We are about to switch to a new forum software. Until then we have removed the registration on this forum.
//hey, I'm probably not doing this right //is it cause I'm using the context of PGraphics and PImage mixed up?? //IM GETTING 7 FPS W/ I7 7700K AND 1070 sli //CPU AND GPU ARE NOT BEING PUSHED ///NEED HELP!!!!
import java.util.ArrayList; import KinectPV2.KJoint; import KinectPV2.*;
KinectPV2 kinect;
import processing.video.*;
Movie coral; PGraphics feedback;
void setup() { fullScreen(P2D, 2); feedback = createGraphics(1920,1080,P2D); background(0); //blendMode(ADD);
//Video stuff coral = new Movie(this, "CoralReef.mp4"); coral.loop();
//Kinect stuff kinect = new KinectPV2(this); kinect.enableBodyTrackImg(true); kinect.enableSkeletonDepthMap(true); kinect.init(); }
void movieEvent(Movie m) { m.read(); }
PImage kinectSil;
void draw() {
kinectSil = kinect.getBodyTrackImage();
kinectSil.filter(INVERT); kinectSil.loadPixels(); for (int i = 0; i < kinectSil.pixels.length; i++) { if (kinectSil.pixels[i] == color(0)) { kinectSil.pixels[i] = color(0, 0); } else { kinectSil.pixels[i] = color(255,255); } } kinectSil.updatePixels();
feedback.beginDraw(); feedback.image(kinectSil,0,0,1920,1080); feedback.blend(coral, 0, 0, coral.width, coral.height, 0, 0, coral.width, coral.height, MULTIPLY); feedback.filter(THRESHOLD); feedback.endDraw(); tint(255,10); image(coral,0,0,width,height); blend(feedback,0,0,feedback.width,feedback.height, 0, 0, width, height, LIGHTEST); fill(45); rect(0,0,150,54); textSize(30); fill(255); text(frameRate, 20,40); }
Answers
Edit your post (gear icon in the top right corner of your post), select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code.
Minor suggestion: You are doing this
kinectSil.pixels[i] == color(0)
. Instead do this:Also, could you comment why you are calling threshold, tint and blend in every cycle of draw? I would guess these operations are expensive. It is a guess as I am not able to reproduce your sketch. You can try commenting those lines one by one or all together to see if that is your bottleneck. However, keep in mind that performing these operation plus using larger mage sizes will limited the fps. There are few strategies. For example, only process every second (or fifth) image. Or use a smaller image (maybe resize?).
Kf
Thank you for your help!