I’m new to OF and OpenCV. I was reviewing some example code:(10. Color Tracking with OpenCV).
https://sites.google.com/site/ofauckland/examples/10-testing
The program uses seven images (3 across) within the main window. It splits RGB into HSV.
You then can use the mouse to pick a Hue value in one of the images.
It used the FindHue variable to find the correct Hue value and then uses that to find the contours.
It then can draw a filled circle on the very first image for a detected object.
I can’t figure out why the circles wind up on the first image.
My other question is: why exactly does the mouse pointer use modulo for mx and my?
void testApp::mousePressed(int x, int y, int button) {
//calculate local mouse x,y in image
int mx = x % w;
int my = y % h;
//get hue value on mouse position
findHue = hue.getPixels()[my*w+mx];
}
For example:
x = 432, y = 376
w = 320, h = 240
mx = 112, my = 136
FindHue = -842150451
I just can’t seem to get my head around it.
I understand the modulus operation in c++.
I also understand the reason for [my*w+mx]
Is it used to get back to the first image? The images are 240x320 each.
If I click on image #5 does the use of modulus reduce the pointer to image #1?
Thanks in advance.