Ask Your Question
0

Display driver stopped responding and has succesfully recovered during detectMultiScale

asked 2015-07-19 08:11:49 -0600

ventilatorr gravatar image

updated 2015-07-19 11:48:14 -0600

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?

edit retag flag offensive close merge delete

Comments

1

Okay some basic remarks but I guess one of them will be the problem

  1. You do not check whether both cascades where succesfully loaded. You should do that before continuing. You can simply check the return value of the isEmpty function of the cascade.
  2. Afaik you do not cover the fact that you can have no face detection.
StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-19 11:58:02 -0600 )edit

Both are loaded when I check them, and without a face there are no eyes either. Check my edit.

ventilatorr gravatar imageventilatorr ( 2015-07-19 12:03:14 -0600 )edit
1

Hmm did you use the latest models from the repository? There were some problems that we fixed 2 months ago on that model.

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-20 02:21:01 -0600 )edit

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?

ventilatorr gravatar imageventilatorr ( 2015-07-20 06:17:31 -0600 )edit

Is the one on Github the latest?

ventilatorr gravatar imageventilatorr ( 2015-07-22 07:52:43 -0600 )edit

Yep it should be --> it does work here ... will check tomorrow at work on other pc

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-22 08:08:45 -0600 )edit

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.

ventilatorr gravatar imageventilatorr ( 2015-07-23 14:37:20 -0600 )edit

You are not using your GPU here, so that could not be the problem...

StevenPuttemans gravatar imageStevenPuttemans ( 2015-07-24 01:57:47 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2015-07-24 07:47:34 -0600

ventilatorr gravatar image

It's working now. I used the haarcascades_cuda instead of the normal one. I don't know why that worked if I'm not using the GPU but atleast it's working.

edit flag offensive delete link more

Comments

Works for me also.

cypih gravatar imagecypih ( 2016-02-01 03:13:25 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-07-19 08:11:49 -0600

Seen: 1,648 times

Last updated: Jul 19 '15