For a more in-depth guide, we've created a detailed tutorial hosted on GitHub. In this tutorial, you'll find step-by-step instructions, code examples, and additional resources to help you better understand and implement the concepts discussed here. Whether you're a beginner or looking to deepen your knowledge, this comprehensive guide covers everything you need.
You can access the GitHub repository with the full code here: https://github.com/System-Electronics/astrial_tutorials/tree/main/05-usb_camera
IntroductionThis tutorial will explore how to set up and use the Astrial board with a USB camera. The Astrial board is a versatile platform designed for various embedded applications. By connecting a USB camera, you can leverage the power of the Astrial board to capture and process video streams, making it suitable for projects in computer vision, surveillance, and interactive media.
The following sections will guide you through the necessary hardware and software setup steps. By the end of this tutorial, you will have a functional video stream from your USB camera displayed on a monitor connected to the Astrial board. Additionally, we'll run a detection script to demonstrate basic image processing capabilities.
Hardware setup stepsTo get started, let's prepare the hardware:
- Connect the USB camera: connect the USB camera to the CM4's USB port
- Connect an HDMI monitor: for this tutorial, to see the video stream, you need to connect a display to the CM4's HDMI port
With the hardware in place, we can now proceed to the software configuration:
- Create the example script: copy the bash script named detection.sh from the Code section below to the Astrial board, placing it in the /home/root/apps/detection directory. This script will handle the video processing tasks.
scp detection.sh root@<astrial_ip>:/home/root/apps/detection
- Check camera ID and input resolution: before running the script, we need to identify the camera and its supported resolutions. Open a terminal on the Astrial board and use the following command to check the camera ID and available input resolutions:
gst-device-monitor-1.0
You should see an output similar to the one shown in the code section.
In this case, the device ID is /dev/video3, and 1920x1080 is the only available resolution, but you may have different values if you use a different camera.
- Run the script: execute the detection script with the appropriate parameters. Replace /dev/video3 with your camera's device ID, and adjust the width and height to match your chosen resolution:
cd /home/root/apps/detection
./detection.sh -i /dev/video3 -w 1920 -h 1080
You should now see the video stream on your monitor. Put some objects in front of the camera and see if they get detected.
Comments