Blob collision detection

I am trying to detect collisions between blobs and other objects, such as circles or boxes, but the usual Google search on the subject doesn’t seem to bring up much useful material, which is surprising as apparently it is quite a common project for beginners.

Does anybody know the best way to test the collision of an object against an ofxCvBlob please? Or know of any resources that might be of use?

I understand this is probably more of a maths related question, any help would be greatly appreciated.


Hi, nice username btw.

This is an great question and there are a lot of interesting answers.

I did a google search for “is a point inside a polygon” and got some promising results:

He outlines a few different approaches with code snippets.

Hope this helps

i don’t really know how to answer you but:
ofxCvBlob has boundingRect for an approximate collision detection and
has also pts.
i think a solution should be write a little adapter class that contains (via composition or inheritance?) both ofxCvBlob and ofxBox2dPolygon and make collision detection with box2d

Thanks for the quick response and help guys, really appreciate it.

I looked more into Box2D as you said and came across this post:

Absolutely amazing stuff, can’t seem to find the code for it anywhere though, none of the links work :frowning: would love to see the techniques used.

I think this is the sort of thing I am looking for though, need to work out how to convert the contours of a blob into a Box2D shape and then use it for collision against other obstacles.

Cheers for the help :).

Ok, I have given it a go, tried the following in the update call, where polyLines is a vector.

Works ok, but I believe there is some sort of memory leak or other type of problem as after a while it becomes slugglish then finally breaks.

vector <ofPoint> pts = contourFinder.blobs[0].pts;  
ofxBox2dPolygon poly;  
for (int i = 0; i < pts.size(); i++) {  

Can anybody comment on whether I am going about this the right way or is this completely the wrong approach, just trying to convert a blob contour into a Box2D shape for use with collision detection :).