Simple person detection Using Tinker Board and Balena Cloud

Few months ago I wrote a post to extract h264 data from a v380 camera and streamed it over RTSP using rtsp simple server. Recently I coupled that with Asus TinkerBoard and Balena cloud to have the ability for the v380 camera to detect a person in the frame.

To implement this I tried (as much as I could) to use the code that is already available and not to write anything from the scratch. So for the person detection, I used the code from pyimagesearch. To deploy this code, I used balena's debian-python:3.7-build container image.

To stich everything together and pass on the output from the object detection module to the clinet, I used tornado.

I’m yet to post the source code for this demo on github, I’ll do that soon.

How does it work?

There are two parts, the client that runs on a computer/PC and the server that runs on the tinkerboard (you can use other boards also, balena supports a wide range of devices).

How to implement it?

Create an application and add devices to it on balena cloud

The detailed documentation for doing the above mentioned process is available at

Just a quick note, you can ssh into both your host os running on the device as well as in a specific container where your application is running.

In order to do that

# to login to an application container
$ balena ssh <device id> <container>
# to login to the host os on the device
$ balena ssh <device id>


For this demo, I’ve used tornado instead of flask. The main reason behind using tornado is that it uses non blocking network I/O so it is better for serving the data over websocket.

The directory structure for this project looks like

├── Dockerfile.template
├── MobileNetSSD_deploy.caffemodel
├── MobileNetSSD_deploy.prototxt.txt
├── requirements.txt
├── src
│   ├──
│   └──

1 directory, 8 files

Push the code on to the devices

Once this is in place, push the code to the device with

$ balena push <application_name>

Once this is done, you will have a person detection service running for v380 camera.

NOTE: All of the code mentioned in this post so far is taken from a various sources on the internet and stitched together.It needs refactoring 😅 The purpose of this exercise was to hack on tinkerboard to try out balena os and balena cloud to have a quick and dirty solution running.

Key take aways from this post.

balena is: