Tracking mit RGB

This commit is contained in:
Julian Graf 2022-06-09 14:34:49 +02:00
parent ee084dd3b9
commit 781d94004a

View File

@ -20,12 +20,13 @@ void ofApp::update(){
rgb_immage.setFromPixels(webcam.getPixels());
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;
if (contour.size() != 0) {
for (i = 1; i < contour.size(); i++) {
@ -75,7 +76,7 @@ void ofApp::keyPressed(int key){
else if (key == 57356) {
mouse_event(MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0);
}
else if (key == 57357) {
else if (key == ' ') {
select_colour = select_colour ^ 0x0001;
}
}
@ -104,7 +105,7 @@ void ofApp::mouseDragged(int x, int y, int button){
//--------------------------------------------------------------
void ofApp::mousePressed(int x, int y, int button) {
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("%f, %f, %f, %f \n", y_offset, y_scale, x_offset, x_scale);
color_picked = 1;