Two cameras, two models - running multiple object detection models on the RZ/V2L
Last updated
Last updated
In this tutorial, you will learn how to run multiple cameras with multiple models simultaneously on the Renesas RZ/V2L microprocessor. The models used for this demo are:
YOLOv5 - Face detection using DRPAI acceleration
ResNet - Number recognition on AARCH64 (no acceleration)
To follow this tutorial, you will need a combination of hardware and software tools. You will need an Edge Impulse compatible Renesas RZ board, either the Renesas RZ/V2L smarc board or the Avnet RZBoard. In addition to the board, the following additional items are needed:
Two webcams - the webcams used for this tutorial are:
Logitech C920 HD Pro Webcam
Logitech C922 Pro Stream 1080p Webcam
USB hub (to connect the cameras to the Renesas RZ/V2L board)
Ethernet cable or USB serial cable
Note that any webcams will suffice for this application. Some details will have to be modified depending on the cameras, this is explained in detail further along in the tutorial.
In order to successfully install and run the application, you need access to the target's Linux terminal. You may require other hardware like ethernet cable or USB to serial cable to achieve this. Detailed instructions on how to set the device up and gain access to the Linux are not provided here. For the Renesas RZ/V2L board, please refer to this page and for the Avnet RZBoard, please refer to this page.
The models used for this tutorial can be downloaded as a zip file from this link. The file (models-20230921T125858Z-001.zip
) that you download, may be named differently for you. Once the file has been downloaded, go ahead and unzip the files either in the GUI or as follows:
There are two folders in this zip file. The cpu directory contains a ResNet model that identifies numbers for a Linux aarch64 target without acceleration by the DRPAI. The drpai directory contains a YOLOv5 face detection model for the RZ/V2L microprocessor with DRPAI acceleration incorporated. Once the files have been extracted, their permissions need to be changed to make them executable. This can be done as follows:
The application required to run the two models simultaneously must be downloaded from the Edge Impulse CLI repository. The simplest way to do this is to run the following command in your terminal/command line application:
If you would like to do it manually, it can be downloaded here at the branch classify-camera-finer-control, at commit number: 1fc1639acdfb9e7af3fc8794619334b28dffac00
. Once the application has been downloaded, unzip the contents, navigate to the directory and list the contents to ensure the operation was successful. This can be done as follows:
While staying at the same directory, install the dependencies and build the application as follows:
Please ensure that you are inside the directory edge-impulse-linux-cli-classify-camera-finer-control
when installing and running the application.
Before we can run the application, please ensure that the directory structure is as follows:
In the previous step, we installed an application called classify-camera. To run this app with two cameras and two separate models, the same app needs to be executed twice in two separate terminal instances with different cameras. The arguments required by the app are:
model - name of the model to executed in the current instance (required)
camera - the name of the camera to be used for the instance as detected by the system (required)
fps - frames per second of the input stream. This will affect the speed of the app (default: 5)
width - the width of the input image directed to the respective model (default: 640)
height - the height of the input image directed to the respective model (default: 480)
The syntax of the command to be executed is as follows:
Before running the first instance, we first need to determine the names of the webcam(s) that are detected by the system. The correct name is required to direct the stream from camera to the respective models. The easiest way to do this is by running the command with only the model as an argument. In this case:
The command will fail and result in an error with the error message containing names of the connecting cameras. In this case, the output might be as follows:
From this output, we can determine that the names of cameras detected by the system are "HD Pro Webcam C920" and "C922 Pro Stream Webcam". These names can now be used to run the application. Before running the application, ensure that your current working directory is correct - it needs to be the edge-impulse-linux-cli-classify-camera-finer-control
folder. In this case, the cd
commands from the following instructions can be omitted.
You will need to open two terminal instances.
In terminal 1 run the following command:
And in terminal 2 run the following command:
Once both these commands have been executed, you will be able to see the results of the models in the terminal similar to the following in terminal 1:
and the following in terminal 2:
Running the application in this way will not provide a visual output. To see a visual result of this inference, please see the following section.
The above steps are enough to execute both models and see their outputs in the terminal. However, it is always better to see a visual output of the image detection models that are being executing. With a slight modification of the execution commands, it is possible to run the application using WebServer and see the visual output.
The arguments to run the application using WebServer are as follows:
model - name of the model to executed in the current instance (required)
camera - the name of the camera to be used for the instance as detected by the system (required)
fps - frames per second of the input stream. This will affect the speed of the app (default: 5)
width - the width of the input image directed to the respective model (default: 640)
height - the height of the input image directed to the respective model (default: 480)
port - this is the port to which the output from the cameras and application is directed (default: 4912)
The syntax of the command to be executed is then changed to the following:
Similar to running the application before, you will need to open two terminal instances.
In terminal 1 run the following command:
The terminal output from this command will be:
Navigating to the address mentioned in the output (http://192.168.178.30:4912
in this case), you will see an output similar to this:
In terminal 2 run the following command:
The terminal output from this command will be:
Note that the port numbers passed as arguments must be different. This allows for the streams to be directed to different ports to be viewed in the browser.
Navigating to the address mentioned in the output (http://192.168.178.30:4912
in this case), you will see an output similar to this:
Now you have two models running simultaneously. You will notice that the model running on the CPU has a significantly higher inference time (above 1200ms) as opposed to the model running on the DRP-AI (under 10ms). You can see a side by side view of this parallelism:
You can see the two models running simultaneously in the video below:
Congratulations! You have successfully run two Edge Impulse generated models simultaneously on the Renesas RZ/V2L device. You will notice that the model run using the DRP-AI accelerator is orders of magnitude faster than the one running simply on the CPU.
Using this application, you can run any two image-based models simultaneously on the RZV2L device. If you have a great idea for a different project, that's fine too. Edge Impulse lets you capture data from any sensor, build custom processing blocks to extract features, and you have full flexibility in your Machine Learning pipeline with the learning blocks.
The possibilities are endless, and we can't wait to see what you'll build! 🚀