PImage to display video?
in
Contributed Library Questions
•
9 months ago
This is the code I modify to display depthImage, rgbImage, and the copy of rgbImage
- import SimpleOpenNI.*;
- SimpleOpenNI kinect;
- color trackColor;
- // Frame
- PImage currentFrame;
- PImage rgbImage;
- void setup()
- {
- size(640*3, 480);
- kinect = new SimpleOpenNI(this);
- kinect.enableDepth();
- kinect.enableRGB();
- trackColor = color (255,0,0);
- smooth ();
- currentFrame = createImage (640,480, RGB);
- }
- void draw()
- {
- kinect.update();
- PImage depthImage = kinect.depthImage();
- PImage rgbImage = kinect.rgbImage();
- image(depthImage, 0, 0);
- image(rgbImage, 640, 0);
- currentFrame.copy(kinect.rgbImage(),640,0,640,480,1280,0,640,480);
- currentFrame.updatePixels();
- loadPixels();
- currentFrame.loadPixels();
- image(currentFrame,1280,0);
- }
- void mousePressed(){
- color c = get(mouseX, mouseY);
- println("r: " + red(c) + " g: " + green(c) + " b: " + blue(c));
- // Save color where the mouse is clicked in trackColor variable
- int loc = mouseX + mouseY*width;
- println(loc);
- }
the code works for 1st and 2nd frame (which is DepthImage and RGBImage),
But I wonder why it display black at the 3rd Frame? Because I expect it display the copy of the 2nd frane (which is RGBImage).
Is there any wrong in my code?
I am using PImage to display video bcause I would like to use some of PImage methods (like pixels) which inspired from this simple motion detection code and single color tracking code:
The core of my modification is, I would like to track color but not using webcam, but using kinect cam.
Any reply or question for clarity, do not hesitate to ask.
1