How to make the people counter

Hi guys.I wanna make the people counter like that Opencv Python - People Counter - YouTube
I searched how to be made with opencv-pyhton but it is difference more than openmv’s functions and classes.I don’t understand exactly. Is there who guide to me? or ıs there who
make like that ?

Ah, that’s just frame differencing with blob tracking. See the frame differencing example scripts and then call find_blobs on the difference image to find all the blobs.

That said, this just gets you where people blobs are… The next step is to determine up and down direction. This requires you to have state and keep track of each blob and how it’s moving.

Thank you :slight_smile: I have a question.I need to “drawcontours” but ı didnt find what provide it as drawcontours.Should ı do about it?

Please use the find_blobs() method. image — machine vision — MicroPython 1.15 documentation

It gives you this output: image — machine vision — MicroPython 1.15 documentation

That’s my video!! :smiley:
Anyways, as suggested, you need to keep a track of each blob/contour found and then decide whether it’s moving up or down.

hi kwagyeman can you explain further how can I determine the up and down direction and how to count them if they pass a certain line.

I don’t actually know. Generally, you try to break the problem down and think of something that may work.

This might work…

  1. For every frame detect all the blobs and then add new blobs that meet a threshold quality of “goodness” (for you to decide what that is) into a global tracked blob list.
  2. If a blob is spatially similar to a tracked blobs already in the tracked blob list update the position of the tracked blob. If not, create a new tracked blob.
  3. If a tracked blob has not been updated in a while then remove it from the list (i.e. have a aging timer on each blob).

Now you can track objects over multiple frames.

Next, when a blob passes a certain pixel position (let’s say it’s centroid) count when you see a delta in the tracked blob’s position update over the line in the center of the image. For robustness, define the line such it’s a low and hi pixel position and not just one value so there’s some hysteresis and you don’t get multiple triggers if a blob hovers on the line.

thank you for your quick response kwagyeman

By hysteresis I mean… like, only say it’s going down if it passes the low position in one direction during an update and if the state of the blob was not going down and only up if it passes the high position during an update and if the state of the blob was not going up. This prevents triggering multiple times from blob tracking noise.

Hi,

Could you make the person count with OpenMV?

I need counting people in both directions.

Thanks you.

You can use our person detector to kinda do this. But, we don’t have an out of the box solution to do it easily.