─░├žeri─če ge├ž

Ultralytics YOLOv8 adresini kullanarak Nesne Sayma ­čÜÇ

Nesne Sayma Nedir?

Nesne sayma ile Ultralytics YOLOv8 videolarda ve kamera ak─▒┼člar─▒nda belirli nesnelerin do─čru bir ┼čekilde tan─▒mlanmas─▒n─▒ ve say─▒lmas─▒n─▒ i├žerir. YOLOv8 , son teknoloji algoritmalar─▒ ve derin ├Â─črenme yetenekleri sayesinde kalabal─▒k analizi ve g├Âzetim gibi ├že┼čitli senaryolar i├žin verimli ve hassas nesne say─▒m─▒ sa─člayarak ger├žek zamanl─▒ uygulamalarda ├Âne ├ž─▒kar.


─░zle: Nesne Sayma kullanarak Ultralytics YOLOv8

─░zle: Class-wise Object Counting using Ultralytics YOLOv8

Nesne Sayman─▒n Avantajlar─▒?

  • Kaynak Optimizasyonu: Nesne say─▒m─▒, do─čru say─▒mlar sa─člayarak ve envanter y├Ânetimi gibi uygulamalarda kaynak tahsisini optimize ederek verimli kaynak y├Ânetimini kolayla┼čt─▒r─▒r.
  • Geli┼čmi┼č G├╝venlik: Nesne sayma, varl─▒klar─▒ do─čru bir ┼čekilde izleyip sayarak g├╝venli─či ve g├Âzetimi art─▒r─▒r ve proaktif tehdit tespitine yard─▒mc─▒ olur.
  • Bilgilendirilmi┼č Karar Alma: Nesne say─▒m─▒, perakende, trafik y├Ânetimi ve di─čer ├že┼čitli alanlarda karar verme, s├╝re├žleri optimize etme i├žin de─čerli bilgiler sunar.

Ger├žek D├╝nya Uygulamalar─▒

Lojistik Akuak├╝lt├╝r
Konvey├Âr Bant Paketleri Kullanarak Sayma Ultralytics YOLOv8 Denizde Bal─▒k Say─▒m─▒ Ultralytics YOLOv8
Konvey├Âr Bant Paketleri Kullanarak Sayma Ultralytics YOLOv8 Denizde Bal─▒k Say─▒m─▒ Ultralytics YOLOv8

YOLOv8 kullanarak Nesne Sayma ├ľrnek

import cv2

from ultralytics import YOLO, solutions

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))

# Define region points
region_points = [(20, 400), (1080, 404), (1080, 360), (20, 360)]

# Video writer
video_writer = cv2.VideoWriter("object_counting_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))

# Init Object Counter
counter = solutions.ObjectCounter(
    view_img=True,
    reg_pts=region_points,
    classes_names=model.names,
    draw_tracks=True,
    line_thickness=2,
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    tracks = model.track(im0, persist=True, show=False)

    im0 = counter.start_counting(im0, tracks)
    video_writer.write(im0)

cap.release()
video_writer.release()
cv2.destroyAllWindows()
import cv2

from ultralytics import YOLO, solutions

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))

# Define region points as a polygon with 5 points
region_points = [(20, 400), (1080, 404), (1080, 360), (20, 360), (20, 400)]

# Video writer
video_writer = cv2.VideoWriter("object_counting_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))

# Init Object Counter
counter = solutions.ObjectCounter(
    view_img=True,
    reg_pts=region_points,
    classes_names=model.names,
    draw_tracks=True,
    line_thickness=2,
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    tracks = model.track(im0, persist=True, show=False)

    im0 = counter.start_counting(im0, tracks)
    video_writer.write(im0)

cap.release()
video_writer.release()
cv2.destroyAllWindows()
import cv2

from ultralytics import YOLO, solutions

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))

# Define line points
line_points = [(20, 400), (1080, 400)]

# Video writer
video_writer = cv2.VideoWriter("object_counting_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))

# Init Object Counter
counter = solutions.ObjectCounter(
    view_img=True,
    reg_pts=line_points,
    classes_names=model.names,
    draw_tracks=True,
    line_thickness=2,
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    tracks = model.track(im0, persist=True, show=False)

    im0 = counter.start_counting(im0, tracks)
    video_writer.write(im0)

cap.release()
video_writer.release()
cv2.destroyAllWindows()
import cv2

from ultralytics import YOLO, solutions

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))

line_points = [(20, 400), (1080, 400)]  # line or region points
classes_to_count = [0, 2]  # person and car classes for count

# Video writer
video_writer = cv2.VideoWriter("object_counting_output.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))

# Init Object Counter
counter = solutions.ObjectCounter(
    view_img=True,
    reg_pts=line_points,
    classes_names=model.names,
    draw_tracks=True,
    line_thickness=2,
)

while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    tracks = model.track(im0, persist=True, show=False, classes=classes_to_count)

    im0 = counter.start_counting(im0, tracks)
    video_writer.write(im0)

cap.release()
video_writer.release()
cv2.destroyAllWindows()
B├Âlge Hareketli

Kenarlar─▒na t─▒klayarak b├Âlgeyi ├žer├ževe i├žinde herhangi bir yere ta┼č─▒yabilirsiniz

Tart─▒┼čma ObjectCounter

─░┼čte bir tablo ObjectCounter Arg├╝manlar:

─░sim Tip Varsay─▒lan A├ž─▒klama
classes_names dict None S─▒n─▒f adlar─▒ s├Âzl├╝─č├╝.
reg_pts list [(20, 400), (1260, 400)] Say─▒m b├Âlgesini tan─▒mlayan noktalar─▒n listesi.
count_reg_color tuple (255, 0, 255) Sayma b├Âlgesinin RGB rengi.
count_txt_color tuple (0, 0, 0) Say─▒m metninin RGB rengi.
count_bg_color tuple (255, 255, 255) Say─▒m metni arka plan─▒n─▒n RGB rengi.
line_thickness int 2 S─▒n─▒rlay─▒c─▒ kutular i├žin ├žizgi kal─▒nl─▒─č─▒.
track_thickness int 2 Ray ├žizgilerinin kal─▒nl─▒─č─▒.
view_img bool False Video ak─▒┼č─▒n─▒n g├Âr├╝nt├╝lenip g├Âr├╝nt├╝lenmeyece─čini kontrol etmek i├žin bayrak.
view_in_counts bool True Video ak─▒┼č─▒nda giri┼č say─▒lar─▒n─▒n g├Âr├╝nt├╝lenip g├Âr├╝nt├╝lenmeyece─čini kontrol etmek i├žin bayrak.
view_out_counts bool True Video ak─▒┼č─▒nda ├ž─▒k─▒┼č say─▒lar─▒n─▒n g├Âr├╝nt├╝lenip g├Âr├╝nt├╝lenmeyece─čini kontrol etmek i├žin bayrak.
draw_tracks bool False Nesne izlerinin ├žizilip ├žizilmeyece─čini kontrol etmek i├žin bayrak.
track_color tuple None ─░zlerin RGB rengi.
region_thickness int 5 Nesne sayma b├Âlgesinin kal─▒nl─▒─č─▒.
line_dist_thresh int 15 ├çizgi sayac─▒ i├žin ├ľklid mesafesi e┼či─či.
cls_txtdisplay_gap int 50 Her s─▒n─▒f say─▒s─▒ aras─▒ndaki bo┼člu─ču g├Âr├╝nt├╝leyin.

Arg├╝manlar model.track

─░sim Tip Varsay─▒lan A├ž─▒klama
source im0 None resimler veya videolar i├žin kaynak dizin
persist bool False kareler aras─▒nda kal─▒c─▒ izler
tracker str botsort.yaml ─░zleme y├Ântemi 'bytetrack' veya 'botsort'
conf float 0.3 G├╝ven E┼či─či
iou float 0.5 IOU E┼či─či
classes list None sonu├žlar─▒ s─▒n─▒fa g├Âre filtreleyin, yani classes=0 veya classes=[0,2,3]
verbose bool True Nesne izleme sonu├žlar─▒n─▒ g├Âr├╝nt├╝leme


Created 2023-12-02, Updated 2024-06-10
Authors: glenn-jocher (14), IvorZhu331 (1), RizwanMunawar (6), AyushExel (1)

Yorumlar