2. Read data from camera

Source: Internet
Author: User

The OpenCV Highgui module provides the Cvcreatecameracapture (), which can be read into the video stream from the camera device, and the function parameter is the device ID instead of the file name. The default value is-1, which is to randomly select a device.

Sample program:

1 /************************************************************************/2 /*read data by camera*/3 /************************************************************************/4 5#include"cv.h"6#include"highgui.h"7 8 intMainintargcChar**argv)9 {TenCvnamedwindow ("cameracapture", cv_window_autosize); Onecvcapture*capture; A     if(ARGC = =1) -     { -Capture = cvcreatecameracapture (-1); the     }  -     Else -     { -Capture = Cvcreatefilecapture (argv[1]); +     } -ASSERT (Capture! =NULL); +  Aiplimage*frame; at      while(1) -     { -frame =Cvqueryframe (capture); -         if(!frame) Break; -Cvshowimage ("cameracapture", frame); -         Charc = Cvwaitkey ( -);//Set Frame rate in         if(c = = -) Break;//Press ESC to exit -     } to  +Cvreleasecapture (&capture); -Cvdestroywindow ("cameracapture"); the  *     return 0; $}

2. Read data from camera

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.