Build and enable the local computer camera in the opencv environment ., Opencv camera

Source: Internet
Author: User

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:




Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.