from ultralytics import YOLO, Heatmap
import cv2
model = YOLO("/home/safepro/Documents/croud_map/final-poc/Crowd-heatmap/crowd-seg.pt") # Load your model
video_path = "/home/safepro/Documents/croud_map/final-poc/Crowd-heatmap/eagle-view.mp4"
cap = cv2.VideoCapture(video_path)
# Ensure video opens correctly
assert cap.isOpened(), "Failed to open video."
# Initialize Heatmap without additional arguments
heatmap_obj = Heatmap()
while True:
ret, frame = cap.read()
if not ret:
break # Exit loop if no more frames
# Generate predictions and apply heatmaps
results = model.predict(frame)
frame_with_heatmap = heatmap_obj.apply(frame, results)
# Display the frame with applied heatmap
cv2.imshow("Heatmap Visual", frame_with_heatmap)
if cv2.waitKey(10) == ord('q'):
break
cap.release()
cv2.destroyAllWindows()
from ultralytics import YOLO, Heatmap
ImportError:无法从“ultralytics”导入名称“Heatmap”(/home/safepro/.local/lib/python3.10/site-packages/ultralytics/init.py) 我尝试更新 ultralytics,但无法解决这个问题,这个脚本是由 ultralytics 的人之一提供的
我尝试了很多方法来绘制分割的热图,但我无法解决并接受了 Ultralytics 人的帮助,即使他们也无法重新处理如果有人在实例分割上绘制了热图,请分享我