Update notebooks (#17065)
Co-authored-by: UltralyticsAssistant <web@ultralytics.com> Co-authored-by: Glenn Jocher <glenn.jocher@ultralytics.com>
This commit is contained in:
parent
b9747791df
commit
71624018e2
2 changed files with 11 additions and 28 deletions
|
|
@ -96,10 +96,7 @@
|
|||
"source": [
|
||||
"import cv2\n",
|
||||
"\n",
|
||||
"from ultralytics import YOLO, solutions\n",
|
||||
"\n",
|
||||
"# Load YOLO model\n",
|
||||
"model = YOLO(\"yolo11n.pt\")\n",
|
||||
"from ultralytics import solutions\n",
|
||||
"\n",
|
||||
"# Open video file\n",
|
||||
"cap = cv2.VideoCapture(\"path/to/video/file.mp4\")\n",
|
||||
|
|
@ -113,10 +110,9 @@
|
|||
"\n",
|
||||
"# Initialize heatmap object\n",
|
||||
"heatmap_obj = solutions.Heatmap(\n",
|
||||
" colormap=cv2.COLORMAP_PARULA,\n",
|
||||
" view_img=True,\n",
|
||||
" shape=\"circle\",\n",
|
||||
" names=model.names,\n",
|
||||
" colormap=cv2.COLORMAP_PARULA, # Color of the heatmap\n",
|
||||
" show=True, # Display the image during processing\n",
|
||||
" model=yolo11n.pt, # Ultralytics YOLO11 model file\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"while cap.isOpened():\n",
|
||||
|
|
@ -125,11 +121,8 @@
|
|||
" print(\"Video frame is empty or video processing has been successfully completed.\")\n",
|
||||
" break\n",
|
||||
"\n",
|
||||
" # Perform tracking on the current frame\n",
|
||||
" tracks = model.track(im0, persist=True, show=False)\n",
|
||||
"\n",
|
||||
" # Generate heatmap on the frame\n",
|
||||
" im0 = heatmap_obj.generate_heatmap(im0, tracks)\n",
|
||||
" im0 = heatmap_obj.generate_heatmap(im0)\n",
|
||||
"\n",
|
||||
" # Write the frame to the output video\n",
|
||||
" video_writer.write(im0)\n",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue