Real time object/people detection with Node-RED and Yolo

A few weeks ago I came across Yolo (you only look once), an object detection system build on the darknet neural network platform. Until then I wasn’t spending my time with machine learning and neural networks. But Yolo got me triggered.

At home I have some IP camera’s watching the house using ZoneMinder. Unfortunately I was never very succesfull at configuring ZM to detection motion by people without also capturing rain, snow and motion by wind.

When I heard about Yolo I immediatly thought this could by the sollution to the never ending struggle to configure ZM to detect people without generating false alarms.

As metionned in an earlier post I’m using Node-RED to do some automations and data processing around the house (see house of things).

Getting all those elements together I want to create a system roughly presented by the schematic below:

YUsing Yolo in Node-RED

I will still use ZoneMinder to capture the streams from the IP camera. Using het http node in Node-RED I’ll fetch the image from the monitor and save it in a temporary file.

Node-RED will pass the image to Darknet Yolo and wil get the result from the analysis. If a person has been detected an MQTT message will be published to trigger an alarm. The implemented flow in Node-RED looks as follows. Note that MQTT is currently replaced by a debug and a pushbullet node.

Node-RED flow with Yolo object detection

The first three nodes are pretty straight forward. The inject node has an interval of 5 seconds. Five seconds might seem a long time but since my server has no GPU available for the VM that’s runing Yolo it takes some time to process the images.

The interval inject node triggers an http request to zonemineder:

1
http://zmserver/zm/cgi-bin/zms?mode=single&monitor=2

Replace the monitor value by the correct monitor id in the url above.

The next node is a file node that saves the images to the Node-RED server for processing by Yolo later on.

After the file has been saved it’s time for Yolo to do it’s magic. The image is passed to Yolo for object and people detection. This is acheived by using the exec node with the following command:

1
cd darknet; ./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights ../monitor_2.jpg

As you can see in the command I’m using tiny yolo, for the same reason as mentioned before: the lack of a GPU in the Node-RED server. Darnet is located in the ‘darknet’ directory and the imge in my home directory. This is why I first change directory to darknet and use ../monitor_2.jpg in the darknet command.

The result of the exec node is interprede by a function. This can be used to look for people, cars, or any other object that Yolo is capable to detect. This function on it’s turn also builds a message for pushbullet, a debug node, or later on an MQTT node.

Want to know how to get Yolo running on your server? Have a look on the darknet yolo page as it contains very clear instruction on how you can get this done. Or just execute the following commands in the home directory on your Linux (Ubuntu) server:

1
git clone https://github.com/pjreddie/darknet cd darknet make

You will also need the .weights file for the neural network. Download the weights file using the following command:

1
wget https://pjreddie.com/media/files/yolov3.weights

Or for tiny yolo:

1
wget https://pjreddie.com/media/files/yolov3-tiny.weights

How does tiny yolo perform for people detection?

Unfortunately it’s a bit dissapointing. Mainly because of the circumstances I’m using the camera and because of tiny yolo being a bit less acurate than the regular yolo network.

One camera is installed in my garage where most of the time light conditions are bad and the camera goes to night vision. In this mode the pretrained network doesn’t perform at all. When enough light is available and the images are bright and colorfull tiny yolo sometimes detects people.

A test with regular yolo showed that this is much more accurate (but it takes 50 seconds to process one image). When I use the not-tiny yolo even the bikes in my garage are recognized.

A solution would be to train yolo to work with night vision images, but since I don’t have good hardware to do this (lots of GPU) I didn’t take a shot on that route. Maybe that’s someting to try in the future…

1 Comment

  1. JeVois machine learning – Techible.net on June 17, 2019 at 11:37 am

    […] Last week I wrote a post on how I’m implementing Yolo into my security camera system. You can read this article here: https://techible.net/real-time-object-people-detection-with-node-red-and-yolo/ […]

Leave a Comment





This site uses Akismet to reduce spam. Learn how your comment data is processed.