Hi people! I'm programming a simple game using color tracking, but I'm having some dificulties.
Let me explain how the game works:
I made some images in jpg. one with a lemon, other with banana, and one other with strawberry, all of then colorless.
Each image have something like "show a red object to paint the fruit" (in the case of the strawberry) or "show a yellow object to paint the fruit" (in the case of the banana).
What I need to do?
When the banana image is in the screen the program need to track for yellow color. If we put a green object he will not recognize, but if we put a yellow object after some seconds the program will change the image with the respcetiva image but colored (in the case of the banana, a yellow banana, etc)
After he recognize all the images, I want it to display the last image that will be something like "congratulation! you painted all the fruits"...
All the images is a simple ".jpg" image with the image of the fruit and the instruction of what you need to make.
I already have the code that tracks the color and I'm using the JMyron library, because I tried to programming without the library and I had a lot of problems with the color tracking trying to find the color everywhere.
import JMyron.*;
PImage fruta1;
PImage fruta2;
PImage fruta3;
PImage fruta4;
JMyron m;//a camera object
PImage fragment;
int rand;
void setup(){
size(640,480);
fruta1 = loadImage("banana1.jpg");
fruta2 = loadImage("lemon1.jpg");
fruta3 = loadImage("straberry1.jpg");
m = new JMyron();//make a new instance of the object
m.start(width,height);//start a capture at 640x480
m.trackColor(255,0,0,200);//R, G, B, and range of similarity
m.minDensity(50); //minimum pixels in the glob required to result in a box
println("Myron " + m.version());
noFill();
}
void draw(){
m.update();//update the camera view
//draw the camera to the screen
int[][] b = m.globBoxes();//get the center points
//draw the boxes
stroke(255,255,255);
void drawCamera(){
int[] img = m.image(); //get the normal image of the camera
loadPixels();
for(int i=0;i<width*height;i++){ //loop through all the pixels
pixels[i] = img[i]; //draw each pixel to the screen
}
updatePixels();
}
void mousePressed(){
m.settings();//click the window to get the settings
}
public void stop(){
m.stop();//stop the object
super.stop();
}
What exactly I need to do:
if the display image is the banana1.jpg, it need to track the yellow color, when we show something with yellow color to the camera, after some second he will change the image to the image with the colored banana. After some second, the program pass to the next image that is the lemon image, we need to show to the camera something with the green color, after some seconds the program change the image to the colored lemon...
When we have "painted" all the fruits, the program will show the image with the congratulation mensage.