pageauc / speed-camera

A Unix, Windows, Raspberry Pi Object Speed Camera using python, opencv, video streaming, motion tracking. Includes a Standalone Web Server Interface, Image Search using opencv template match and a whiptail Admin Menu Interface Includes picam and webcam Plugins for motion track security camera configuration including rclone sync script. watch-app allows remotely controller camera configuration from a remote storage service name. Uses sqlite3 and gnuplot for reporting. Recently added openalpr license plate reader support.
Apache License 2.0
960 stars 169 forks source link

`MO_MIN_AREA_PX` is not the area of the rectangle #168

Open SamDecrock opened 5 months ago

SamDecrock commented 5 months ago

Just a note, and maybe this should be added to the documentation or even to the debug statements:

I was using the sqpx in the following line to base the minimum MO_MIN_AREA_PX on (89250 in this example):

INFO     speed_camera  Add - 3/7 xy(195,183) 7.05 kph D=6/250 C=23 375x238=89250 sqpx L2R

However, doing some debugging revealed that the MO_MIN_AREA_PX is compared to cv2.contourArea(c) wheares the sqpx in the debug statement is based on the response from cv2.boundingRect(c).

cv2.contourArea measures the actual area within the contour, while cv2.boundingRect provides the dimensions of the smallest rectangle that can enclose the contour. Thus cv2.contourArea can be a lot smaller as it uses the real contours, not a rectangle.

So I guess it would be better to also debug the contourArea so users have something to base their MO_MIN_AREA_PX on?