Opencv failed to open the camera

Source: Internet
Author: User
<span style="font-family: Arial, Helvetica, sans-serif;">#include <stdio.h></span>
# Include <cv. h> # include <cxcore. h> # include 

Still that piece of code. Yesterday I understood the meaning of argche argv in the main function parameter table. If you compile and run it directly, it is equivalent to inputting try.exe in the command line, that is, argc is 1.

Go to the command line to run

Result



The result is that you can select a video source and click OK to return to the system in seconds. You can check the development documentation and find that the cvcreatecameracapture (INT index) function can select a camera, however, the actual test showed that cvcapturefromcam only accepted the-1 and 0 parameters, and then changed-1 to 0. The camera can be opened normally.


I have not figured out the specific cause. I checked the official documentation of opencv:

A function in opencv. Initialize obtaining the video cvcapture * cvcapturefromcam (INT index) from the camera );
  • Index
  • The index of the camera to use. If there is only one camera or which camera is used, you can use parameter-1.
The function allocates and initializes the cvcapture structure for the video streams from the camera. Currently, two interfaces can be used in Windows: Video forwindows (VFW) and matrox imaging Library (MIL); and v4l and FireWire (ieee1394) in Linux ).

It is not detailed. The problem remains to be studied ..

In addition, if you want to open the video file to be processed, you can simply put the AVI video in the same directory as the EXE file and enter try2.exe 123. Avi in the command line. ,

Opencv failed to open the 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.