ofxOpenCV Blob interaction with shapes when null blobs exist

Hi y’all

I’ve tried a few ideas out in order to get blobs interacting with shapes in project I’m working on, but I can’t seem to get it working well when there are null blobs in the blob array.

I’m thinking it might be a problem I haven’t even thought of. The only thing I can think of is making an if when null blobs are present, but it crashes.

Any ideas? how would something like this work? thanks =D

You mean you need to know if there are any blobs and it crashes when you try to ?

if you have
ofxCvContourFinder cntrfinder;

just do

if(cntrfinder.blobs.size() > 0){

then do something with the blobs

for(int i=0; i<cntrfinder.blobs.size(); i++){
// cycle through each blob

thanks chrisoshea :smiley:

I’ll check when I get back home =D

by the way, might you know of a book or extensive tutorial in which to learn of such interactions?

thanks in advanced =D

after a few fixes the idea worked great!
Thanks chrisoshea :smiley: