Build and enable the local computer camera in the opencv environment ., Opencv camera
1. Refer to the link for building the opencv environment. My test is on the win8 system.
# Include <cv. h> # include
If you want to use opencv to open the laptop camera and extract images from the video, the image is not displayed after a single camera is opened.
You are Opencv1.0, right? I do not know the specific reason, but I was not able to use it at the beginning, but after using VS2005 to configure Opencv2.0, my camera in this book can be called.
Hope to help you!
How To Enable usb camera with opencv
Why can't I open my camera?
# Include "cv. h"
# Include "highgui. h"
# Include "iostream"
Using namespace std;
Int main (int argc, char * argv [])
{
CvCapture * cap;
Cap = cvCaptureFromCAM (1 );
If (! Cap)
{
Cout <"create camera capture error" <endl;
System ("pause ");
Exit (-1 );
}
CvNamedWindow ("img", 1 );
IplImage * img;
While (1)
{
Img = cvQueryFrame (cap); // capture and decode the video frames of the camera.
If (! Img)
Break;
If (img-> origin = IPL_ORIGIN_TL) // if the image origin is in the upper left corner, flip it along the X axis to make the lower left corner
{
CvFlip (img, img );
}
CvShowImage ("img", img );
CvWaitKey (3 );
}
CvReleaseCapture (& cap );
CvDestroyAllWindows ();
CvReleaseImage (& img );
Return 0;
}
The following prompt appears: