<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