Recognize drawn shape on sceen

Hello guys,

I want to recognize a drawn shape with a camera that is watching at my screen.
I’m drawing a little rectangle on the screen and want to enlarge it if it isn’t detected on the camera frame.
The Backround is white and the rectangle black. So maybe its also workin if I’m looking for textures?

for that i begin with a rectangle thats with 1 pixel size. this should get bigger if i do not recognize it

img = cam.getPixels();    
  // Loop to control if the drawn pixel is recognized
  pix = img.getPixels();
  for (auto & pixel : pix.getPixelsIter()) {
    if (!(pixel.getColor() == ofColor::white)) {
      recog = true;
    else {

the objects have this type:

ofVideoGrabber cam;
ofImage img;
ofPixels pix;

the pixelSize is one at the begin. The result for the moment ist, that the rectangle is directly enormous large and bigger than my screen :frowning:
can you help me ?

EDIT: I just recognized while debugging that I somehow do not get into the loop. but it at least enlarge the the pixelSize sometimes depending on the framerate. Even if I set a breakpoint I won’t reach him but the pixelSize is enlarged. o0