[FFmpeg-user] find_rect, suggestion for improvement

Michael Koch astroelectronic at t-online.de
Mon Oct 19 11:00:13 EEST 2020


I'd like to propose an improvement for the find_rect filter.
In my application the object is quite small (10x10 pixels) and slowly 
moving over half of the image size.
I did already narrow down the search area with the xmin, xmax, ymin, 
ymax options, and I did optimize the threshold value. But sometimes the 
algorithm is still finding false positives, because other parts of the 
image look similar to the object. I know that my object can't move 
faster than about 10 pixels from one frame to the next.

My suggestion:
-- Add a new option "radius" which is 0 by default.
-- If radius = 0, then the behavior is the same as before.
-- If radius > 0, then use the xmin, xmax, ymin, ymax values only for 
the first frame.
-- For all subsequent frames, the search area is defined by the x,y 
result from the previous frame, plus and minus the radius value.
-- If the algorithm doesn't find the object, it shall stay in this 
"object lost" state for all subsequent frames. In this case it would be 
nice to see a warning in the log file.

That means for all frames (except the first one) the search area can be 
made quite small, so that the algorithm becomes much faster and the 
probability of finding false positives is reduced.


More information about the ffmpeg-user mailing list