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(); } // ================================================== // 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<b.getEdgeNb();m++)" {="" ea="b.getEdgeVertexA(m);" eb="b.getEdgeVertexB(m);" if="" (ea="" !="null" &&="" eb="" !="null)" line(="" ea.x<em="">width, eA.yheight, eB.xwidth, eB.yheight ); } } } // ================================================== // 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<=radius;i++){" p="pix[yi+min(wm,max(i,0))];" rsum+="(p" &="" 0xff0000)>>16;="" gsum+="(p" &="" 0x00ff00)>>8;="" bsum+="p" &="" 0x0000ff;="" }="" for="" (x="0;x<w;x++){</p"> (more) |