HELP! Webcam color detection
in
Programming Questions
•
2 years ago
Hello,
I'm busy to make a simple version of Angry Birds named Angry Cats wich will work with a webcam.
I need to have the difference between 2 frames and used the following code.
The following code is about the difference between the colors but it won't work.
I hope that you guys can help me out and get it work.
loadPixels();
cam.loadPixels();
photo.loadPixels();
diff.loadPixels();
for(int i =0; i<cam.pixels.length; i++){
diffR = abs(red(cam.pixels[i]) - red(photo.pixels[i]));
diffG = abs(green(cam.pixels[i]) - green(photo.pixels[i]));
diffB = abs(blue(cam.pixels[i]) - blue(photo.pixels[i]));
diff.pixels[i] = color(diffR, diffG, diffB);
}
cam.updatePixels();
photo.updatePixels();
diff.updatePixels();
image(cam,0,0);
image(photo,0,0);
image(diff,200,300);
1