# include & lt; Opencv2/opencv. Hpp>
Using the namespace CV;
Int main ()
{
//VideoCapture capture (" F: \ \ video \ \ 1. Avi ");//read video
VideoCapture capture (0);//read camera
While (1)
{
Mat frame;
Capture> Frame;
Imshow (" readvideo, "frame);
WaitKey (30);
}
return 0;
}
Run to imshow function will appear when the error
I am a novice, just to learn, to get to the Internet to find a lot of methods, including waitKey time instead of what, all useless, have a great god know what's the problem,
CodePudding user response:
I have just a piece of code, for your reference,
Void ThreadFunction (void * Param)
{
_this FacePhoto *=Param (FacePhoto *);
Frame IplImage * and * frame_copy=0;
Cascade=(CvHaarClassifierCascade *) cvLoad (" haarcascade_frontalface_alt. XML ", 0, 0, 0).
if( ! Cascade)
return;
Eye_cascade=(CvHaarClassifierCascade *) cvLoad (" haarcascade_eye. XML ", 0, 0).
if(! Eye_cascade)
return;
Storage=cvCreateMemStorage (0);
CvCapture * capture=cvCaptureFromCAM (0);
Int rw=cvSetCaptureProperty (the capture, CV_CAP_PROP_FRAME_WIDTH, 1920);
Int rh=cvSetCaptureProperty (the capture, CV_CAP_PROP_FRAME_HEIGHT, 1080);
If (capture)
{
_this - & gt; ThreadExit=false;
while(! _this - & gt; ThreadTerminated ())
{
If (_this - & gt; IfTakePhotoPaused ())
continue;
if( ! CvGrabFrame (capture))
break;
Frame=cvRetrieveFrame (capture);//from cameras capture a frame image
if( ! Frame)
break;
if( ! Frame_copy)
Frame_copy=cvCreateImage (cvSize (frame - & gt; Width, frame - & gt; Height),
IPL_DEPTH_8U, frame - & gt; NChannels);
If (frame - & gt; Origin==IPL_ORIGIN_TL)
CvCopy (frame, frame_copy, 0);
The else
CvFlip (frame, frame_copy, 0);
//gWaitCount + +;
_this - & gt; DetectAndDraw (frame_copy);
CvReleaseImage (& amp; Frame_copy);
}
}
CvReleaseCapture (& amp; The capture);
_this - & gt; ThreadExit=true;
CvReleaseMemStorage (& amp; Storage);
CvReleaseHaarClassifierCascade (& amp; Cascade);
CvReleaseHaarClassifierCascade (& amp; Eye_cascade);
G_event. SetEvent ();
}