i did this to get the color of a point in the webcam capture. It works well, but when i use the imageadjuster lib. it does not.
You can define the color by clicking on the video.
I split the video in two parts. the left part is adjusted, the right is not.
The selected color will be shown as a black overlay.
I hope you can help me to fix the problem.
Code:
import processing.video.*;
import imageadjuster.*;
ImageAdjuster adjust = new ImageAdjuster(this);
Capture video;
float RED=400;
float GREEN=400;
float BLUE=400;
color a1;
float threshold=5;
void setup() {
size(320,240);
video = new Capture(this, width, height, 30);
}
void draw() {
if (video.available()) {
video.read();
image(video, 0, 0, width, height); // Draw the webcam video onto the screen
video.loadPixels();
//Problem starts here:
adjust.contrast(g, 0, 0, width/2, height, 3.0f);
for(int j=0; j<video.height; j++){
for(int i=0; i<video.width; i++){
int num = (j*video.width)+i;
if( (abs(red(video.pixels[num]) - RED) <=threshold) && (abs(green(video.pixels[num]) - GREEN) <=threshold) && (abs(blue(video.pixels[num]) - BLUE)<=threshold)){
stroke(0);
point(i,j);
}
}
}
}
}
void mousePressed() {
a1=get(mouseX, mouseY);
RED=red(a1);
GREEN=green(a1);
BLUE=blue(a1);
}
void keyPressed()
{
if (key == 'A' || key == 'a') {
threshold++;
}
else if ((key == 'y' || key == 'Y')&& threshold>0) {
threshold--;
}
println("threshold= "+threshold);
}