made project vaguely in the shape of a python project

This commit is contained in:
didier amyot committed 2024-01-21 09:04:43 -05:00
1 parent 292c7762cd
commit e26489bf9c
4 files changed
+1 -117

No files matched your search

+34
View File
@@ -0,0 +1,34 @@
import contextlib
import time
import cv2
def create_video_writer(video_cap, output_filename):
# grab the width, height, and fps of the frames in the video stream.
frame_width = int(video_cap.get(cv2.CAP_PROP_FRAME_WIDTH))
frame_height = int(video_cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
fps = int(video_cap.get(cv2.CAP_PROP_FPS))
# initialize the FourCC and a video writer object
fourcc = cv2.VideoWriter_fourcc(*'MP4V')
writer = cv2.VideoWriter(output_filename, fourcc, fps,
(frame_width, frame_height))
return writer
def iter_frames(video_cap):
while 1:
ret, frame = video_cap.read()
if not ret:
return
yield frame
@contextlib.contextmanager
def time_tracker():
start = time.monotonic()
yield
end = time.monotonic()
print(f"Time to process 1 frame: {(end-start) * 1000:.0f} milliseconds")
+1 -1
View File
@@ -2,7 +2,7 @@ from pathlib import Path
from ultralytics import YOLO
import cv2
from helper import create_video_writer, iter_frames, time_tracker
from dodgeballtracker.helper import create_video_writer, iter_frames, time_tracker
from deep_sort_realtime.deepsort_tracker import DeepSort
import matplotlib
import numpy as np