Display driver stopped responding and has succesfully recovered during detectMultiScale
I'm making the object detection tutorial in Java. The face detection is working but the eye detection crashes the program. Windows gives me a pop-up that says:
Display driver stopped responding and has succesfully recovered.
This is my code:
public Mat detectFace(Mat frame){
CascadeClassifier face_cascade = new CascadeClassifier(face_cascade_name);
CascadeClassifier eyes_cascade = new CascadeClassifier(eyes_cascade_name);
Mat greyScale = new Mat();
Imgproc.cvtColor(frame, greyScale, Imgproc.COLOR_BGR2GRAY);
Imgproc.equalizeHist(greyScale, greyScale);
MatOfRect faces = new MatOfRect();
face_cascade.detectMultiScale(greyScale, faces);
List<Rect> facesList = faces.toList();
for(Rect face : facesList){
Point center = new Point ( face.x + face.width*0.5, face.y + face.height*0.5 );
Imgproc.ellipse( frame, center, new Size( face.width*0.5, face.height*0.5), 0.0, 0.0, 360.0, new Scalar( 255, 0, 255 ), 4, 8, 0 );
Mat faceMat = new Mat(greyScale, face);
MatOfRect eyes = new MatOfRect();
eyes_cascade.detectMultiScale(faceMat, eyes);
List<Rect> eyesList = eyes.toList();
System.out.println(eyesList.size());
for(Rect eye : eyesList){
Point eyeCenter = new Point( face.x + eye.x + eye.width*0.5, face.y + eye.y + eye.height*0.5 );
int radius = (int) ((eye.width + eye.height)*0.25 );
Imgproc.circle( frame, center, radius, new Scalar( 255, 0, 0 ), 4, 8, 0 );
}
}
return frame;
}
It crashes at eyes_cascade.detectMultiScale(faceMat, eyes) but face_cascade.detectMultiScale(greyScale, faces) works fine.
EDIT: It seems haarcascade_eye_tree_eyeglasses.xml is the problem. It doesn't crash when using another, but all the others I found don't detect the eyes. Does anyone have a working haarcascade?
Okay some basic remarks but I guess one of them will be the problem
Both are loaded when I check them, and without a face there are no eyes either. Check my edit.
Hmm did you use the latest models from the repository? There were some problems that we fixed 2 months ago on that model.
The latest on github and the one included with 3.0.
The one on github was last updated 2 years ago, can you link me the new one?
Is the one on Github the latest?
Yep it should be --> it does work here ... will check tomorrow at work on other pc
I tried it in c++ but I get the same result. What are the requirements for OpenCV? My laptop has a Intel and Nvidea gpu so maybe that's a problem.
You are not using your GPU here, so that could not be the problem...