I'm trying to use OpenCV with Processing 4 on a MAC with Catalina. However, I am getting the following error:
WARNING: An illegal reflective access operation has occurred
WARNING: Illegal reflective access by gab.opencv.OpenCV (file:/Users/mmemmo/Documents/Processing/libraries/opencv_processing/library/opencv_processing.jar) to field java.lang.ClassLoader.sys_paths
when I run this code
import gab.opencv.*;
import processing.video.*;
import java.awt.*;
Capture video;
OpenCV opencv;
void setup() {
size(640, 480);
video = new Capture(this, 640/2, 480/2);
opencv = new OpenCV(this, 640/2, 480/2);
//CASCADE_EYE
opencv.loadCascade(OpenCV.CASCADE_FRONTALFACE);
// opencv.loadCascade(OpenCV.CASCADE_EYE);
video.start();
}
void draw() {
scale(2);
opencv.loadImage(video);
image(video, 0, 0 );
noFill();
stroke(0, 255, 0);
strokeWeight(3);
Rectangle[] faces = opencv.detect();
println(faces.length);
for (int i = 0; i < faces.length; i++) {
println(faces[i].x + "," + faces[i].y);
rect(faces[i].x, faces[i].y, faces[i].width, faces[i].height);
}
if(faces.length > 0 ){
println("Hello Human");enter code here
}
}
void captureEvent(Capture c) {
c.read();
}
I know Processing has camera issues with Catalina. That doesn't seem to be the issue here. I was able to get the camera working just fine in other sketches.
I would appreciate any feedback. Thanks.
The module system introduced in Java 9 has more limitations in what modules can use of the functionality of other modules. See this question and answers for more information: what is an illegal reflective access
Is there a specific reason that you are using Processing 4? There are only alpha releases available at the moment, so I would use Processing 3 if possible. When I try to run your code in Processing 4, I get the same error as you. When I run your code in Processing 3.5.4 (on Ubuntu), it runs without any issues and facial recognition is working. I would recommend giving Processing 3 a try.