键盘输入以保存从opencv中的视频流中检测到的图像

时间:2014-01-29 21:35:58

标签: c++ opencv

我正在尝试使用opencv进行面部识别,并在键盘输入时保存在cvRect中检测到的图像(在我的情况下,按下键盘上的" c"图像应该是使用文件夹中检测到的面创建。)但是,我猜中断(cvWaitKey())给了我很多问题,系统没有响应。非常感谢您在这方面的投入!

代码在这里:

char d = cvWaitKey(33);

if (d==67) // if the keyboard c is pressed
{   
    // r is the cvRect created for the face detected
    cvSetImageROI(img, cvRect(pt1.x,pt1.y,r->width,r->height));

    //img is the video frame passed in here
    IplImage* img2 = cvCreateImage(cvGetSize(img),img->depth,img->nChannels);

    cvCopy(img, img2, NULL);

    cvResetImageROI(img);

    cvSaveImage("roi.jpg",img2);
}

此前的代码将是网络摄像头非常标准的人脸检测。它有效。谢谢!

1 个答案:

答案 0 :(得分:2)

67?写'C'更清楚。这也会向你展示真正的问题:你可能意味着'c'