Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin webcam720 cannot calibrate #95

Closed
jameshfischer opened this issue Jul 17, 2021 · 8 comments
Closed

Plugin webcam720 cannot calibrate #95

jameshfischer opened this issue Jul 17, 2021 · 8 comments

Comments

@jameshfischer
Copy link

using default low-rez 240p plugin, all is well, but changing to webcam720, and appropriately changing parameters within that file results in calibration mode that never see any motion at all.

Motion is certainly detected, but it does not result in a trigger.

What would be some "good guess" settings for detection box size with the webcam720 plugin?

@pageauc
Copy link
Owner

pageauc commented Jul 17, 2021 via email

@jameshfischer
Copy link
Author

I do not think that a Pi-3B can handle 720p, and the graphics processing required even with quad-core processors.
The pi crashes and burns, as shown below:

First, the initial debug messages when in calibration mode

image

Then, the capture and resulting crash
image

@pageauc
Copy link
Owner

pageauc commented Jul 18, 2021 via email

@jameshfischer
Copy link
Author

I went back to the 240p configuration, as low-quality photos are not a deal-breaker. (The goal here is to document speeds of vehicles passing grandmother's house (102 yrs) as some cars roar up the street at 50mph+ in a 25mph town, and a speed bump is needed to protect the little old ladies who live on the street. )

But I am getting inconsistent results, and multiple speed estimates for the same car... some wildly variant.

The variations in speed readings are concerning, but when I drove my own car past the camera, it seemed within 1mph of my speedometer.

For example, 38mph, 30mph, and 30mph for the same car within less than a second:
speed-20210718-1110491
speed-20210718-1110494 (1)
speed-20210718-1110494

and 19mph, then 143mph:
speed-20210718-1727364
speed-20210718-1727371

25mph, then 17mph
speed-20210718-1836370
speed-20210718-1836364

Below is the startup, config, and a typical capture
pi@speedcam:~/speed-camera $ ./speed-cam.py

speed-cam.py 11.09 written by Claude Pageau
Motion Track Largest Moving Object and Calculate Speed per Calibration.

Loading Wait ...
2021-07-18 19:22:24 INFO pluginEnabled - loading pluginName /home/pi/speed-camera/plugins/webcam240.py
2021-07-18 19:22:24 INFO Copy /home/pi/speed-camera/plugins/webcam240.py to /home/pi/speed-camera/plugins/current.py
2021-07-18 19:22:24 INFO Import Plugin /home/pi/speed-camera/plugins/webcam240.py
2021-07-18 19:22:28 INFO Initializing USB Web Camera Try .. 1

Note: To Send Full Output to File Use command
python -u ./speed-cam.py | tee -a log.txt
Set log_data_to_file=True to Send speed_Data to CSV File speed-cam.log

Debug Messages .. verbose=True display_fps=False calibrate=False
show_out_range=True
Plugins ......... pluginEnable=True pluginName=webcam240
Calibration ..... cal_obj_px_L2R=105 px cal_obj_mm_L2R=4503 mm speed_conv_L2R=0.09395
cal_obj_px_R2L=105 px cal_obj_mm_R2L=4503 mm speed_conv_R2L=0.09395
(Change Settings in /home/pi/speed-camera/plugins/webcam240.py)
Logging ......... Log_data_to_CSV=True log_filename=speed-cam.csv (CSV format)
loggingToFile=False logFilePath=speed-cam.log
SQLITE3 DB_PATH=/home/pi/speed-camera/data/speed_cam.db DB_TABLE=speed
Speed Trigger ... Log only if max_speed_over > 10 mph
and track_counter >= 8 consecutive motion events
Exclude Events .. If x_diff_min < 1 or x_diff_max > 30 px
If y_upper < 100 or y_lower > 150 px
or x_left < 90 or x_right > 300 px
If max_speed_over < 10 mph
If event_timeout > 0.50 seconds Start New Track
track_timeout=0.20 sec wait after Track Ends (avoid retrack of same object)
Speed Photo ..... Size=960x720 px image_bigger=3.0 rotation=0 VFlip=True HFlip=True
image_path=media/images image_Prefix=speed-
image_font_size=12 px high image_text_bottom=True
image_jpeg_quality=98 image_jpeg_optimize=True
Motion Settings . Size=320x240 px px_to_kph_L2R=0.151200 px_to_kph_R2L=0.151200 speed_units=mph
CAM_LOCATION= None
OpenCV Settings . MIN_AREA=100 sq-px BLUR_SIZE=10 THRESHOLD_SENSITIVITY=20 CIRCLE_SIZE=5 px
WINDOW_BIGGER=1 gui_window_on=False (Display OpenCV Status Windows on GUI Desktop)
CAMERA_FRAMERATE=30 fps video stream speed
Sub-Directories . imageSubDirMaxHours=0 (0=off) imageSubDirMaxFiles=2000 (0=off)
imageRecentDir=media/recent imageRecentMax=100 (0=off)
Disk Space ..... Disabled - spaceTimerHrs=0 Manage Target Free Disk Space. Delete Oldest jpg Files
spaceTimerHrs=0 (0=Off) Target spaceFreeMB=500 (min=100 MB)


2021-07-18 19:22:32 INFO isSQLite3 Success: File is sqlite3 Format /home/pi/speed-camera/data/speed_cam.db
2021-07-18 19:22:32 INFO db_check Success: sqlite3 Connected to DB /home/pi/speed-camera/data/speed_cam.db
2021-07-18 19:22:32 INFO speed_camera sqlite3 DB is Open /home/pi/speed-camera/data/speed_cam.db
2021-07-18 19:22:32 INFO speed_notify Plugin Enabled per pluginName=webcam240
2021-07-18 19:22:32 INFO speed_notify Logging to Console per Variable verbose=True
2021-07-18 19:22:32 INFO speed_notify Press ctrl-c in this terminal session to Quit
2021-07-18 19:22:32 INFO speed_notify Begin Motion Tracking .....
2021-07-18 19:23:05 INFO speed_camera Reset- event_timer 32.44>0.50 sec Exceeded

2021-07-18 19:23:05 INFO speed_camera New - 0/8 xy(146,41) Start New Track
2021-07-18 19:23:05 INFO speed_camera Add - 1/8 xy(134,41) 35.61 mph D=12/30 C=2 27x9=165 sqpx R2L
2021-07-18 19:23:05 INFO speed_camera Add - 2/8 xy(122,38) 33.58 mph D=12/30 C=2 28x12=190 sqpx R2L
2021-07-18 19:23:05 INFO speed_camera Add - 3/8 xy(110,36) 33.90 mph D=12/30 C=3 29x14=246 sqpx R2L
2021-07-18 19:23:05 INFO speed_camera Add - 4/8 xy(98,25) 34.28 mph D=12/30 C=2 85x25=1243 sqpx R2L
2021-07-18 19:23:05 INFO speed_camera Add - 5/8 xy(87,26) 33.79 mph D=11/30 C=2 83x24=1216 sqpx R2L
2021-07-18 19:23:05 INFO speed_camera Add - 6/8 xy(83,23) 29.91 mph D=4/30 C=3 74x27=1166 sqpx R2L
2021-07-18 19:23:05 INFO speed_camera Add - 7/8 xy(69,23) 31.55 mph D=14/30 C=2 75x27=1113 sqpx R2L
2021-07-18 19:23:05 INFO speed_camera Add - 8/8 xy(57,22) 31.57 mph D=12/30 C=2 75x28=1204 sqpx R2L
2021-07-18 19:23:05 INFO speed_camera Saved media/images/speed-20210717-1139/speed-20210718-1923056.jpg
2021-07-18 19:23:05 INFO isSQLite3 Success: File is sqlite3 Format /home/pi/speed-camera/data/speed_cam.db
2021-07-18 19:23:05 INFO db_check Success: sqlite3 Connected to DB /home/pi/speed-camera/data/speed_cam.db
2021-07-18 19:23:05 INFO speed_camera SQL - Inserted Data Row into /home/pi/speed-camera/data/speed_cam.db
2021-07-18 19:23:05 INFO log_to_csv CSV - Appended Data into /home/pi/speed-camera/speed-cam.csv
2021-07-18 19:23:05 INFO saveRecent symlink /home/pi/speed-camera/media/recent/speed-20210718-1923056.jpg
2021-07-18 19:23:05 INFO speed_camera End - R2L Ave Speed 31.6 mph Tracked 89 px in 0.267 sec Calib 105px 4503mm

2021-07-18 19:23:05 INFO speed_camera track_timeout 0.20 sec Sleep to Avoid Tracking Same Object Multiple Times.

@pageauc
Copy link
Owner

pageauc commented Jul 19, 2021 via email

@jameshfischer
Copy link
Author

So, increase the "track count" parameter, and tweak that setting to avoid double-counting the same car?

@bushibot
Copy link

'. Eg 75 to 100 ft from camera. Sometimes the problem is unrealistic expectations. Even radar systems can have issues. Hope this explanation helps.'

This has been challenge for me, my camera sits about 35ft from the middle of the adjacent road. Does angle affect the reading? I'm wondering if I put it up on the the 3rd floor window angled it down at the street to increase distance if it would help. Similar projects seem to require a flat level view to the street though.

@pageauc
Copy link
Owner

pageauc commented Jul 27, 2021 via email

@pageauc pageauc closed this as completed Oct 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants