浏览代码

print the frame time on the image

Blake Blackshear 5 年之前
父节点
当前提交
e818744d81
共有 3 个文件被更改,包括 11 次插入0 次删除
  1. 2 0
      README.md
  2. 4 0
      frigate/objects.py
  3. 5 0
      frigate/video.py

+ 2 - 0
README.md

@@ -32,6 +32,7 @@ docker run --rm \
 --privileged \
 -v /dev/bus/usb:/dev/bus/usb \
 -v <path_to_config_dir>:/config:ro \
+-v /etc/localtime:/etc/localtime:ro \
 -p 5000:5000 \
 -e FRIGATE_RTSP_PASSWORD='password' \
 frigate:latest
@@ -46,6 +47,7 @@ Example docker-compose:
     image: frigate:latest
     volumes:
       - /dev/bus/usb:/dev/bus/usb
+      - /etc/localtime:/etc/localtime:ro
       - <path_to_config>:/config
     ports:
       - "5000:5000"

+ 4 - 0
frigate/objects.py

@@ -85,4 +85,8 @@ class BestPersonFrame(threading.Thread):
                 draw_box_with_label(best_frame, self.best_person['xmin'], self.best_person['ymin'], 
                     self.best_person['xmax'], self.best_person['ymax'], label)
                 
+                # print a timestamp
+                time_to_show = datetime.datetime.fromtimestamp(self.best_person['frame_time']).strftime("%m/%d/%Y %H:%M:%S")
+                cv2.putText(best_frame, time_to_show, (10, 10), cv2.FONT_HERSHEY_SIMPLEX, fontScale=1, color=(255, 255, 255), thickness=4)
+                
                 self.best_frame = cv2.cvtColor(best_frame, cv2.COLOR_RGB2BGR)

+ 5 - 0
frigate/video.py

@@ -315,6 +315,7 @@ class Camera:
         # lock and make a copy of the current frame
         with self.frame_lock:
             frame = self.current_frame.copy()
+            frame_time = self.frame_time.value
 
         # draw the bounding boxes on the screen
         for obj in detected_objects:
@@ -326,6 +327,10 @@ class Camera:
             cv2.rectangle(frame, (region['x_offset'], region['y_offset']), 
                 (region['x_offset']+region['size'], region['y_offset']+region['size']), 
                 color, 2)
+        
+        # print a timestamp
+        time_to_show = datetime.datetime.fromtimestamp(frame_time).strftime("%m/%d/%Y %H:%M:%S")
+        cv2.putText(frame, time_to_show, (10, 30), cv2.FONT_HERSHEY_SIMPLEX, fontScale=.8, color=(255, 255, 255), thickness=2)
 
         # convert to BGR
         frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)