diff --git a/config.py b/config.py index 1cebc0c..74a52b9 100644 --- a/config.py +++ b/config.py @@ -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. diff --git a/speed-cam.py b/speed-cam.py old mode 100644 new mode 100755 index 3599665..6bb19af --- a/speed-cam.py +++ b/speed-cam.py @@ -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, @@ -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(