[OpenR8 solution] Image_VideoCapture_OpenCV (Capture webcam images using OpenCV's VideoCapture)
  1. 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.png

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.

 

 

  1. 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.png

Fig. 2. Image_VideoCapture_OpenCV location.

 

Fig. 3. Image_VideoCapture_OpenCV folder.png

Fig. 3. Image_VideoCapture_OpenCV folder.

 

 

  1. 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.png

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.png

Fig. 5. Select OpenCV_VideoCapture.flow.

 

Fig. 6. Open OpenCV_VideoCapture.flow.png

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.png

Fig. 7. Change parameter.

 

After confirming the device code of the webcam, you can press Run.

 

Fig. 8. Run the solution.png

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.png

Fig. 10. Press any key to close the DOS window.

 

 

  1. Chapter4: OpenCV_VideoCapture.flow Process

 

Fig. 11. OpenCV_VideoCapture.flow process.png

Fig. 11. OpenCV_VideoCapture.flow process.

 

  1. OpenCV_VideoCapture_Init: videoCaptureObject: Initialize before using OpenCV VideoCapture.

 

  1. 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.png

Fig. 12. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Open.

 

  1. OpenCV_VideoCapture_SetResolution:

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.png

Fig. 13. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_SetResolution.

 

  1. OpenCV_VideoCapture_Grab:

Capture webcam image.

 

Fig. 14. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Grab.png

Fig. 14. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Grab.

 

  1. OpenCV_VideoCapture_Retrieve:

Get the image of "OpenCV_VideoCapture_Grab".

grabbedImage: Output image.

 

Fig. 15. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Retrieve.png

Fig. 15. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Retrieve.

 

  1. Image_Show:

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.png

Fig. 16. OpenCV_VideoCapture.flow - Image_Show.

 

Fig. 17. Window Title Signal.png

Fig. 17. Window Title Signal.

 

  1. OpenCV_VideoCapture_Release:

Close the webcam.

 

Fig. 18. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Release.png

Fig. 18. OpenCV_VideoCapture.flow - OpenCV_VideoCapture_Release.

 

  1. waitKey:

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.png

Fig. 19. OpenCV_VideoCapture.flow - waitKey.

 

  1. Image_DestoryAllWindows Closes the image window displayed by all “Image_Show”.

Recommended Article

1.
OpenR8 Community Edition - AI Software for Everyone (Free Download)