lyricsride
Ex Member
always runs out of memory, bad code?
Mar 18th , 2008, 12:55am
Hi everyone. I've been working toward a video installation. Currently I'm stumped over an error that happens every time it runs [eventually]. you can run this but you need the blob detection library and you need your own .mov . Right now i can't get you the exact error message, but i will update this post with it tomorrow. Basically though, there's some sort of memory problem i believe. I've read through numerous documentation throughout this site. I'm still not clear though - hence i'm asking here. Thanks for your time, really. I'm going to update with error details tomorrow. Note that, the bigger video files/resolutions cause failure sooner than smaller counter-parts. JMMK // ================================================== // import/declare // ================================================== import processing.video.*; import blobDetection.*; BlobDetection theBlobDetection; Capture cam; Movie myMovie; PImage img; boolean newFrame = false; int oldBlobNumber = 99; // the number of blobs on the last scan, before current scan int elapsedTime = 0; // time since calendar was flipped float myMovieSpeed = 1; // playback speed, 1 is normal float pointer = 0; // Where the tracking is aimed at, 0 if aimed at nowhere // ================================================== // setup() // ================================================== void setup(){ size(640, 360); cam = new Capture(this, 640, 360, "IIDC FireWire Video",15); // Capture //video frameRate(15); myMovie = new Movie(this, "1upLow.mov"); myMovie.speed(myMovieSpeed); myMovie.loop(); // BlobDetection img = new PImage(80,60); // img which will be sent to detection (a smaller copy of the cam frame); theBlobDetection = new BlobDetection(img.width, img.height); theBlobDetection.setPosDiscrimination(true); theBlobDetection.setThreshold(0.2f); // will detect bright areas whose luminosity > 0.2f; } // ================================================== // captureEvent() // ================================================== void captureEvent(Capture cam){ cam.read(); newFrame = true; } // ================================================== // draw() // ================================================== void draw(){ //video playback myMovie.read(); image(myMovie, 0, 0,width,height); //blobs if(newFrame){ newFrame=false; //image(cam,0,0,width,height); // uncomment this line to see what the camera sees img.copy(cam, 0, 0, cam.width, cam.height, 0, 0, img.width, img.height); theBlobDetection.computeBlobs(img.pixels); drawBlobs(); } //tracking if(elapsedTime>60 && theBlobDetection.getBlobNb() < 20 && theBlobDetection.getBlobNb() != oldBlobNumber){ oldBlobNumber = theBlobDetection.getBlobNb(); // we're about to make a new scan so move the current blob to the last blob slot elapsedTime = 0; // we're about to make a new scan so reset the elapsed time switch(theBlobDetection.getBlobNb()){ case 6: // case # where number is the number of blobs you want to track myMovieSpeed = 8; // speed of playback myMovie.speed(myMovieSpeed); pointer = 5; // frame target of this blob case break; case 3: myMovieSpeed = 8; myMovie.speed(myMovieSpeed); pointer = 50; break; case 12: myMovieSpeed = 8; myMovie.speed(myMovieSpeed); pointer = 30; break; default: // if none of the cases are found, then it's a bad blob entry we don't want it break; } } if(pointer > myMovie.time()-2 && pointer < myMovie.time()+2){ // once the tracking target is found, this if statement will return the video to normal speed myMovieSpeed = 1; myMovie.speed(myMovieSpeed); pointer = 0; } myMovie.speed(myMovieSpeed); elapsedTime++; println("Blob#: "+theBlobDetection.getBlobNb() + " || oldBlob#: "+oldBlobNumber + " || elapsedTime: "+elapsedTime +" ||||| pointerVtime " + pointer + "/" + myMovie.time()); //theBlobDetection.getBlobNb() is the number of blobs, this is for degbugging } // ================================================== // drawBlobsAndEdges() // ================================================== void drawBlobs(){ // this is the code that magically detects blobs noFill(); Blob b; for (int n=0 ; n<theBlobDetection.getBlobNb() ; n++){ b=theBlobDetection.getBlob(n); if(b!=null){ strokeWeight(1);stroke(255,0,0); // the visual appearance of the blobs rect(b.xMin*width,b.yMin*height,b.w*width,b.h*height); } } }