Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import hypermedia.video.*;
- import SimpleOpenNI.*;
- SimpleOpenNI ni;
- OpenCV cv;
- void setup(){
- size(640,480);stroke(0,192,0);//basic setup
- ni = new SimpleOpenNI(this);
- if(SimpleOpenNI.deviceCount() == 0) ni.openFileRecording("/Users/hm/Documents/Processing/tests/OpenNIPoseRecorder/data/20Apr2013-16.07.oni");
- ni.enableDepth();
- cv = new OpenCV(this);
- cv.allocate(width,height);//tell OpenCV to allocate memory for the pixels we'll use from the depth sensor
- }
- void draw(){
- //update
- ni.update();
- cv.copy(ni.depthImage());//copy data from depth sensor to opencv
- cv.blur(BLUR,((int)map(mouseY,0,height,0,4)*2)+1);//optionally smooth/blur a bit: blur value should be odd (1, 3, 5, …), so that a pixel neighborhood used for smoothing operation is symmetrical relative to the pixel.
- cv.threshold(map(mouseX,0,width,0,255));//threshold
- Blob[] blobs = cv.blobs( 10, width*height/2, 100, true, OpenCV.MAX_VERTICES*4 );
- //draw
- image(cv.image(),0,0);//threshold result
- for( int i=0; i<blobs.length; i++ ) {//blobs
- beginShape();
- for( int j=0; j<blobs[i].points.length; j++ )
- vertex( blobs[i].points[j].x, blobs[i].points[j].y );
- endShape(CLOSE);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement