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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Simple object tracking

Hello, I am very new to labview and I am trying to build a vi that will let me open an .avi video file and track an object's motion throughout each frame of the video.

 

I want to have a box to mark the location of the object for each frame, and I plan to do this by using subtraction to locate the object by subtracting all the values of one frame from the frame before that. This way, after subtraction, the only remaining non-zero values should be where the object has moved to. Additionally, I think I may have to implement some sort of threshold value so only certain values will be tracked, but I have not put this in the vi yet.

 

To read each frame, I used the IMAQ frame reader and put the values of that frame into an array (ImageToArray function). However, I am not sure how to set this up in my vi and everything I have tried ends up in error. Also, I am unsure which function to use to actually mark the location of the fish and how to implement it into my loop. I tried to assimilate the example Object Tracker's vi into mine, but I was a bit confused as to how their vi was structured, and how the functions should fit.

 

 

I have attached what I have so far in my vi, any help or guidance on how I can further build my vi would be greatly appreciated. Also, I am sure there are errors all over my vi, but I am unsure on what to fix so far. Thank you very much!

0 Kudos
Message 1 of 5
(4,006 Views)

Hi jshieh,

 

I'm curious if you've looked at the LabVIEW Example "Optical Flow Feature Tracking.vi"? It can be found in the NI Example Finder (Help >> Find Examples..) by selecting the Directory Structure option and navigating to Vision >>Motion Estimation. It reads frames from an AVI file and tracks user specified features in a sequence of images.

I hope this information helps!

 

- Kale

0 Kudos
Message 2 of 5
(3,960 Views)

Hey Kale,

 

I have looked at both the Optical Flow Feature Tracking vi and Object Tracking vi to see if I could tweak either or apply it to my own vi. However, the block diagrams were a bit complicated for me, and I could not use either algorithm to correctly work for .avi files of my own.

 

For the Optical Flow Feature Tracking, I assumed that you would need to input a template image of the object you were tracking in the .avi, and I did not know where in the block diagram to set this option. I guess I just assumed that since it was an example vi, it wouldn't let me change the template image. If this is indeed possible, please let me know!

 

Thanks,

 

JS

0 Kudos
Message 3 of 5
(3,942 Views)

Hi,

 

You can definitely make changes to an example. Often a good starting point for writing code is to find and example that is similar. I would recommend saving it as a copy so that you don't alter all of the shipping examples (Save As... Copy in LabVIEW).

The Optical Flow Feature Tracking VI is using many jp2 images (JPEG 2000) and comparing them. You can see IMAQ Optical Flow (LKP) function on the block diagram that a Current Image and Previous Image are being inputted. One way you might manipulate this is to extract individual images from your avi file and then input those rather than those coming from the IMAQ Vision Examples folder. I would also recommend looking at various AVI examples in LabVIEW such as Read AVI file, Read Write AVI With Data, etc.

 

I hope you find this information helpful!

 

- Kale

Message 4 of 5
(3,910 Views)

Kale,

 

I have worked on my own vi and have made a lot of progress learning LabView and making my code work (although there are definitely still some issues and bugs I am sorting out, hahah)

 

However, I will definitely take your advice and mess around with the example vi to see if it works out much better than the code I have worked on! Thank you very much for the step by step guide on how to manipulate the example vi, I was having trouble before understanding how to use it, hahah.

 

Thank you so much for you help!!

 

-JS

0 Kudos
Message 5 of 5
(3,892 Views)