Image tracking similar


#1

Hi, I would like to see in this computer vision one image with red pixels and the other normal
but here the both are with red pixels.

void draw() {
  image(ps3eye.getFrame(), 0, 0);
  tracking = ps3eye.getFrame();
  tracking.loadPixels();
  for (int i = 0; i < tracking.pixels.length; i++) {
    color c = tracking.pixels[i];           
    if ((abs(red(c)-red(myPix))<range) && 
      (abs(green(c)-green(myPix))<range) && 
      (abs(blue(c)-blue(myPix))<range)) tracking.pixels[i] = #EA0707;
  }
  tracking.updatePixels();
  image(tracking, 320, 0); 
}

#2

I dont know what your getFrame() method is suppose to do but I’m willing to bet your problem is that your setting tracking’s pixels to the same as ps3eye’s pixels which is a problem when you trying to do what your doing because “All Processing programs update the screen at the end of draw(), never earlier.” taken straight from https://processing.org/reference/draw_.html so since both your image variables point to the same memory when it come times for processing to update the screen it looks at the memory where their arrays are pointing and both are now red, so both your images will be red. If you don’t want them both to be red use the copy() function for PImage(outside of draw or it will lag the program).


#3

I had this and now it’s works

tracking = ps3eye.getFrame();
  image(video, 0, 0);
  copy(tracking, 0, 0, 320, 240, 0, 0, 320, 240);  
  tracking.loadPixels();

Thanks a lot !