์ฝ˜ํ…์ธ ๋กœ ๊ฑด๋„ˆ๋›ฐ๊ธฐ

ํŠธ๋ž™์กด ์‚ฌ์šฉ Ultralytics YOLO11

ํŠธ๋ž™์กด์ด๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”?

TrackZone์€ ์ „์ฒด ํ”„๋ ˆ์ž„์ด ์•„๋‹Œ ํ”„๋ ˆ์ž„์˜ ์ง€์ •๋œ ์˜์—ญ ๋‚ด์˜ ๊ฐ์ฒด๋ฅผ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๋Š” ๋ฐ ํŠนํ™”๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๊ธฐ๋ฐ˜ Ultralytics YOLO11์„ ๊ธฐ๋ฐ˜์œผ๋กœ ๋น„๋””์˜ค ๋ฐ ๋ผ์ด๋ธŒ ์นด๋ฉ”๋ผ ํ”ผ๋“œ์˜ ํŠน์ • ์˜์—ญ ๋‚ด์—์„œ ๊ฐ์ฒด ๊ฐ์ง€ ๋ฐ ์ถ”์ ์„ ํ†ตํ•ฉํ•ฉ๋‹ˆ๋‹ค. YOLO11 ์˜ ๊ณ ๊ธ‰ ์•Œ๊ณ ๋ฆฌ์ฆ˜๊ณผ ๋”ฅ ๋Ÿฌ๋‹ ๊ธฐ์ˆ ์€ ๊ตฐ์ค‘ ๋ชจ๋‹ˆํ„ฐ๋ง ๋ฐ ๊ฐ์‹œ์™€ ๊ฐ™์€ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์—์„œ ์ •ํ™•ํ•˜๊ณ  ํšจ์œจ์ ์ธ ๊ฐ์ฒด ์ถ”์ ์„ ์ œ๊ณตํ•˜์—ฌ ์‹ค์‹œ๊ฐ„ ์‚ฌ์šฉ ์‚ฌ๋ก€์— ์™„๋ฒฝํ•œ ์„ ํƒ์ž…๋‹ˆ๋‹ค.

์˜์—ญ ๋‚ด ์˜ค๋ธŒ์ ํŠธ ์ถ”์ ์˜ ์žฅ์ (ํŠธ๋ž™์กด)

  • ํƒ€๊ฒŸ ๋ถ„์„: ํŠน์ • ์˜์—ญ ๋‚ด์˜ ๊ฐœ์ฒด๋ฅผ ์ถ”์ ํ•˜๋ฉด ์ง„์ž… ์ง€์ ์ด๋‚˜ ์ œํ•œ ๊ตฌ์—ญ๊ณผ ๊ฐ™์€ ๊ด€์‹ฌ ์˜์—ญ์„ ์ •๋ฐ€ํ•˜๊ฒŒ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๊ณ  ๋ถ„์„ํ•  ์ˆ˜ ์žˆ์–ด ๋ณด๋‹ค ์ง‘์ค‘์ ์ธ ์ธ์‚ฌ์ดํŠธ๋ฅผ ์–ป์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
  • ํšจ์œจ์„ฑ ํ–ฅ์ƒ: TrackZone์€ ์ถ”์  ๋ฒ”์œ„๋ฅผ ์ •์˜๋œ ์˜์—ญ์œผ๋กœ ์ขํ˜€์„œ ๊ณ„์‚ฐ ์˜ค๋ฒ„ํ—ค๋“œ๋ฅผ ์ค„์ž„์œผ๋กœ์จ ๋” ๋น ๋ฅธ ์ฒ˜๋ฆฌ์™€ ์ตœ์ ์˜ ์„ฑ๋Šฅ์„ ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค.
  • ๋ณด์•ˆ ๊ฐ•ํ™”: ๊ตฌ์—ญ ์ถ”์ ์€ ์ค‘์š” ์˜์—ญ์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜์—ฌ ๋น„์ •์ƒ์ ์ธ ํ™œ๋™์ด๋‚˜ ๋ณด์•ˆ ์นจํ•ด๋ฅผ ์กฐ๊ธฐ์— ๋ฐœ๊ฒฌํ•  ์ˆ˜ ์žˆ๋„๋ก ์ง€์›ํ•จ์œผ๋กœ์จ ๊ฐ์‹œ๋ฅผ ๊ฐœ์„ ํ•ฉ๋‹ˆ๋‹ค.
  • ํ™•์žฅ ๊ฐ€๋Šฅํ•œ ์†”๋ฃจ์…˜: ํŠน์ • ๊ตฌ์—ญ์— ์ง‘์ค‘ํ•  ์ˆ˜ ์žˆ๋Š” ๊ธฐ๋Šฅ์œผ๋กœ ์†Œ๋งค ๊ณต๊ฐ„๋ถ€ํ„ฐ ์‚ฐ์—… ํ™˜๊ฒฝ์— ์ด๋ฅด๊ธฐ๊นŒ์ง€ ๋‹ค์–‘ํ•œ ์‹œ๋‚˜๋ฆฌ์˜ค์— ์ ์šฉํ•  ์ˆ˜ ์žˆ์–ด ์›ํ™œํ•œ ํ†ตํ•ฉ๊ณผ ํ™•์žฅ์„ฑ์„ ๋ณด์žฅํ•˜๋Š” TrackZone์ž…๋‹ˆ๋‹ค.

์‹ค์ œ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜

๋†์—… ๊ตํ†ตํŽธ
๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ•„๋“œ์—์„œ ์‹๋ฌผ ์ถ”์  Ultralytics YOLO11 ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋„๋กœ์—์„œ ์ฐจ๋Ÿ‰ ์ถ”์  Ultralytics YOLO11
๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ํ•„๋“œ์—์„œ ์‹๋ฌผ ์ถ”์  Ultralytics YOLO11 ๋‹ค์Œ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋„๋กœ์—์„œ ์ฐจ๋Ÿ‰ ์ถ”์  Ultralytics YOLO11

YOLO11 ์˜ˆ์ œ๋ฅผ ์‚ฌ์šฉํ•œ ํŠธ๋ž™์กด

# Run a trackzone example
yolo solutions trackzone show=True

# Pass a source video
yolo solutions trackzone show=True source="path/to/video/file.mp4"

# Pass region coordinates
yolo solutions trackzone show=True region=[(150, 150), (1130, 150), (1130, 570), (150, 570)]
import cv2

from ultralytics import solutions

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 = [(150, 150), (1130, 150), (1130, 570), (150, 570)]

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

# Init TrackZone (Object Tracking in Zones, not complete frame)
trackzone = solutions.TrackZone(
    show=True,  # Display the output
    region=region_points,  # Pass region points
    model="yolo11n.pt",  # You can use any model that Ultralytics support, i.e. YOLOv9, YOLOv10
    # line_width=2,  # Adjust the line width for bounding boxes and text display
    # classes=[0, 2],  # If you want to count specific classes i.e. person and car with COCO pretrained model.
)

# Process video
while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = trackzone.trackzone(im0)
    video_writer.write(im0)

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

์ธ์ˆ˜ TrackZone

๋‹ค์Œ์€ ํ‘œ์ž…๋‹ˆ๋‹ค. TrackZone ์ธ์ˆ˜๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค:

์ด๋ฆ„ ์œ ํ˜• ๊ธฐ๋ณธ๊ฐ’ ์„ค๋ช…
model str None Ultralytics YOLO ๋ชจ๋ธ ํŒŒ์ผ ๊ฒฝ๋กœ
region list [(150, 150), (1130, 150), (1130, 570), (150, 570)] ๊ฐ์ฒด ์ถ”์  ์˜์—ญ์„ ์ •์˜ํ•˜๋Š” ํฌ์ธํŠธ ๋ชฉ๋ก์ž…๋‹ˆ๋‹ค.
line_width int 2 ๊ฒฝ๊ณ„ ์ƒ์ž์˜ ์„  ๋‘๊ป˜์ž…๋‹ˆ๋‹ค.
show bool False ๋น„๋””์˜ค ์ŠคํŠธ๋ฆผ ํ‘œ์‹œ ์—ฌ๋ถ€๋ฅผ ์ œ์–ดํ•˜๋Š” ํ”Œ๋ž˜๊ทธ์ž…๋‹ˆ๋‹ค.

์ธ์ˆ˜ model.track

์ธ์ˆ˜ ์œ ํ˜• ๊ธฐ๋ณธ๊ฐ’ ์„ค๋ช…
source str None ์ด๋ฏธ์ง€ ๋˜๋Š” ๋™์˜์ƒ์˜ ์†Œ์Šค ๋””๋ ‰ํ„ฐ๋ฆฌ๋ฅผ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค. ํŒŒ์ผ ๊ฒฝ๋กœ ๋ฐ URL์„ ์ง€์›ํ•ฉ๋‹ˆ๋‹ค.
persist bool False ํ”„๋ ˆ์ž„ ๊ฐ„ ์˜ค๋ธŒ์ ํŠธ๋ฅผ ์ง€์†์ ์œผ๋กœ ์ถ”์ ํ•˜์—ฌ ๋น„๋””์˜ค ์‹œํ€€์Šค ์ „์ฒด์—์„œ ID๋ฅผ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
tracker str botsort.yaml ์‚ฌ์šฉํ•  ์ถ”์  ์•Œ๊ณ ๋ฆฌ์ฆ˜์„ ์ง€์ •ํ•ฉ๋‹ˆ๋‹ค(์˜ˆ, bytetrack.yaml ๋˜๋Š” botsort.yaml.
conf float 0.3 ํƒ์ง€ ์‹ ๋ขฐ ์ž„๊ณ„๊ฐ’์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค. ๊ฐ’์ด ๋‚ฎ์„์ˆ˜๋ก ๋” ๋งŽ์€ ๊ฐœ์ฒด๋ฅผ ์ถ”์ ํ•  ์ˆ˜ ์žˆ์ง€๋งŒ ์˜คํƒ์ด ํฌํ•จ๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
iou float 0.5 ์ค‘๋ณต ๊ฐ์ง€๋ฅผ ํ•„ํ„ฐ๋งํ•˜๊ธฐ ์œ„ํ•œ IoU( Intersection over Union ) ์ž„๊ณ„๊ฐ’์„ ์„ค์ •ํ•ฉ๋‹ˆ๋‹ค.
classes list None ํด๋ž˜์Šค ์ธ๋ฑ์Šค๋ณ„๋กœ ๊ฒฐ๊ณผ๋ฅผ ํ•„ํ„ฐ๋งํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ๋ฅผ ๋“ค์–ด classes=[0, 2, 3] ์ง€์ •๋œ ํด๋ž˜์Šค๋งŒ ์ถ”์ ํ•ฉ๋‹ˆ๋‹ค.
verbose bool True ์ถ”์  ๊ฒฐ๊ณผ์˜ ํ‘œ์‹œ๋ฅผ ์ œ์–ดํ•˜์—ฌ ์ถ”์ ๋œ ๊ฐœ์ฒด์˜ ์‹œ๊ฐ์  ์ถœ๋ ฅ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

์ž์ฃผ ๋ฌป๋Š” ์งˆ๋ฌธ

Ultralytics YOLO11 ์„ ์‚ฌ์šฉํ•˜์—ฌ ๋น„๋””์˜ค ํ”„๋ ˆ์ž„์˜ ํŠน์ • ์˜์—ญ ๋˜๋Š” ์˜์—ญ์— ์žˆ๋Š” ๊ฐ์ฒด๋ฅผ ์ถ”์ ํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•˜๋‚˜์š”?

Ultralytics YOLO11 ์„ ์‚ฌ์šฉํ•˜๋ฉด ๋น„๋””์˜ค ํ”„๋ ˆ์ž„์˜ ์ •์˜๋œ ์˜์—ญ ๋˜๋Š” ์˜์—ญ์— ์žˆ๋Š” ๊ฐ์ฒด๋ฅผ ์‰ฝ๊ฒŒ ์ถ”์ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ์•„๋ž˜ ์ œ๊ณต๋œ ๋ช…๋ น์„ ์‚ฌ์šฉํ•ด ์ถ”์ ์„ ์‹œ์ž‘ํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค. ์ด ์ ‘๊ทผ ๋ฐฉ์‹์€ ํšจ์œจ์ ์ธ ๋ถ„์„๊ณผ ์ •ํ™•ํ•œ ๊ฒฐ๊ณผ๋ฅผ ๋ณด์žฅํ•˜๋ฏ€๋กœ ๊ฐ์‹œ, ๊ตฐ์ค‘ ๊ด€๋ฆฌ ๋˜๋Š” ๊ตฌ์—ญ ์ถ”์ ์ด ํ•„์š”ํ•œ ๋ชจ๋“  ์‹œ๋‚˜๋ฆฌ์˜ค์— ์ด์ƒ์ ์ž…๋‹ˆ๋‹ค.

yolo solutions trackzone source="path/to/video/file.mp4" show=True

Python Ultralytics YOLO11 ์—์„œ ํŠธ๋ž™์กด์„ ์‚ฌ์šฉํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋‚˜์š”?

๋ช‡ ์ค„์˜ ์ฝ”๋“œ๋งŒ์œผ๋กœ ํŠน์ • ์˜์—ญ์—์„œ ์˜ค๋ธŒ์ ํŠธ ์ถ”์ ์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ์–ด ํ”„๋กœ์ ํŠธ์— ์‰ฝ๊ฒŒ ํ†ตํ•ฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

import cv2

from ultralytics import solutions

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 = [(150, 150), (1130, 150), (1130, 570), (150, 570)]

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

# Init TrackZone (Object Tracking in Zones, not complete frame)
trackzone = solutions.TrackZone(
    show=True,  # Display the output
    region=region_points,  # Pass region points
    model="yolo11n.pt",
)

# Process video
while cap.isOpened():
    success, im0 = cap.read()
    if not success:
        print("Video frame is empty or video processing has been successfully completed.")
        break
    im0 = trackzone.trackzone(im0)
    video_writer.write(im0)

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

Ultralytics ํŠธ๋ž™์กด์„ ์‚ฌ์šฉํ•˜์—ฌ ๋น„๋””์˜ค ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๊ตฌ์—ญ ์ง€์ ์„ ๊ตฌ์„ฑํ•˜๋ ค๋ฉด ์–ด๋–ป๊ฒŒ ํ•ด์•ผ ํ•˜๋‚˜์š”?

Ultralytics TrackZone์œผ๋กœ ๋น„๋””์˜ค ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•œ ๊ตฌ์—ญ ์ง€์ ์„ ๊ตฌ์„ฑํ•˜๋Š” ๊ฒƒ์€ ๊ฐ„๋‹จํ•˜๊ณ  ์‚ฌ์šฉ์ž ์ง€์ •ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. Python ์Šคํฌ๋ฆฝํŠธ๋ฅผ ํ†ตํ•ด ๊ตฌ์—ญ์„ ์ง์ ‘ ์ •์˜ํ•˜๊ณ  ์กฐ์ •ํ•  ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๋ ค๋Š” ์˜์—ญ์„ ์ •๋ฐ€ํ•˜๊ฒŒ ์ œ์–ดํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

# Define region points
region_points = [(150, 150), (1130, 150), (1130, 570), (150, 570)]

# Init TrackZone (Object Tracking in Zones, not complete frame)
trackzone = solutions.TrackZone(
    show=True,  # Display the output
    region=region_points,  # Pass region points
)
๐Ÿ“… 8์ผ ์ „ ์ƒ์„ฑ๋จ โœ๏ธ ์—…๋ฐ์ดํŠธ๋จ 8 ์ผ ์ „

๋Œ“๊ธ€