Chapter1: Image_VideoCapture_OpenCV Introduction
Image_VideoCapture_OpenCV is a VideoCapture using OpenCV. The image read by the webcam is captured and displayed in the window.
The Image_VideoCapture_OpenCV process is shown in Fig. 1, and how it is operated and used in the chapter3 of this document will be described.
Fig. 1. Image_VideoCapture_OpenCV process.
※ The example of this document only intercepts the first image in the video, and if you want to retrieve the image continuously, you need to add the loop yourself.
Chapter2: Image_VideoCapture_OpenCV Folder Introduction
Image_VideoCapture_OpenCV is in the solution folder of OpenR8, such as Fig. 2, with the OpenCV_VideoCapture.flow file inside.
Fig. 2. Image_VideoCapture_OpenCV location.
Fig. 3. Image_VideoCapture_OpenCV folder.
Chapter3: Open and Run OpenCV_VideoCapture.flow
There is a "R8.exe" execution file under the OpenR8 folder, such as Fig. 4. R8.exe can be executed with double-click.
Fig. 4. Run R8.exe.
Please click "File" => "Open" => "to enter the solution folder under OpenR8" => "Select Image_VideoCapture_OpenCV folder" => "Select OpenCV_VideoCapture.flow", such as Fig. 5, Fig. 6.
Fig. 5. Select OpenCV_VideoCapture.flow.
Fig. 6. Open OpenCV_VideoCapture.flow.
Check the webcam device code.
※ Only one webcam user doesn’t need to change, if there are more than two and want to use other webcam to install the user, you need to set their own device code, its set value of 0: the first webcam, 1: the second webcam, and so on.
Fig. 7. Change parameter.
After confirming the device code of the webcam, you can press Run.
Fig. 8. Run the solution.
After running the OpenCV_VideoCapture.flow, the webcam opens, retrieves an image, displays the image in the window, presses any key, or X closes the image.
Fig. 10. Press any key to close the DOS window.
Chapter4: OpenCV_VideoCapture.flow Process
Fig. 11. OpenCV_VideoCapture.flow process.
- OpenCV_VideoCapture_Init: videoCaptureObject: Initialize before using OpenCV VideoCapture.
- OpenCV_VideoCapture_Open: videoCaptureObject: Select “OpenCV_VideoCapture_Init” the same object. deviceNumber: You can specify which webcam to use, 0 for the first webcam, 1 for the second webcam, and so on.
Fig. 12. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Open.
Sets the size of the display webcam capture image.
videoCaptureObject: Select “OpenCV_VideoCapture_Init” the same object.
frameWidth: Sets the width of the retrieved image.
frameHeight: Sets the height of the retrieved image.
Fig. 13. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_SetResolution.
Capture webcam image.
Fig. 14. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Grab.
Get the image of "OpenCV_VideoCapture_Grab".
grabbedImage: Output image.
Fig. 15. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Retrieve.
Displays the image of "OpenCV_VideoCapture_Retrieve" in the window.
image: Select the image output by OpenCV_VideoCapture_Retrieve.
displayPercentage: Displays the image zoom scale, which defaults to 100 (= 100% normal size) when not filled in.
windowTitle: The name of the window that is displayed.
Fig. 16. OpenCV_VideoCapture.flow - Image_Show.
Fig. 17. Window Title Signal.
Close the webcam.
Fig. 18. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Release.
After the "Image_Show" must be added "Wait" to see the image, the image stay how many microseconds set.
KeyCode: The output signal.
milliSeconds: If you want the image to close until any key is pressed, set 0, and if you want the image to be turned off after 1 second, set 1000, and if you want to turn it off after n seconds, set 1000 * n.
※ 1 second = 1000 microseconds.
Fig. 19. OpenCV_VideoCapture.flow - waitKey.
- Image_DestoryAllWindows Closes the image window displayed by all “Image_Show”.