ultralytics 8.0.237 cv2.CAP_PROP fix and in_counts and out_counts displays (#7380)
Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com> Co-authored-by: ayush chaurasia <ayush.chaurarsia@gmail.com> Co-authored-by: Muhammad Rizwan Munawar <chr043416@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: 曾逸夫(Zeng Yifu) <41098760+Zengyf-CVer@users.noreply.github.com>
This commit is contained in:
parent
71fe5e919d
commit
8c2b2f56b2
15 changed files with 108 additions and 90 deletions
|
|
@ -50,18 +50,19 @@ A heatmap generated with [Ultralytics YOLOv8](https://github.com/ultralytics/ult
|
|||
model = YOLO("yolov8n.pt")
|
||||
cap = cv2.VideoCapture("path/to/video/file.mp4")
|
||||
assert cap.isOpened(), "Error reading video file"
|
||||
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
|
||||
|
||||
# Video writer
|
||||
video_writer = cv2.VideoWriter("heatmap_output.avi",
|
||||
cv2.VideoWriter_fourcc(*'mp4v'),
|
||||
int(cap.get(5)),
|
||||
(int(cap.get(3)), int(cap.get(4))))
|
||||
fps,
|
||||
(w, h))
|
||||
|
||||
# Init heatmap
|
||||
heatmap_obj = heatmap.Heatmap()
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA ,
|
||||
imw=cap.get(4), # should same as cap height
|
||||
imh=cap.get(3), # should same as cap width
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA,
|
||||
imw=w,
|
||||
imh=h,
|
||||
view_img=True,
|
||||
shape="circle")
|
||||
|
||||
|
|
@ -90,20 +91,21 @@ A heatmap generated with [Ultralytics YOLOv8](https://github.com/ultralytics/ult
|
|||
model = YOLO("yolov8n.pt")
|
||||
cap = cv2.VideoCapture("path/to/video/file.mp4")
|
||||
assert cap.isOpened(), "Error reading video file"
|
||||
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
|
||||
|
||||
# Video writer
|
||||
video_writer = cv2.VideoWriter("heatmap_output.avi",
|
||||
cv2.VideoWriter_fourcc(*'mp4v'),
|
||||
int(cap.get(5)),
|
||||
(int(cap.get(3)), int(cap.get(4))))
|
||||
fps,
|
||||
(w, h))
|
||||
|
||||
line_points = [(256, 409), (694, 532)] # line for object counting
|
||||
|
||||
# Init heatmap
|
||||
heatmap_obj = heatmap.Heatmap()
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA ,
|
||||
imw=cap.get(4), # should same as cap height
|
||||
imh=cap.get(3), # should same as cap width
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA,
|
||||
imw=w,
|
||||
imh=h,
|
||||
view_img=True,
|
||||
shape="circle",
|
||||
count_reg_pts=line_points)
|
||||
|
|
@ -132,21 +134,22 @@ A heatmap generated with [Ultralytics YOLOv8](https://github.com/ultralytics/ult
|
|||
model = YOLO("yolov8n.pt")
|
||||
cap = cv2.VideoCapture("path/to/video/file.mp4")
|
||||
assert cap.isOpened(), "Error reading video file"
|
||||
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
|
||||
|
||||
# Video writer
|
||||
video_writer = cv2.VideoWriter("heatmap_output.avi",
|
||||
cv2.VideoWriter_fourcc(*'mp4v'),
|
||||
int(cap.get(5)),
|
||||
(int(cap.get(3)), int(cap.get(4))))
|
||||
fps,
|
||||
(w, h))
|
||||
|
||||
# Define region points
|
||||
region_points = [(20, 400), (1080, 404), (1080, 360), (20, 360)]
|
||||
|
||||
# Init heatmap
|
||||
heatmap_obj = heatmap.Heatmap()
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA ,
|
||||
imw=cap.get(4), # should same as cap height
|
||||
imh=cap.get(3), # should same as cap width
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA,
|
||||
imw=w,
|
||||
imh=h,
|
||||
view_img=True,
|
||||
shape="circle",
|
||||
count_reg_pts=region_points)
|
||||
|
|
@ -178,7 +181,7 @@ A heatmap generated with [Ultralytics YOLOv8](https://github.com/ultralytics/ult
|
|||
|
||||
# Heatmap Init
|
||||
heatmap_obj = heatmap.Heatmap()
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA ,
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA,
|
||||
imw=im0.shape[0], # should same as im0 width
|
||||
imh=im0.shape[1], # should same as im0 height
|
||||
view_img=True,
|
||||
|
|
@ -199,20 +202,21 @@ A heatmap generated with [Ultralytics YOLOv8](https://github.com/ultralytics/ult
|
|||
model = YOLO("yolov8n.pt")
|
||||
cap = cv2.VideoCapture("path/to/video/file.mp4")
|
||||
assert cap.isOpened(), "Error reading video file"
|
||||
w, h, fps = (int(cap.get(x)) for x in (cv2.CAP_PROP_FRAME_WIDTH, cv2.CAP_PROP_FRAME_HEIGHT, cv2.CAP_PROP_FPS))
|
||||
|
||||
# Video writer
|
||||
video_writer = cv2.VideoWriter("heatmap_output.avi",
|
||||
cv2.VideoWriter_fourcc(*'mp4v'),
|
||||
int(cap.get(5)),
|
||||
(int(cap.get(3)), int(cap.get(4))))
|
||||
fps,
|
||||
(w, h))
|
||||
|
||||
classes_for_heatmap = [0, 2] # classes for heatmap
|
||||
|
||||
# Init heatmap
|
||||
heatmap_obj = heatmap.Heatmap()
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA ,
|
||||
imw=cap.get(4), # should same as cap height
|
||||
imh=cap.get(3), # should same as cap width
|
||||
heatmap_obj.set_args(colormap=cv2.COLORMAP_PARULA,
|
||||
imw=w,
|
||||
imh=h,
|
||||
view_img=True,
|
||||
shape="circle")
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue