I’m preparing a workshop using Processing 4.02b, but OpenCV library seems to have an issue with permissions.
WARNING: Illegal reflective access by gab.opencv.OpenCV (file:/Users/Name/Documents/Processing/libraries/opencv_processing/library/opencv_processing.jar) to field java.lang.ClassLoader.sys_paths
WARNING: Please consider reporting this to the maintainers of gab.opencv.OpenCV
WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations
WARNING: All illegal access operations will be denied in a future release
NullPointerException
This a java feature since java 11, but is normally (up to jdk11 at least) only a warning that you can ignore. Ideally you want the OpenCV library updated to module version that explicitly permits reflective access.
The problem is not the warnings themselves. The warnings are telling you the library is doing something it shouldn’t be. In this case, setting a private field to null in such a way that worked in JDK 8 and throws an exception in JDK 11 - the internal behaviour of ClassLoader has changed quite a bit.
However, I still got the error “A library used by this sketch relies on native code that is not available. UnsatisfiedLinkError: no opencv_java400 in java.library.path: :/Applications/Processing.app/Contents/Java/core/library/macos-x86_64:…”
Yes, I solved it by copying the file “libopencv_java400.dylib” to /Applications/Processing.app/Contents/Java/core/library
Of course, with updated library from above. Let me know if it fixed your case.
I am new in Image/video processing field. I want to learn OpenCV in Processing 4.0b2.
I could not run the very first example “BackgroundSubtraction”. IDE throws the following messages:
Processing video library using bundled GStreamer 1.16.2
java.lang.NoSuchFieldException: sys_paths
at java.base/java.lang.Class.getDeclaredField(Class.java:2610)
at gab.opencv.OpenCV.addLibraryPath(Unknown Source)
at gab.opencv.OpenCV.initNative(Unknown Source)
at gab.opencv.OpenCV.(Unknown Source)
at BackgroundSubtraction.setup(BackgroundSubtraction.java:30)
at processing.core.PApplet.handleDraw(PApplet.java:2142)
at processing.awt.PSurfaceAWT$9.callDraw(PSurfaceAWT.java:1440)
at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:356)
OpenCV for Processing 0.5.4 by Greg Borenstein http://gregborenstein.com
Using Java OpenCV 2.4.5.0
IllegalArgumentException: Width (0) and height (0) cannot be <= 0
IllegalArgumentException: Width (0) and height (0) cannot be <= 0
IllegalArgumentException: Width (0) and height (0) cannot be <= 0
Could not run the sketch (Target VM failed to initialize).
For more information, read Help ? Troubleshooting.
At line no. 20 IDE shows the command " opencv.loadImage(video); " highlighted.
void setup()
{
size(720, 480);
video = new Movie(this, "street.mov");
opencv = new OpenCV(this, 720, 480);
opencv.startBackgroundSubtraction(5, 3, false);
println(frameCount, video.width, video.height);
video.loop();
video.play();
int t1 = millis();
while (video.width == 0 )
{
//println(millis());
if (millis() - t1 > 1000)
{
// Can add a message here if over 1000 ms or 1 s
}
}
int t2 = millis();
println(t2-t1, video.width, video.height);
}
Thanx a lot @Dazzid …!! This really help me. And also thanx @kkirklewski for the tip on moving the file.
I was going crazy trying to make it work on a mac M1 Monterey, processing 4.
Though this might help:
With the info on this current thread, and the following line of code (for gstreamer), I was able to run it correctly.
Instead of initializing the Capture instance like this:
video = new Capture(this, width, height);
Do it like this:
video = new Capture(this, 640, 480, “pipeline:avfvideosrc device-index=0 ! video/x-raw, width=640, height=480, framerate=30/1”);