I would like use frame differencing to detect if an object has been added in my scene and then analyze the object by focusing specifically on its position.
For example, drawing a rectangle after performing framing differencing.
I've been looking into the find_blobs function with the "in_memory_advance_frame_difference.py" example but can't seem to figure it out. I figured that the background after applying the difference will generally be the same colour so I found a general threshold for that colour then applied it to the find_blobs function with Invert = true. But, it just outlines the entire frame and not a change in the frame.
Here's what I added to the code example:
Code: Select all
diff = hist.get_percentile(0.99).l_value() - hist.get_percentile(0.90).l_value() triggered = diff > TRIGGER_THRESHOLD black = [(0, 20, 0, 20, 0, 30)] for blob in img.find_blobs(black, invert = True, pixels_threshold=20, area_threshold=200, merge=True): img.draw_rectangle(blob.rect()) print(clock.fps(), triggered)
Additionally, frame differencing has switched the Frame Buffer to show the difference output. Is there a way to revert the Buffer back to the image with the bounded rectangle?