// code goes here
import gab.opencv.*;
import KinectPV2.KJoint;
import KinectPV2.*;
KinectPV2 kinect;
OpenCV opencv;
void setup() {
//size(512, 424, P3D);
fullScreen();
opencv=new OpenCV(this,1920,1080);
// Writing to the depth buffer is disabled to avoid rendering
// artifacts due to the fact that the particles are semi-transparent
// but not z-sorted.
hint(DISABLE_DEPTH_MASK);
kinect = new KinectPV2(this);
kinect.enableDepthImg(true);
kinect.enablePointCloud(true);
kinect.enableSkeletonColorMap(true);
kinect.enableColorImg(true);
kinect.enableBodyTrackImg(true);
kinect.init();
}
void draw () {
background(#0d0d0d);
boolean contourBodyIndex=false;
int threshold=100;
double polygonFactor=1.00;
opencv.loadImage(kinect.getColorImage());
opencv.gray();
opencv.threshold(threshold);
//opencv.updateBackground();
opencv.dilate();
opencv.erode();
ArrayList<Contour> contours = opencv.findContours(false, false); // zhao yi dui lun kuo
if (contours.size() > 0) {
for (Contour contour : contours) {
contour.setPolygonApproximationFactor(polygonFactor); // can shu
if (contour.numPoints() > 50) {
stroke(0, 200, 200); // miao bian
strokeWeight(1);
noFill();
beginShape();
for (PVector point : contour.getPolygonApproximation ().getPoints()) {
vertex(point.x, point.y); // the third pic
}
endShape();
}
}
}
}
I have two questions:
(1) Actually, I want to just get the body outline contour. And this is right now picture.
(2) I have tried to change the "opencv.loadImage(kinect.getColorImage()); " getColorImage() to get BodyTrackImage(), but the picture size is so weird.
Thanks a lot!