ultralytics 8.2.18 major Ultralytics Solutions refactor (#12797)
Co-authored-by: Muhammad Rizwan Munawar <muhammadrizwanmunawar123@gmail.com>
This commit is contained in:
parent
fceea033ad
commit
b6d425c041
4 changed files with 195 additions and 119 deletions
|
|
@ -78,9 +78,8 @@
|
|||
{
|
||||
"cell_type": "code",
|
||||
"source": [
|
||||
"from ultralytics import YOLO\n",
|
||||
"from ultralytics.solutions import object_counter\n",
|
||||
"import cv2\n",
|
||||
"from ultralytics import YOLO, solutions\n",
|
||||
"\n",
|
||||
"model = YOLO(\"yolov8n.pt\")\n",
|
||||
"cap = cv2.VideoCapture(\"path/to/video/file.mp4\")\n",
|
||||
|
|
@ -91,17 +90,16 @@
|
|||
"region_points = [(20, 400), (1080, 404), (1080, 360), (20, 360)]\n",
|
||||
"\n",
|
||||
"# Video writer\n",
|
||||
"video_writer = cv2.VideoWriter(\"object_counting_output.avi\",\n",
|
||||
" cv2.VideoWriter_fourcc(*'mp4v'),\n",
|
||||
" fps,\n",
|
||||
" (w, h))\n",
|
||||
"video_writer = cv2.VideoWriter(\"object_counting_output.avi\", cv2.VideoWriter_fourcc(*'mp4v'), fps, (w, h))\n",
|
||||
"\n",
|
||||
"# Init Object Counter\n",
|
||||
"counter = object_counter.ObjectCounter()\n",
|
||||
"counter.set_args(view_img=True,\n",
|
||||
" reg_pts=region_points,\n",
|
||||
" classes_names=model.names,\n",
|
||||
" draw_tracks=True)\n",
|
||||
"counter = solutions.ObjectCounter(\n",
|
||||
" view_img=True,\n",
|
||||
" reg_pts=region_points,\n",
|
||||
" classes_names=model.names,\n",
|
||||
" draw_tracks=True,\n",
|
||||
" line_thickness=2,\n",
|
||||
")\n",
|
||||
"\n",
|
||||
"while cap.isOpened():\n",
|
||||
" success, im0 = cap.read()\n",
|
||||
|
|
@ -146,4 +144,4 @@
|
|||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue