C++ cv::Mat::release()Opencv3 C++;
我有一个opencv3上的程序问题,这是调试回溯C++ cv::Mat::release()Opencv3 C++;,c++,opencv,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_righte
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;}
intmain(){
级联;
级联1;
级联2;
初始检测器(面级联、眼级联1、眼级联2);
//初始化并分配内存以从摄像机加载视频流
摄像机(0);
如果(!camera.isOpened())
返回1;
while(true)
{
//按顺序抓取并检索视频的每一帧
垫架;
相机>>帧;
//将感兴趣区域设置为框定义的区域
cv::Rect roi;
roi.x=0;
roi.y=0;
roi.width=640;
roi.height=480;
//将原始图像裁剪到定义的ROI
cv::Mat裁剪=帧(roi);
cv::imshow(“作物”,作物);
向量预处理面;
Mat显示框;
frame.copyTo(displayedFrame);
//找到一张脸并对其进行预处理,使其具有标准大小、对比度和亮度。
Rect faceRect;//检测到的面的位置。
Rect searchedLeftEye,searchedRightEye;//搜索眼睛的面部左上和右上区域。
指向左眼,右眼;//检测到的眼睛的位置。
GetPreprecedFace(帧、面宽度、面层叠、眼层叠1、眼层叠2、分别预处理LeftandRight、&faceRect、&leftEye、&rightEye、&searchedLeftEye和&searchedRightEye);
//等待40毫秒
int c=等待键(40);
//如果用户按下“Esc”键,则退出循环(“Esc”的ASCII值为27)
如果(27==char(c))
打破
}
返回0;}
这是完整的代码如果打开
-g
(调试符号)编译器标志,您可能会从回溯中获得一些更有用的数据(即行号)。此外,可能会有所帮助,尽管我现在还不能说。我没有在代码中发现任何引人注目的东西。请确保您没有在发布模式下链接调试库,或者反之亦然。