# Implement a people counter

**URL:** <https://discourse.nodered.org/t/implement-a-people-counter/26614>\
**Category:** General\
**Created:** [13 May 2020 19:16 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614 "2020-05-13T19:16:34Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![gpretto](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@gpretto](https://discourse.nodered.org/u/gpretto)\
**Post date:** [13 May 2020 19:16 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/1 "2020-05-13T19:16:34Z")

</div>

Hi, I have an Rpi 4 and I need to make a people counter from a live video using opencv and python. I'm new to node red, what's the best way to do this?  
sorry about my English.  
Thank you

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [13 May 2020 19:20 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/2 "2020-05-13T19:20:23Z")

</div>

Hi @gpretto

Node-RED is not very suitable for doing real-time video analytics. If you already know how to do it with OpenCV and Python, then do it with those. You could then use an Exec node in Node-RED to run your python code and do things with the results.

---

<div class="post-metadata">

**Author:** ![gpretto](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@gpretto](https://discourse.nodered.org/u/gpretto)\
**Post date:** [13 May 2020 19:26 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/3 "2020-05-13T19:26:36Z")

</div>

Ok, I already did it with python and opencv, I wanted to do it with node red to be able to create a screen that transmits it live over the network, would it be possible?

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [13 May 2020 19:41 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/4 "2020-05-13T19:41:22Z")

</div>

You could do that in Python too of course. However, yes this is achievable in several ways in Node-RED.

The simplest is probably to run your Python app as a service but add a link to a local MQTT server (using Mosquitto for example). This is very low overhead and easy to achieve, there are Python libraries.

Then in Node-RED, you can subscribe to the appropriate topic you've published to and output that direct to a simple Dashboard page.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 May 2020 22:28 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/6 "2020-05-13T22:28:42Z")

</div>

You may want to read and digest this thread - [Standalone Raspberry Pi Security Camera with AI "person detection"](https://discourse.nodered.org/t/standalone-raspberry-pi-security-camera-with-ai-person-detection/1470/33)

---

<div class="post-metadata">

**Author:** ![gpretto](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@gpretto](https://discourse.nodered.org/u/gpretto)\
**Post date:** [14 May 2020 13:19 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/7 "2020-05-14T13:19:19Z")

</div>

Okay, but how do I add the link to a local mqtt?  
could you explain it better?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 May 2020 13:24 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/8 "2020-05-14T13:24:45Z")

</div>

> [@gpretto](#):
>
> but how do I add the link to a local mqtt?

In your python? or in node-red?

In python - [example](https://www.youtube.com/watch?v=QAaXNt0oqSI)

in node-red - [example](https://www.youtube.com/watch?v=LXA-Ge3-ewo)

---

<div class="post-metadata">

**Author:** ![gpretto](https://avatars.discourse-cdn.com/v4/letter/g/d6d6ee/32.png) [@gpretto](https://discourse.nodered.org/u/gpretto)\
**Post date:** [14 May 2020 16:42 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/9 "2020-05-14T16:42:18Z")

</div>

This helped me a lot, thank you for your help.  
Another way would be to implement the people counter in python and create the screen with the functions of the flask library.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [14 May 2020 16:55 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/10 "2020-05-14T16:55:46Z")

</div>

> [@gpretto](#):
>
> Another way would be to implement the people counter in python and create the screen with the functions of the flask library.

Then you lose a bit of the flexibility node-red brings & lose the IoT opportunities MQTT brings.

But yes - of course you can.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [14 May 2020 19:00 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/11 "2020-05-14T19:00:28Z")

</div>

> [@dceejay](#):
>
> You may want to read and digest this thread

Hey Dave,  
I'm wondering why you are not making more advertisement for your node-red-contrib-coco-ssd node here. Seems that people use tensorflow for object counting as in this [video](https://www.youtube.com/watch?v=QL10FwWll44), based on the guy's [Github](https://github.com/ahmetozlu/tensorflow_object_counting_api) repository. If I'm not mistaken he uses object tracking too...

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [13 July 2020 19:00 UTC](https://discourse.nodered.org/t/implement-a-people-counter/26614/12 "2020-07-13T19:00:38Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
