Image source: https://unsplash.com/photos/black-glass-bottles-on-stainless-steel-table-hgrFoK4bjao
m5_nut
on mine, though yours could vary. Click on “Save labels” to advance to the next image in the dataset, and you will notice that the bounding boxes will follow through to the next picture, making this process quick and easy. Once complete, you can click on “Dataset” to return to the summary list of data elements. You can click on them if you’d like to inspect them closer, but they should be ready for use at this point.
m5_nut
. Click “Save Impulse”.
nodejs
and npm
, so that we can install the Edge Impulse Linux Runner. You could go down the path of building Yocto yourself (I tested it, and it does work fine), but to save you the trouble Avnet has already gone ahead and built one, that you can find in their Sharepoint site here:
https://avtinc.sharepoint.com/teams/ET-Downloads/Shared%20Documents/Forms/AllItems.aspx?id=%2Fteams%2FET%2DDownloads%2FShared%20Documents%2Fprojects%2FRenesas%20RzBoard%20V2L%2Fsoftware%5Fimage%5Ffiles%2FRZBoard%5FEdgeImpulse%5FeMMC%2Ezip&parent=%2Fteams%2FET%2DDownloads%2FShared%20Documents%2Fprojects%2FRenesas%20RzBoard%20V2L%2Fsoftware%5Fimage%5Ffiles&p=true&ga=1
avnet-core-image-rzboard-20230124105646.rootfs.wic
. (If you enter the folder at the top-most directory, navigate into the “images” folder to find it there). Download that file, and flash it directly to an SD Card. Now, on the RZBoard, you’ll need to flip a small DIP-switch that tells the board to boot from SD Card instead of the eMMC storage. Look for two tiny switches near the headphone jack, and make sure they are both flipped away from the headphone jack, facing the silkscreened 1
and 2
markings on the switch. Here is an example of how mine looks:
NOTE: You can also attach a serial console and use Putty or a similar terminal application, if that’s easier for you.We’ll also need to expand the available space on the SD Card, so enter:
p
to print the current partition information, and make note of the mmcblk0p2
start address displayed on the screen. We’ll need that in a moment (mine was 204832
). Follow the series of commands below to [p] print the partition info, [d] delete the current second [2] partition, make a [n] new [p] primary second [2] partition, and type in the start address you discovered a moment ago and press [enter]. Then press [enter] again on the next question to accept the default end address, [N] to not remove the signature, and [w] to write the changes to disk. The chain of commands is thus:
/root/.ei-linux-runner/models/315846/v15/model.eim
). You can also load http://:4912 in a browser on your development machine, to get a view from the camera with any detected objects outlined by bounding boxes. Before we move on to building our object counting application, let’s highlight an important item here. My inference time as you can see below is approximately 8ms to 10ms, so roughly 100 inferences per second - incredible performance. The web view of the camera however, provides a slow frame rate: The reason is that the sample webserver sending the camera view is not really optimized, and the WiFi latency itself is also at play here. A compiled binary version of an application is much more responsive.
portaudio
, pip
, a few dependencies, edge_impulse_linux
, and set the Display variable. You could probably wrap this all up into a shell command to run in bulk, but here are the individual commands to run:
nano unique_count.py
and then pasting in the following python snippet (it might be faster to copy/paste this snippet into a file on your desktop/laptop, and then copy the file directly on to the RZBoard’s SD card, or use a serial console so that you can copy/paste from host to device, instead of typing this all in to that terminal window directly on the RZBoard).
/root/.ei-linux-runner/models/315846/v15/model.eim
earlier when we ran the Linux Runner the first time. Finally, it is time to test out the counter, simply run python3 unique_count.py
, and in the terminal you will see the number of detected M5 nuts that are in view of the camera printed out to the console.
I was able to then use the conveyor belt and observe the quantity increase and decrease as the bolts moved down the line and entered / exited the field of view of the camera.
nano total_count.py
and paste in the following snippet:
Like the first application, it might be easier to use a serial console or just copy the file directly onto the RZBoard’s SD Card from your development machine, to save the typing.For this application, we’ll need to append the model file to use to the command, so from the terminal session on the RZBoard run:
python3 total_count.py /root/.ei-linux-runner/models/315846/v15/model.eim
It will take a moment for the camera view to appear on screen, and it should be noted that once again the framerate here is not optimized, as we are running non-threaded single core python, and compiled code is much faster. But for purposes of demonstrating how to achieve the counting, this will work. I once again turned on the conveyor belt, and as M5 hex nuts travel past the camera, the count increases by one in the rendered camera view window. My model could probably benefit from some extra images added to my dataset, as I did have a few sneak by undetected, so perhaps 60 images was not quite enough in the training dataset, but we have proven the concept works!