|
|
|
|
|
|
|
|
|
|
|
|
|
|
rgb_immage.setFromPixels(webcam.getPixels()); |
|
|
rgb_immage.setFromPixels(webcam.getPixels()); |
|
|
rgb_immage.blurGaussian(5); |
|
|
rgb_immage.blurGaussian(5); |
|
|
hsv_immage = rgb_immage; |
|
|
|
|
|
hsv_immage.convertRgbToHsv(); |
|
|
|
|
|
|
|
|
//hsv_immage = rgb_immage; |
|
|
|
|
|
//hsv_immage.convertRgbToHsv(); |
|
|
|
|
|
//hsv_immage.blur(); |
|
|
|
|
|
|
|
|
contour.setTargetColor(color); |
|
|
|
|
|
contour.setThreshold(30); |
|
|
|
|
|
contour.findContours(hsv_immage); |
|
|
|
|
|
|
|
|
contour.setTargetColor(color); /*, ofxCv::TRACK_COLOR_HSV*/ |
|
|
|
|
|
contour.setThreshold(20); |
|
|
|
|
|
contour.findContours(rgb_immage); |
|
|
selection = 0; |
|
|
selection = 0; |
|
|
if (contour.size() != 0) { |
|
|
if (contour.size() != 0) { |
|
|
for (i = 1; i < contour.size(); i++) { |
|
|
for (i = 1; i < contour.size(); i++) { |
|
|
|
|
|
|
|
|
else if (key == 57356) { |
|
|
else if (key == 57356) { |
|
|
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); |
|
|
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0); |
|
|
} |
|
|
} |
|
|
else if (key == 57357) { |
|
|
|
|
|
|
|
|
else if (key == ' ') { |
|
|
select_colour = select_colour ^ 0x0001; |
|
|
select_colour = select_colour ^ 0x0001; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
//-------------------------------------------------------------- |
|
|
//-------------------------------------------------------------- |
|
|
void ofApp::mousePressed(int x, int y, int button) { |
|
|
void ofApp::mousePressed(int x, int y, int button) { |
|
|
if (calibrated == 4 && select_colour == 0x0001) { |
|
|
if (calibrated == 4 && select_colour == 0x0001) { |
|
|
color = hsv_immage.getPixels().getColor(x, y); |
|
|
|
|
|
|
|
|
color = rgb_immage.getPixels().getColor(x, y); |
|
|
printf("%i, %i, %i\n", color.r, color.g, color.b); |
|
|
printf("%i, %i, %i\n", color.r, color.g, color.b); |
|
|
printf("%f, %f, %f, %f \n", y_offset, y_scale, x_offset, x_scale); |
|
|
printf("%f, %f, %f, %f \n", y_offset, y_scale, x_offset, x_scale); |
|
|
color_picked = 1; |
|
|
color_picked = 1; |