Forum

Creating a color tracker in VVVV

Hi I am trying to create a color tracker in VVVV similar to the free frame node (as the free frame node seems to have some limitations in tracking)

Any ideas on how I should start.

Thanks as I am still new to VVVV

hey acforst,

the new library for computervision in vvvv that will allow you to create your own color tracker is VL.OpenCV. you can use it in vvvv beta or gamma but if you don’t need any beta-specific features you’ll have more fun using it in vvvv gamma.

so either way, make yourself familiar with vl.opencv by going throw the patches that come with the helpbrowser and then come back with more specific questions.

roughly i’d say you’ll first have to filter out the desired colors of your image and then, depending a bit on your input use either a blobtracking or contours node on that filtered image…

Hi Joreg,

Thank you for your reply.
I have managed to create the following patch by modifying some example patches. I can filter the desired color through HSV and extract the contours but I would now like to get the convex hull of the 2 objects separately. I am having trouble using the convex hull node as it only accepts sequence of vector2 and the contour node outputs collection of vector2.
Any ideas on how I can get this done?

Thanks again!

Contours returns a Spread of Spread of Vector2, ie a Spread of Contours. So you want to do:

grafik

ForEach contour compute the ConvexHull…

let us know if you need more help on this…

1 Like

Thank you I have now managed to get the convex hull of the objects.

So for the next step what should be my approach for colour tracking?
Should I try and get the object’s center coordinates, if so how can I achieve this?

Thanks & Merry Christmas!

Also just as a follow up question.
How can I allow for tracking of multiple colours like in the free frame node?
Because my current approach uses the within range(hsv) node to limit the hsv colour range.

Hey @acfrost!

As far as getting the filtered color masks, WithinRange and HSV images are the right way to go. If you want to track multiple colors individually you would need to repeat the process for each HSV range you want to track. If you want to track multiple colors without differenciating between them, you can get the mask for each color you want to track and then combine them using OR, AND or Mult depending on what you are after.

I would have gone with a non-contour approach using FindNonZero on the mask resulting from WithinRange and averaging the positions to get an approximation to the center of the color blob.

Hope that helps.

Hi Ravazquez,

Thanks for your in-depth answer. I try all of this out and get back to you if I have any further questions.

we indeed don’t have a convenient way yet to get a contours centroid…OpenCV has it, we just have to expose that bit…

just as an alternative you could also have a look at the BlobDetector.

and then if you need stable IDs for moving blobs, try VL.TrackObjects.

@acfrost as of version 1.2.1 of VL.OpenCV you can find the Centroid node, also all contour related nodes have been properly tagged to make finding them in the node browser easier.

Thanks to @joreg for taking care of this!

Wow thanks guys!
I will try updating it and see. I actually managed to get it working with the blob detector like you guys suggested as well. I am now trying to map the opencv coordinates to the VVVV 3D renderer space.
I think it is covered in this video https://www.youtube.com/watch?v=4hPH5CokxwQ&t=2972s at about 45:10 for anyone else that is interested.

@acfrost this might be a good read for you: https://github.com/vvvv/VL.OpenCV/wiki/Coordinate-system-conversions-between-OpenCV,-DirectX-and-vvvv

Thanks ravazquez!
That seems like exactly what I need.

1 Like