My pet project from this weekend: findContours (openCV) added to cv.jit

lightspeed.johnny's icon

I am not sure why the amazing cv.jit package does not include support for findContours - but when I found myself having a need for it, I spent the weekend getting it to work...

I am pretty happy with the results - especially after running the cvFindContours() results through cvApproxPoly() to reduce the point count (which is super important for my project).

I am currently working on some better control over the coloring - right now it simply uses a matrix of color choices in the right inlet and iterates over these colors for each path - which looks ok for static images, but for movies / animations - it results in a the same path being colored different each frame - which looks kinda bad. I am going to add the option of coloring all enclosing contours the same color - and also add the option to color based on contour area size - which should improve the results for movies / animations.

I also discovered by accident that jit.movie allows you to drop image files as well as movie files - so I simply use a dropfile->read->jit.movie path - and then do rgb2luma->cv.jit.canny->cv.jit.findContours.

Thanks to C74 for updating the cv.jit package to 64bit and moving the build files to Xcode! That was super helpful when it came time to debug the crazy CvSeq structure that findContours uses.

LSka's icon

This is great!
Any plan for sharing it?

Rob Ramirez's icon

yes please share. perhaps we can get this incorporated into the jit.cv package.

lightspeed.johnny's icon

Absolutely - I need to spend some time to clean it up and harden it up - but have no problems sharing. I was thinking a bit more about the coloring of the paths - and will probably add an optional inlet where you can pass in the original RGB raster image and it will sample colors for the paths from the original image.

LSka's icon

Yes, that could be very useful, although I believe the native system is more intended as an ID number for contours, rather than color, and keeping that option would be still very useful for some applications.

TConnors's icon
JFS's icon

This looks great - am bumping to see if this can be shared.

John Daniel's icon

cool.

yes, please share when you can.

Rajan Craveri's icon

I'm interested too

Max Doe's icon

When will it be shared ? We have been waiting 5 years now……

are u still coding ?

Rajan Craveri's icon

Dear Max Doe I shared an object to find contours here it's free
https://www.patreon.com/posts/cv-jit-rj-win-42931605

Max Doe's icon

Thanks a lot for the link. Very nice patch. Kind regards from Switzerland