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
969 stars 171 forks source link

sudden change in sqpx while taking car speed #92

Closed peterb99 closed 3 years ago

peterb99 commented 3 years ago

Im puzzled by a phenomenon I regularly see, significant change in the sqpx size while tracking a car, seems to happen more frequent by large objects, speed_camera Reset- event_timer 6.63>0.40 sec Exceeded 2021-06-25 17:11:41 INFO speed_camera New - 0/6 xy(29,25) Start New Track 2021-06-25 17:11:41 INFO speed_camera Add - 1/6 xy(38,24) 24.33 mph D=9/50 C=3 75x36=1409 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 2/6 xy(47,24) 25.97 mph D=9/50 C=3 74x36=1386 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 3/6 xy(55,24) 25.75 mph D=8/50 C=2 75x36=1371 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 4/6 xy(64,26) 25.43 mph D=9/50 C=2 74x34=1307 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 5/6 xy(100,37) 42.48 mph D=36/50 C=3 46x23=688 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 6/6 xy(81,26) 44.64 mph D=19/50 C=2 73x34=1337 sqpx R2L

It some times triggers negative x pixel change between the last two intervals.

image Can any settings be tweaked to circumvent this?

pageauc commented 3 years ago

Yes that can happen due to a shift in largest contour. I try to filter some of those out in the code but it cannot eliminate the problem completely due to the way opencv discovers contours. My code does not do object recognition due to speed of RPI. This code was developed by myself just for fun and is not intended to be perfect in all situations. The code works best if the vehicles do are not too close to the camera where contours can easily move location on the moving object. Eg from front to back or middle due to lighting or other changes that change the location of the largest contour.

On Fri, Jun 25, 2021 at 12:23 PM peterb99 @.***> wrote:

Im puzzled by a phenomenon I regularly see, significant change in the sqpx size while tracking a car, seems to happen more frequent by large objects, speed_camera Reset- event_timer 6.63>0.40 sec Exceeded 2021-06-25 17:11:41 INFO speed_camera New - 0/6 xy(29,25) Start New Track 2021-06-25 17:11:41 INFO speed_camera Add - 1/6 xy(38,24) 24.33 mph D=9/50 C=3 75x36=1409 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 2/6 xy(47,24) 25.97 mph D=9/50 C=3 74x36=1386 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 3/6 xy(55,24) 25.75 mph D=8/50 C=2 75x36=1371 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 4/6 xy(64,26) 25.43 mph D=9/50 C=2 74x34=1307 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 5/6 xy(100,37) 42.48 mph D=36/50 C=3 46x23=688 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 6/6 xy(81,26) 44.64 mph D=19/50 C=2 73x34=1337 sqpx R2L

It some times triggers negative x pixel change between the last two intervals.

[image: image] https://user-images.githubusercontent.com/35472441/123455619-d39f8b00-d5d9-11eb-9ddc-6cba7bc65465.png Can any settings be tweaked to circumvent this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/92, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZGASYIFQJIT45JTMW3TUSUO7ANCNFSM47KFU6PA .

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

pageauc commented 3 years ago

Note in the data you can see the second last contour was half the size of the other contours eg 688 vs 1300+ sq pixels This may have been due to lighting change or vehicle bodywork. The C= is the number of contours found. It is possible to join overlapping contours into one larger contour. My Camera is farther away from the road and I can get C=1 for the track so better chance of accuracy although the contour can still shift of the moving object. Hope this explanation helps. Let me know if you have any ideas Claude ...

On Fri, Jun 25, 2021 at 12:40 PM Claude Pageau @.***> wrote:

Yes that can happen due to a shift in largest contour. I try to filter some of those out in the code but it cannot eliminate the problem completely due to the way opencv discovers contours. My code does not do object recognition due to speed of RPI. This code was developed by myself just for fun and is not intended to be perfect in all situations. The code works best if the vehicles do are not too close to the camera where contours can easily move location on the moving object. Eg from front to back or middle due to lighting or other changes that change the location of the largest contour.

On Fri, Jun 25, 2021 at 12:23 PM peterb99 @.***> wrote:

Im puzzled by a phenomenon I regularly see, significant change in the sqpx size while tracking a car, seems to happen more frequent by large objects, speed_camera Reset- event_timer 6.63>0.40 sec Exceeded 2021-06-25 17:11:41 INFO speed_camera New - 0/6 xy(29,25) Start New Track 2021-06-25 17:11:41 INFO speed_camera Add - 1/6 xy(38,24) 24.33 mph D=9/50 C=3 75x36=1409 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 2/6 xy(47,24) 25.97 mph D=9/50 C=3 74x36=1386 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 3/6 xy(55,24) 25.75 mph D=8/50 C=2 75x36=1371 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 4/6 xy(64,26) 25.43 mph D=9/50 C=2 74x34=1307 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 5/6 xy(100,37) 42.48 mph D=36/50 C=3 46x23=688 sqpx L2R 2021-06-25 17:11:41 INFO speed_camera Add - 6/6 xy(81,26) 44.64 mph D=19/50 C=2 73x34=1337 sqpx R2L

It some times triggers negative x pixel change between the last two intervals.

[image: image] https://user-images.githubusercontent.com/35472441/123455619-d39f8b00-d5d9-11eb-9ddc-6cba7bc65465.png Can any settings be tweaked to circumvent this?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pageauc/speed-camera/issues/92, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABNPKZGASYIFQJIT45JTMW3TUSUO7ANCNFSM47KFU6PA .

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc

-- YouTube Channel at https://www.youtube.com/user/pageaucp http://www.youtube.com/user/pageaucp GitHub Repository at https://github.com/pageauc