ofCvBlobTracker?

I know this is not finished/available for use yet but can someone give me a quick tutorial on how an ofCvBlobTracker SimpleApp would look like? I’m guessing that from the opencv addon simmple app I would somehow pass the contourFinder blob vector to the blobtracker’s trackBlobs function, but first I should setListener on the blobtracker. Then how do I get the event data? Anyway I’m sure I could trial and error it but it would be cool if someone with knowledge would give me a hand.

P.S. This seems very “beginners” to me but if this is the wrong thread I am sorry.
Also if this is something I should not be messing with yet because of reason x I am sorry too.

Ding

if you’re on a mac, you could try using this app that I put together for when i need to do cv related blobtracking.

its just a mishmash of the old cvBlobTracker that I think stefanix put together updated to work with the actual ofxOpenCv addon.

http://www.stfj.net/cvBase.zip

zach_gage,

Thanks for your help I really appreciate it but when I try to download it I get this error:

stfj.net/cvBase.zip doesn’t exist… maybe it never did. Why not check in here?

BTW I am on a mac. The blobtracker I was refering is the one on the updated ofxOpenCv addon that can be downloaded if you go here:

http://wiki.openframeworks.cc/index.php?title=OfLondon

and scroll down to Oli’s project (very funny and cool BTW) he’s got a link to download it. I sends out blob event data. Im still trying to figure it out.

Thanks,

Ding

You Know maybe I should try using the search option more often:

http://www.openframeworks.cc/forum/view-…-c&start=15

cant test it now but I assume it works.

BTW nice synth pond thingy!

Ding

thanks!

oh man, im an idiot sorry!!

heres the proper link if you still need it:

http://www.stfj.net/misc/cvBase.zip

thanks,

A blend of both projects was what I was looking for. I am still curious if there is a proper way to get the blob information into the draw part of the app. Right now I’m going to try a “for loop”/iterator on the tracker.blobs vector. I know there are delegates like blobon, blobupdate and bloboff and I was wondering if these might be used instead and how to do it properly.

ding

I think I posted the following example a while back. It shows how to hook up the listeners. It is not up to date for OF v0.5 but shows the idea. I am currently in the process of repackaging all that code and it might be more useful then.

http://file.stefanix.net/blobTrackingExample.zip

The crucial parts are:

blobTracker.setListener( this );
and
class testApp : public ofSimpleApp, public ofCvBlobListener { … }

thanks stefanix,

I was just wondering how to use the blob data to draw with. For example:

when blob is on draw circle 50px
when blob is updated draw circle 10px
when blob is off delete circle

Should I iterate the tracker.blobs vector in the Draw method of my app or is there a better way.

ding

This really depends. There is nothing wrong with doing this like you suggested.

I usually make that “circle” an object and then relay the status to it from the touch handlers. So circle would have on, off, moved handlers which I call from the main handlers when the circle is actually touched, moved, etc. Based on that circle should know how to draw itself for these events. This means in the main draw you would only need to call circle.draw()

Hope this helps,

Another option is that if you’re just drawing circles where the blobs are, simply iterating through the blobtracker.trackedblobs vector and drawing circles at all of its positions every frame…

as long as the background clears every frame this would work.

im not sure if i completely understand your question

I think stefanix is understanding me. So I would create a class and set up parameters with setters and getters and pass those setters and getters to the touch handlers

like this maybe:

  
class Target {  
  
  public:  
      
    Target();  
    ~Target();  
  
    bool on, off, moved;  
    float X, Y;  
  
    draw();  
};  
  
-----------------------------------  
Target::Target {  
    on = moved = false;  
    off = true;  
}  
  
Target::draw {  
      
    if (on || moved) {  
        //color red  
        ofSetColor(200, 0, 0);  
        //draw target  
        ofCircle(X, Y, 30);  
        ofCircle(X, Y, 20);  
        ofCircle(X, Y, 10);  
}  

and then over on the app part---------------->>

  
  
Target target  
  
void testApp::blobOn( int x, int y, int id, int order ) {  
    target.on = true;  
    target.X = x;  
    target.Y = y;  
}    
  
void testApp::blobMoved( int x, int y, int id, int order) {  
     target.moved = true;  
     target.X = x;  
     target.Y = y;  
}  
  
void testApp::blobOff( int x, int y, int id, int order ) {  
    target.off = true;  
}  

but wouldn’t this just create one target drawing? I’m a bit confused.

Sorry for the long post

ding

Thanks Stefanix for the example code,

It seems that when i run the code, my fps drops tremendously from 30 (with no blob tracking) to 10fps (with blob tracking on)…even though i have set the fps to 60.

Is this framerate drop due to tracking being done? Anyway, i am doing this on a laptop with only an in-built Intel media accelerator.

are there any examples of blobTracker that work with current oF version? i’ve tried converting the ones linked in this and other posts but there are too many errors i don’t understand.

also - i’m confused, with the current oF fat version which includes ofxOpenCv, is blobTracking still not included, so i need to add code from others, e.g. ofCvBlobTracker from stefanix?

i am doing overhead object detection of people walking around, so i’m starting with the basics and working my way up. afaik, at the current time in oF i will need to use some combination of blob tracking and optical flow, or perhaps the cvvidsurv which is not in ofxOpenCv yet, correct?

also - i’m confused, with the current oF fat version which includes ofxOpenCv, is blobTracking still not included, so i need to add code from others, e.g. ofCvBlobTracker from stefanix?

yes, it’s not a part of the ofxCv addon that comes with the FAT download.

I’ll let stefan jump in about any errors, but maybe you can post up what problems you have ?

take care,
zach

first i tried updating stefanix code to actual included ofxCV, but then thought it would be faster to update code from zach_gage (http://www.stfj.net/misc/cvBase.zip).

get 847 errors, e.g.:

ofxOpenCV/dll/cv100.dll - no such file

libguide40.dll - no such file

Poco/FIFOEvent.h - no such file

ofAddons.h is deprecated … !!!

lots and lots of ____ has not been declared

lots and lots of field '____" has incomplete type

etc…

it looks as if you are compiling a 0.05 project in 0.06 – which will get you a world of pain (since the layout of files and libraries changes from release to release. I recommend you duplicate an 0.06 project which does compile (like the opencv example since it has the addon up and running) and copy your source code into that project.

projects (ie, xcode files, code blocks files, etc) are not compatible from version to version but source generally* is.

* = maybe a few errors based on small changes, but not tons :slight_smile:

take care,
zach

thanks for the quick responses. i realize i am trying to port 05 code to 06, which is a bad idea - that’s why i initially asked if there were any examples that already work in 06. but there doesn’t seem to be?

i have created a new project in 06 and copied code over, now using stefanix’s code again, from http://file.stefanix.net/blobTrackingExample.zip. i dragged his ofxOpenCVBlobTrackingExt folder into addons (using xCode 3). deleted references to addons.h due to compile errors but not sure what else i need to change.

getting errors such as:

expected class-name before “{” token

in class ofxCvTrackedBlob.h : 17
class ofxCvTrackedBlob : public ofxCvBlob {

you can either add addons.h (which isn’t in the project, but you can find it in OF/addons and drag it over) OR you can add #include “ofxCvMain.h” or something like that – likely, you are not including opencv thus getting errors.

can you give that a try ? feel like posting a ZIP of an 0.06 project, we can help ?? !!

take care,
zach

cool! i got it to work by adding #include “ofxCvMain.h” to ofxCVBlobTracker.h. thank you. i added it to main.cpp and testApp.h first, which didn’t work. i must admit, i’m still confused about proper form for addons, and why some includes are duplicated in files (e.g. main.cpp and testApp.h) and some aren’t. to use a simple example, if ofMain.h is included in main.cpp, and then testApp.h is included, why does testApp.h also need to have an include ofMain.h? i thought the code was inserted by the compiler in a linear fashion. the wiki page (http://wiki.openframeworks.cc/index.php-…-ing-addons) did not clarify much for me, unfortunately. i guess i should move this to another thread.

back to motion tracking: i will post this working example but it would be good for others if i made sure it was good form for 06 - what else should i look out for in terms of deprecated style, etc.?

can you direct me to a simple optical flow and vidSurv example that I will also try to update for 06? i will post all 3 when i get them working.

thanks

Hi

New to OF, but getting stuck into the world of code. Good work, guys!

Here’s a sample app I put together mashing up Stefanixs’ code and the openCV sample app - thought I’d share it for noobies like me. It runs on XCode for OSX10.6 and on OF0061. Haven’t checked it on older versions of OF.
http://olliepalmer.com/labs/code/opencv-stefanix3.zip

As I say, new to this world of code/forum, so not sure of protocols - if I’m doing something wrong, let me know!

One question - how do I get hold of blob coordinates? Trying to create an app that enables me to interface with Arduino through blob tracking, but haven’t been able to find the blob coordinates.

Keep up the good work! :smiley:

Ollie