
Intro
As any large retailer knows, lots of potential profits are lost each year due to shoplifting. Shoplifters are rarely caught, and even when they are, many regions have minimal punishment so shoplifters go right back to committing the crime. For this experimental project, I will use a new Vision AI single board computer from Texas Instruments, the TDA4VM, to detect forbidden bags. The TDA4VM SoC and it’s Starter Kit contains a dual-core Arm Cortex-A72 processor, C7x DSP, and deep learning, vision and multimedia accelerators onboard.TDA4VM Starter Kit Setup
First, download the OS image that TI provides here: https://www.ti.com/tool/download/PROCESSOR-SDK-LINUX-SK-TDA4VM Flash the image onto a microSD card (there is one included with the kit, along with a power cable) and place the card into the board. The TDA4VM Starter Kit board is able to use a Raspberry Pi camera, connected with a standard ribbon cable. In fact, the board actually supports two Raspberry Pi cameras, as there are two connectors on the board. But, at the time of this tutorial, Edge Impulse support for the Raspberry Pi camera is not yet available, so instead you can use popular USB cameras like the Logitech C270, C920 or C922. Connect the camera to a USB port (use a blue USB 3.0 port if possible) and power the board with at least a 5V/3A power supply. Once booted, you’ll notice the OS is not a typical Linux version. It called Arago, and has some differences that you might not be used to. Connecting a USB keyboard and HDMI screen won’t work, for example. Instead, you can connect to the board with a UART cable, but since the software tools included are limited (There is nonano
editor, just vi
so don’t forgot the combinations :q
, etc!), it is better to connect the Ethernet cable to a router, obtain the IP by checking DHCP lease, and access the board through SSH and SFTP.
The OS user account credentials are username: root
, and there is no password. After you connect with SSH, you will have to press Enter again since there will be no greeting, otherwise and you may think the board is locked up or powered off.
If you want to configure the Raspberry Pi camera (though it won’t work with Edge Impulse, as mentioned), open /run/media/mmcblk0p1/uEnv.txt
and edit the file to include:
$sudo reboot
Data Acquisition
The first step is in a computer vision project is data collection, which in this case requires images. We need pictures of bags, lots of them. How can we get those pictures? Open Camera is an Android app that includes a “repeat” option that can take X pictures every Y seconds. Using a white background, I took 100 pictures of different bags in different positions. More pictures is even better, but 100 is enough to get started. Then, upload those files to Edge Impulse and label them. Uploading images is easy, using the Edge Impulse Studio.Note: you can also skip this Data acquisition step, by simply cloning my Edge Impulse project, which will provide you with the images I collected.



Model Training
With the data all uploaded and labeled, go to Impulse Design. An Impulse is a machine learning pipeline. In the first block, select Image Data if it is not already chosen, and set the image width and height to 96 pixels, and Fit shortest axis. Next, choose Image for the Processing block. Then Object Detection in the Learning block. You can learn more about block choices here.



Model Deployment
To take the built model and install it on the TDA4VM Starter Kit board, head back to your SSD connection to the board. Run this command to install the Edge Impulse Linux runner on the board:.zip
file that gets generated. That file is going to be needed on the TDA4VM board, so you could use SFTP to place it onto the board, or perhaps just use a USB drive and copy the file from your laptop or desktop PC, onto the USB stick, then place the USB stick into the TDA4VM board and copy it from USB to the local filesystem.

$ unzip tda4vmbagdetector-tidl-lib-v17.zip
Then run:


Output Example

- Download
readLog.py
from https://github.com/ronibandini/TDA4VM-bag-detector - Edit the file to set your Telegram Token, Chat ID and Confidence % threshold
- Transfer the file to the TDA4VM via SFTP, or using a USB stick like previously
- Run the application with
$ python3 readlog.py
Conclusion
In this tutorial, we have built a proof-of-concept project to help deter shoplifting and theft. We used a Texas Instruments TDA4VM Vision AI Starter Kit and Edge Impulse to train a computer vision machine learning model that can detect bags, deployed the model to the TDA4VM board, and then added an application that can send an alert if a bag is identified during inferencing. The hardware acceleration built-in to the TDA4VM board performed inferencing at approximately 1ms, or 100 frames per second in this test. Only one camera is being used in this demonstration, but the TDA4VM can support up to 8 cameras simultaneously.Sources
- https://recfaces.com/articles/shoplifting-statistics
- https://software-dl.ti.com/jacinto7/esd/processor-sdk-linux-edgeai/TDA4VM/latest/exports/docs/devices/TDA4VM/linux/getting_started.html
- https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1137524/faq-edge-impulse-setup-on-ti-processors-arm-only?tisearch=e2e-sitesearch\&keymatch=faq%3Atrue