Ask Your Question

LauraK's profile - activity

2014-09-06 11:39:55 -0600 commented answer How to direct BlobDetection script to local video file, instead of cam

Thank you, that makes sense! I will look and hopefully find an example that also does Blob detection, within Video which is what I am really looking for.

2014-09-06 11:09:50 -0600 received badge  Critic (source)
2014-09-06 11:06:40 -0600 commented answer How to direct BlobDetection script to local video file, instead of cam

Hi FooBar,

Thanks for you help, but as I mentioned I am new to this and the part I am most interested in keeping is the blob detection in a video (which is most of the script). The link you suggest has instructions for pyhton and C++ but I am not familiar with either and using processing. Which will work for me?

2014-09-06 07:06:12 -0600 asked a question How to direct BlobDetection script to local video file, instead of cam

Hi, I am new to OpenCV and using BlobDetection library but need to direct the script to use a local video file instead of the camera. Here is the original script. Would love someone's help please. Thank you.

Using MacOS 64bit

// - Super Fast Blur v1.1 by Mario Klingemann http://incubator.quasimondo.com // - BlobDetection library

import processing.video.; import blobDetection.;

Capture cam; BlobDetection theBlobDetection; PImage img; boolean newFrame=false;

// ================================================== // setup() // ================================================== void setup() { // Size of applet size(640, 480); // Capture cam = new Capture(this, 404, 304, 15); // Comment the following line if you use Processing 1.5 cam.start();

// BlobDetection
// img which will be sent to detection (a smaller copy of the cam frame);
img = new PImage(80,60); 
theBlobDetection = new BlobDetection(img.width, img.height);
theBlobDetection.setPosDiscrimination(true);
theBlobDetection.setThreshold(0.9f); // will detect bright areas whose luminosity > 0.2f;

}

// ================================================== // captureEvent() // ================================================== void captureEvent(Capture cam) { cam.read(); newFrame = true; }

// ================================================== // draw() // ================================================== void draw() { if (newFrame) { newFrame=false; image(cam,0,0,width,height); img.copy(cam, 0, 0, cam.width, cam.height, 0, 0, img.width, img.height); fastblur(img, 2); theBlobDetection.computeBlobs(img.pixels); drawBlobsAndEdges(true,true); } }

// ================================================== // drawBlobsAndEdges() // ================================================== void drawBlobsAndEdges(boolean drawBlobs, boolean drawEdges) { noFill(); Blob b; EdgeVertex eA,eB; for (int n=0 ; n<theblobdetection.getblobnb() ;="" n++)="" {="" b="theBlobDetection.getBlob(n);" if="" (b!="null)" {="" edges="" if="" (drawedges)="" {="" strokeweight(3);="" stroke(0,255,0);="" for="" (int="" m="0;m&lt;b.getEdgeNb();m++)" {="" ea="b.getEdgeVertexA(m);" eb="b.getEdgeVertexB(m);" if="" (ea="" !="null" &amp;&amp;="" eb="" !="null)" line(="" ea.x<em="">width, eA.yheight, eB.xwidth, eB.yheight ); } }

        // Blobs
        if (drawBlobs)
        {
            strokeWeight(1);
            stroke(255,0,0);
            rect(
                b.xMin*width,b.yMin*height,
                b.w*width,b.h*height
                );
        }

    }

  }

}

// ================================================== // Super Fast Blur v1.1 // by Mario Klingemann // http://incubator.quasimondo.com // ================================================== void fastblur(PImage img,int radius) { if (radius<1){ return; } int w=img.width; int h=img.height; int wm=w-1; int hm=h-1; int wh=wh; int div=radius+radius+1; int r[]=new int[wh]; int g[]=new int[wh]; int b[]=new int[wh]; int rsum,gsum,bsum,x,y,i,p,p1,p2,yp,yi,yw; int vmin[] = new int[max(w,h)]; int vmax[] = new int[max(w,h)]; int[] pix=img.pixels; int dv[]=new int[256div]; for (i=0;i<256*div;i++){ dv[i]=(i/div); }

yw=yi=0;

for (y=0;y<h;y++){ rsum="gsum=bsum=0;" for(i="-radius;i&lt;=radius;i++){" p="pix[yi+min(wm,max(i,0))];" rsum+="(p" &amp;="" 0xff0000)&gt;&gt;16;="" gsum+="(p" &amp;="" 0x00ff00)&gt;&gt;8;="" bsum+="p" &amp;="" 0x0000ff;="" }="" for="" (x="0;x&lt;w;x++){&lt;/p">

  r[yi]=dv[rsum];
  g[yi]=dv[gsum];
  b[yi]=dv[bsum];

  if(y==0){
    vmin[x]=min(x+radius+1,wm);
    vmax[x]=max(x-radius,0);
  }
  p1=pix[yw+vmin[x]];
  p2=pix[yw+vmax[x]];

  rsum+=((p1 & 0xff0000)-(p2 & 0xff0000))>>16;
  gsum+=((p1 & 0x00ff00)-(p2 & 0x00ff00))>>8;
  bsum+= (p1 ...
(more)