Ask Your Question

rSi's profile - activity

2013-04-01 13:09:42 -0600 commented answer How to Install OpenCV with Processing??

thanks for your answer! i'm a bit confused, because following the link you posted i could not find a tutorial on installing openCV... how to use it with processing is well documented. i was confused, because processing.org points you to: http://ubaa.net/shared/processing/opencv/ for the windows binaries you need to use with processing. i didn't know that its a different code base. thanks!

2013-04-01 09:35:30 -0600 commented question How to Install OpenCV with Processing??

I'm having troubles using OpenCV in processing 2.0b7 and 2.0b8 on WIN7 64. i've installed the binaries and put the openCV bin in my system PATH variable. i've installed the OpenCV libraries in my processing sketchbook/libraries folder. but when i open the blobs example from the OpenCV examples i get the following error: >Cannot find class or type named "Rectangle"<

here is the code from the example: ANY help would be much appreciated!!

import hypermedia.video.*;


OpenCV opencv;

int w = 320;
int h = 240;
int threshold = 80;

boolean find=true;

PFont font;

void setup() {

    size( w*2+30, h*2+30 );

    opencv = new OpenCV( this );
    opencv.capture(w,h);

    font = loadFont( "AndaleMono.vlw" );
2013-04-01 09:09:54 -0600 received badge  Editor (source)
2013-04-01 09:08:53 -0600 answered a question How to Install OpenCV with Processing??

I'm having troubles using OpenCV in processing 2.0b7 and 2.0b8 on WIN7 64. i've installed the binaries and put the openCV bin in my system PATH variable. i've installed the OpenCV libraries in my processing sketchbook/libraries folder. but when i open the blobs example from the OpenCV examples i get the following error:

Cannot find class or type named "Rectangle"<

here is the code from the example: ANY help would be much appreciated!!

import hypermedia.video.*;


OpenCV opencv;

int w = 320;
int h = 240;
int threshold = 80;

boolean find=true;

PFont font;

void setup() {

    size( w*2+30, h*2+30 );

    opencv = new OpenCV( this );
    opencv.capture(w,h);

    font = loadFont( "AndaleMono.vlw" );
    textFont( font );

    println( "Drag mouse inside sketch window to change threshold" );
    println( "Press space bar to record background image" );

}



void draw() {

    background(0);
    opencv.read();
    //opencv.flip( OpenCV.FLIP_HORIZONTAL );

    image( opencv.image(), 10, 10 );                // RGB image
    image( opencv.image(OpenCV.GRAY), 20+w, 10 );   // GRAY image
    image( opencv.image(OpenCV.MEMORY), 10, 20+h ); // image in memory

    opencv.absDiff();
    opencv.threshold(threshold);
    image( opencv.image(OpenCV.GRAY), 20+w, 20+h ); // absolute difference image


    // working with blobs
    Blob[] blobs = opencv.blobs( 100, w*h/3, 20, true );

    noFill();

    pushMatrix();
    translate(20+w,20+h);

    for( int i=0; i<blobs.length; i++ ) {

        Rectangle bounding_rect = blobs[i].rectangle;
        float area = blobs[i].area;
        float circumference = blobs[i].length;
        Point centroid = blobs[i].centroid;
        Point[] points = blobs[i].points;

        // rectangle
        noFill();
        stroke( blobs[i].isHole ? 128 : 64 );
        rect( bounding_rect.x, bounding_rect.y, bounding_rect.width, bounding_rect.height );


        // centroid
        stroke(0,0,255);
        line( centroid.x-5, centroid.y, centroid.x+5, centroid.y );
        line( centroid.x, centroid.y-5, centroid.x, centroid.y+5 );
        noStroke();
        fill(0,0,255);
        text( area,centroid.x+5, centroid.y+5 );


        fill(255,0,255,64);
        stroke(255,0,255);
        if ( points.length>0 ) {
            beginShape();
            for( int j=0; j<points.length; j++ ) {
                vertex( points[j].x, points[j].y );
            }
            endShape(CLOSE);
        }

        noStroke();
        fill(255,0,255);
        text( circumference, centroid.x+5, centroid.y+15 );

    }
    popMatrix();

}

void keyPressed() {
    if ( key==' ' ) opencv.remember();
}

void mouseDragged() {
    threshold = int( map(mouseX,0,width,0,255) );
}

public void stop() {
    opencv.stop();
    super.stop();
}