cv :: Mat :: release()中的分段错误Opencv3 C ++

时间:2015-10-15 23:26:13

标签: c++ opencv

我在opencv3上有一个程序有问题,这是调试回溯

Loaded the Face Detection cascade classifier [lbpcascade_frontalface.xml].
Loaded the 1st Eye Detection cascade classifier [haarcascade_lefteye_2splits.xml].
Loaded the 2nd Eye Detection cascade classifier [haarcascade_righteye_2splits.xml].
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
VIDIOC_QUERYMENU: Invalid argument
[New Thread 0x7fffdef9d700 (LWP 17762)]
[New Thread 0x7fffdeb9c700 (LWP 17764)]
[New Thread 0x7fffd6b9c700 (LWP 17763)]
+++++Cara detectada
        ojos abiertos

Program received signal SIGSEGV, Segmentation fault.
0x0000000000403967 in cv::Mat::release() ()
(gdb) bt
#0  0x0000000000403967 in cv::Mat::release() ()
#1  0x0000000000403730 in cv::Mat::~Mat() ()
#2  0x000000000040342a in main ()

这是主要代码,我是opencv和c ++的新手,我试图检测眼睛是否闭合。我希望你能帮我看看我的错误

int main(){
CascadeClassifier faceCascade;
CascadeClassifier eyeCascade1;
CascadeClassifier eyeCascade2;
initDetectors(faceCascade, eyeCascade1, eyeCascade2);
// Initialize and allocate memory to load the video stream from camera
VideoCapture camera(0);

if (!camera.isOpened())
    return 1;

while (true)
{
    // Grab and retrieve each frames of the video sequentially

    Mat frame;

    camera >> frame;

    // Set Region of Interest to the area defined by the box
    cv::Rect roi;
    roi.x = 0;
    roi.y = 0;
    roi.width = 640;
    roi.height = 480;

    // Crop the original image to the defined ROI
    cv::Mat crop = frame(roi);

    cv::imshow("crop", crop);

    vector<Mat> preprocessedFaces;

    Mat displayedFrame;
    frame.copyTo(displayedFrame);

    // Find a face and preprocess it to have a standard size and contrast & brightness.
    Rect faceRect;  // Position of detected face.
    Rect searchedLeftEye, searchedRightEye; // top-left and top-right regions of the face, where eyes were searched.
    Point leftEye, rightEye;    // Position of the detected eyes.

    getPreprocessedFace(frame, faceWidth, faceCascade, eyeCascade1, eyeCascade2, preprocessLeftAndRightSeparately, &faceRect, &leftEye, &rightEye, &searchedLeftEye, &searchedRightEye);

    //wait for 40 milliseconds
    int c = waitKey(40);

    //exit the loop if user press "Esc" key  (ASCII value of "Esc" is 27)
    if (27 == char(c))
        break;
}

return 0;}

这是完整代码http://pasted.co/51b5c5dc

0 个答案:

没有答案