Page 1 of 1

Detect motion direction

Posted: Sun Aug 07, 2016 8:50 am
by bob63
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.

Re: Detect motion direction

Posted: Sun Aug 07, 2016 8:58 am
by iabdalkader
Yes, you could use optical flow for that, you won't need to implement anything it's already implemented.

Re: Detect motion direction

Posted: Tue Aug 09, 2016 3:47 pm
by bob63
oK, perfect !
I've placed my order yesterday .
Thanks again.

Re: Detect motion direction

Posted: Tue Aug 09, 2016 8:16 pm
by kwagyeman
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.

Re: Detect motion direction

Posted: Fri Sep 09, 2016 4:25 pm
by bob63
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.

Re: Detect motion direction

Posted: Fri Sep 09, 2016 7:14 pm
by kwagyeman
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?

Re: Detect motion direction

Posted: Sat Sep 10, 2016 3:48 am
by bob63
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.

Re: Detect motion direction

Posted: Sat Sep 10, 2016 10:56 am
by kwagyeman
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.

Re: Detect motion direction

Posted: Sun Sep 11, 2016 6:13 am
by bob63
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.

Re: Detect motion direction

Posted: Sun Sep 11, 2016 12:11 pm
by kwagyeman
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.