the limitation done by this
for (int x = 0; x < video.width && x < 100; x ++ ) {
for (int y = 240; y < video.height; y ++ )
note affect
if (blue(video.pixels[loc])
since loc come from this
int loc = x + y*video.width
the limitation done by this
for (int x = 0; x < video.width && x < 100; x ++ ) {
for (int y = 240; y < video.height; y ++ )
note affect
if (blue(video.pixels[loc])
since loc come from this
int loc = x + y*video.width
What don’t you like? Your code says you want the circle to be drawn over the pixel sampled and that’s what it does. The circle also moves when the mouse is moved. Is that what you don’t want?
Perhaps you only want to sample the rectangle in the lower left hand corner, where x < 100 and y > 240? Is that correct? Right now it’s sampling any pixel in the image.
the tracking, draw circle and the redraw of tracked color done within this range
for (int x = 0; x < video.width && x < 100; x ++ ) {
for (int y = 240; y < video.height; y ++ )
not over those x and y value
If you only want to trap clicks in the area x < 100 and y > 240 then you need to define this area in mousePressed():
void mousePressed() {
// Save color where the mouse is clicked in trackColor variable
if (mouseX < 100 && mouseY > 240) {
int loc = mouseX + mouseY*video.width;
trackColor = video.pixels[loc];
locX = mouseX;
locY = mouseY;
}
}
locX, locY need to be global variables defined at the top of your code:
int locX = 0;
int locY = 0;
Add a counter and use it like this:
int counter = 0;
for (int x = 0; x < video.width; x ++ ) {
for (int y = 0; y < video.height; y ++ ) {
if (x<100 && y>240) {
// Draw a circle at the tracked pixel
fill(trackColor);
strokeWeight(4.0);
stroke(0);
ellipse( locX, locY, 20, 20);
if (blue(video.pixels[counter]) > 0) {
count++;
// processing takes 0-1 (float) color values from shader to 0-255 (int) values for color
// to decode, we need to divide the color by 255 to get the original value
// avg.add(red(video.pixels[loc]) / 255.0, green(video.pixels[loc]) / 255.0);
}
counter++;
...
}
}
This should allow you to trap clicks only in the designated area and report the color.
It’s getting late here and I’m going to have to sign off. Hopefully this will help you finish your project.
thank you so much brother i really appreciate it, i will inform you for any progress