Detect motion direction

Hi,
I would like to know if OpenMV can be the right device for a my project.
I need detect the direction of someone/something that transit under a door without have any marker or pre defined shape.
The OpenMV could be the right device for this scope and in which way I could implement ?
Comparing more pictures is able “easily” to define the direction?
Thanks.

Yes, you could use optical flow for that, you won’t need to implement anything it’s already implemented.

oK, perfect !
I’ve placed my order yesterday .
Thanks again.

Can you let me know exactly what you want to do? I’ll be able to give a better explanation of the steps you have to take then.

I want place the openmv camora on the top of a door to count how many person pass under the door from left to right and viceversa and count the transit in both direction. I’ve tryed the example available but not really understood how works an how decode the output for my scope.
Thanks.

Okay, so, is the room in a controlled environment and is the lighting constant? If so, it will actually be better to use color tracking for anything that isn’t the color of the hallway. The camera will then tell you about all the color blobs moving around in the hallway.

Each blob will give you a bounding rectangle along with centroid information. From that you can track the direction of travel. This will only easily work for one person at a time though. Is that okay?

Hi,
unfortuantely I can’t assume that the light will be always costant because during the day the light in the rooms could change. My idea was catch periodically the picture of the floor having so a reference and then compare this picture with frames taken when someone pass trought the door to understand the direction . The Optical Flow looks good if I understand how interpreter the output data.
Thanks. Roberto.

Okay, then you’ll want to do combined frame differencing with blob detection.

Optical flow is really for just using the Cam like a mouse.

So, see the advanced frame differencing script. Is in the examples folders. Anyway, after you have the difference frame you can use the find_blobs function on the image (looking for any color that ins’t black) to find all the changes in the image. Then you can track the movement of those blobs.

The hard part will be getting direction information from movement. Doing it for one blob is not so hard. Multiple blobs will be a challenge.

Trying to test the basic and advanced frame differencing scripts I got this error msg IMPORT ERROR : no module named ‘os’ .
I’m using a 4 gb sd , that I normally use on the PyBoard without problems.
Thanks Roberto.

Hi, you need to update your firmware. We released a new version of the Ide that hasn’t the newest firmware that fixes this issue. When Ibrahim updated the MicroPyhton version to v1.8 the os module was not included.