From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

count moving object (Inter the ROI from one side and leave ROI from other side)

Hello All
I want to design program that can counting moving object that inter ROI from one side and come out from the other side, I want to give each object ID number
I have design a program that compare between object distances from one frame to the next frame, but the program efficiency is very low
If any one can give me a sample code that I can use or modify it to suite my application

0 Kudos
Message 1 of 7
(6,093 Views)

Hello,

 

if your setup permits it (i.e. static camera, indoor,...), you could use background subtraction. Simply take the frame without the objects and use it as a reference. Then subtract each subsequent frame from the reference one and threshold the data (you would probably need to use some morphological operations to "clean" the result).

 

More advanced method would be to use the adaptive background model. There are quite a few methods out there, but if you don't need to fully understand the process, you could just use the OpenCV GMM implementation (as a .dll in Labview).

 

Do the paths of the objects intersect? If they do, the objects ID would be more difficult to track.

 

You could also use optical flow to track the objects after you establish an initial location.

 

Always, it is good to provide some sample images to better present your problem.

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 2 of 7
(6,090 Views)

Thank you for your replay

First I didn't have any problem for detect moving object, I have built more algorithm for detecting obgect including Background subtraction

Second obgect doesn't intersect, the problem that I face that counting program and connect each object through multible frame, and give the new object inter ROI new ID

Third for OpenCV, It is the first time to now that you can get library from Opencv In labview if you have much information please show it

Thanks

0 Kudos
Message 3 of 7
(6,086 Views)

Hello,

 

my mistake. Seems I misinterpreted your question.

 

Below is the example of object ID labeling, assuming that the object detection is already performed in the previous step. It will assign a new ID for each new object and keep the ID throughout the field of view of camera. The ID labeling is based on minimum Euclidean distance of object's centers between two successive frames.

 

animation.gif

 

The only problem is when the object goes out of field of view of the camera. The labeling is then incorrect (this can of course be modified).

 

Tell me if this helps and I can attach the example code.

P.S.: The process takes ~12 ms per frame on my computer (includes reading the 11 images (~500x200 resolution) shown in the animation).

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 4 of 7
(6,068 Views)

Very Good

This is what I need

If you have example cood please shear it

for the time talken to excute the code, it is very long for my application

can you tell me you computer specification

0 Kudos
Message 5 of 7
(6,060 Views)

Hello,

 

you will find the code in the attachment (saved for LV2013). There is a longer delay inside the loop, remove it for efficiency.

 

Roughly measuring the time to read an image, the processing takes ~8 ms on my computer (~500x200 image resolution). That is ~125 samples/images per second. Is this not fast enough for you? Considering better image resolution, the time is of course increased.

 

My specifications:

 

Core i7 3632QM

6 Gb RAM

Win 7 x64 (Labview x86 though).

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 6 of 7
(6,045 Views)

Hello

Thank you for your example code, that exactly what I need

I had tried using your code for my application the program give a good result, but when object move out from the ROI the program give false result

Can you fix this problem? or tell me what should I do to modify your code to fix this problem?

If you will fix this problem I will accepte the next post for you as a solution, if not I will accept the last post for you as a solution

Thanks Klemen for your help

0 Kudos
Message 7 of 7
(6,019 Views)