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

Add the ability to show the date/time on the image #172

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@
IM_SHOW_CROP_AREA_ON = False # True= Display motion detection rectangle area on saved images
IM_BIGGER = 3.0 # Default= 3.0 min=0.1 Resize saved speed image by specified multiplier value
IM_SHOW_TEXT_ON = True # True= Show Text on speed images False= No Text on images
IM_TEXT_FORMAT = "filename" # filename= Show the filename (current behavior). date= Show the date on the image
IM_TEXT_DATE_FORMAT = "%c" # the date format to apply if IM_TEXT_FORMAT = "date" (https://strftime.org/)
IM_SHOW_TEXT_BOTTOM_ON = True # True= Show image text at bottom otherwise at top
IM_FONT_SIZE_PX = 12 # Default= 12 Font text height in px for text on images
IM_FONT_SCALE = 0.5 # Default= 0.5 Font scale factor that is multiplied by the font-specific base size.
Expand Down
11 changes: 11 additions & 0 deletions speed-cam.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@
"IM_SHOW_CROP_AREA_ON": True,
"IM_SHOW_SPEED_FILENAME_ON": False,
"IM_SHOW_TEXT_ON": True,
"IM_TEXT_DATE_FORMAT": "%c",
"IM_TEXT_FORMAT": "filename",
"IM_SHOW_TEXT_BOTTOM_ON": True,
"IM_FONT_SIZE_PX": 12,
"IM_FONT_THICKNESS": 2,
Expand Down Expand Up @@ -1561,10 +1563,19 @@ def speed_camera():
speed_units,
filename,
)

if IM_TEXT_FORMAT == "date":
image_text = "SPEED %.1f %s - %s" % (
ave_speed,
speed_units,
log_time.strftime(IM_TEXT_DATE_FORMAT),
)

text_x = int(
(image_width / 2)
- (len(image_text) * IM_FONT_SIZE_PX / 3)
)

if text_x < 2:
text_x = 2
cv2.putText(
Expand Down