简体   繁体   English

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

[英]keyboard input to save image detected from video stream in opencv

I was trying to do facial recognition using opencv and save the image detected in the cvRect when an input from the keyboard(in my case, when "c" on the keyboard is pressed, an image should be created with the detected face in the folder. ) However, I guess the interrupt ( cvWaitKey() ) is giving me lots of problems and there is no response from the system. 我正在尝试使用opencv进行面部识别,并在键盘输入时保存在cvRect中检测到的图像(在我的情况下,当按下键盘上的“c”时,应该在文件夹中使用检测到的面部创建图像。)但是,我猜中断( cvWaitKey() )给了我很多问题,系统没有响应。 Would really appreciate your input in this area! 非常感谢您在这方面的投入!

The code is here: 代码在这里:

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);
}

The code before this will be very standard face detection from webcam. 此前的代码将是网络摄像头非常标准的人脸检测。 And it works. 它有效。 thanks! 谢谢!

67? 67? It's clearer to write 'C' . 'C'更清楚。 That would also have shown you the real problem: you probably meant 'c' 这也会向你展示真正的问题:你可能意味着'c'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM