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

Ultralytics YOLOv8 ๐Ÿš€์„ ์ด์šฉํ•œ ์ฃผ์ฐจ ๊ด€๋ฆฌ

์ฃผ์ฐจ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์ด๋ž€ ๋ฌด์—‡์ธ๊ฐ€์š”?

์ฃผ์ฐจ ๊ด€๋ฆฌ Ultralytics YOLOv8 ๋Š” ๊ณต๊ฐ„์„ ๊ตฌ์„ฑํ•˜๊ณ  ๊ฐ€์šฉ์„ฑ์„ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜์—ฌ ํšจ์œจ์ ์ด๊ณ  ์•ˆ์ „ํ•œ ์ฃผ์ฐจ๋ฅผ ๋ณด์žฅํ•ฉ๋‹ˆ๋‹ค. YOLOv8 ์‹ค์‹œ๊ฐ„ ์ฐจ๋Ÿ‰ ๊ฐ์ง€ ๋ฐ ์ฃผ์ฐจ ์ ์œ ์œจ์— ๋Œ€ํ•œ ์ธ์‚ฌ์ดํŠธ๋ฅผ ํ†ตํ•ด ์ฃผ์ฐจ์žฅ ๊ด€๋ฆฌ๋ฅผ ๊ฐœ์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

์ฃผ์ฐจ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์˜ ์žฅ์ ์€?

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

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

์ฃผ์ฐจ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ ์ฃผ์ฐจ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ
์ฃผ์ฐจ์žฅ ๋ถ„์„ ์‚ฌ์šฉ Ultralytics YOLOv8 ๋‹ค์Œ์„ ์‚ฌ์šฉํ•œ ์ฃผ์ฐจ ๊ด€๋ฆฌ ํ‰๋ฉด๋„ Ultralytics YOLOv8
Parking management Aerial View using Ultralytics YOLOv8 ๋‹ค์Œ์„ ์‚ฌ์šฉํ•œ ์ฃผ์ฐจ ๊ด€๋ฆฌ ํ‰๋ฉด๋„ Ultralytics YOLOv8

์ฃผ์ฐจ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ ์ฝ”๋“œ ์›Œํฌํ”Œ๋กœ์šฐ

ํฌ์ธํŠธ ์„ ํƒ

์ด์ œ ํฌ์ธํŠธ ์„ ํƒ์ด ์‰ฌ์›Œ์กŒ์Šต๋‹ˆ๋‹ค.

์ฃผ์ฐจ ์ง€์  ์„ ํƒ์€ ์ฃผ์ฐจ ๊ด€๋ฆฌ ์‹œ์Šคํ…œ์—์„œ ๋งค์šฐ ์ค‘์š”ํ•˜๊ณ  ๋ณต์žกํ•œ ์ž‘์—…์ž…๋‹ˆ๋‹ค. Ultralytics ์—์„œ๋Š” ์ฃผ์ฐจ์žฅ ๊ตฌ์—ญ์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋Š” ๋„๊ตฌ๋ฅผ ์ œ๊ณตํ•˜์—ฌ ์ด ํ”„๋กœ์„ธ์Šค๋ฅผ ๊ฐ„์†Œํ™”ํ•˜๊ณ , ๋‚˜์ค‘์— ์ถ”๊ฐ€ ์ฒ˜๋ฆฌ์— ํ™œ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

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

์ด๋ฏธ์ง€ ํฌ๊ธฐ

์ตœ๋Œ€ ์ด๋ฏธ์ง€ ํฌ๊ธฐ 1920 * 1080 ์ง€์›

์ฃผ์ฐจ ์Šฌ๋กฏ ์ฃผ์„๊ธฐ Ultralytics YOLOv8

from ultralytics import solutions

solutions.ParkingPtsSelection()
  • ๋‹ค๊ฐํ˜•์œผ๋กœ ์ฃผ์ฐจ ๊ตฌ์—ญ์„ ์ •์˜ํ•œ ํ›„ ๋‹ค์Œ์„ ํด๋ฆญํ•ฉ๋‹ˆ๋‹ค. save ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ž‘์—… ๋””๋ ‰ํ„ฐ๋ฆฌ์— ๋ฐ์ดํ„ฐ๊ฐ€ ํฌํ•จ๋œ JSON ํŒŒ์ผ์„ ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

Ultralytics YOLOv8 ํฌ์ธํŠธ ์„ ํƒ ๋ฐ๋ชจ

Python ์ฃผ์ฐจ ๊ด€๋ฆฌ ์ฝ”๋“œ

YOLOv8 ์˜ˆ์ œ๋ฅผ ์‚ฌ์šฉํ•œ ์ฃผ์ฐจ ๊ด€๋ฆฌ

import cv2

from ultralytics import solutions

# Path to json file, that created with above point selection app
polygon_json_path = "bounding_boxes.json"

# Video capture
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))

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

# Initialize parking management object
management = solutions.ParkingManagement(model_path="yolov8n.pt")

while cap.isOpened():
    ret, im0 = cap.read()
    if not ret:
        break

    json_data = management.parking_regions_extraction(polygon_json_path)
    results = management.model.track(im0, persist=True, show=False)

    if results[0].boxes.id is not None:
        boxes = results[0].boxes.xyxy.cpu().tolist()
        clss = results[0].boxes.cls.cpu().tolist()
        management.process_data(json_data, im0, boxes, clss)

    management.display_frames(im0)
    video_writer.write(im0)

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

์„ ํƒ์  ์ธ์ˆ˜ ParkingManagement

์ด๋ฆ„ ์œ ํ˜• ๊ธฐ๋ณธ๊ฐ’ ์„ค๋ช…
model_path str None YOLOv8 ๋ชจ๋ธ ๊ฒฝ๋กœ์ž…๋‹ˆ๋‹ค.
txt_color tuple (0, 0, 0) ํ…์ŠคํŠธ์šฉ RGB ์ปฌ๋Ÿฌ ํŠœํ”Œ์ž…๋‹ˆ๋‹ค.
bg_color tuple (255, 255, 255) ๋ฐฐ๊ฒฝ์šฉ RGB ์ปฌ๋Ÿฌ ํŠœํ”Œ์ž…๋‹ˆ๋‹ค.
occupied_region_color tuple (0, 255, 0) ์ ์œ  ์˜์—ญ์— ๋Œ€ํ•œ RGB ์ปฌ๋Ÿฌ ํŠœํ”Œ์ž…๋‹ˆ๋‹ค.
available_region_color tuple (0, 0, 255) ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ ์ง€์—ญ์— ๋Œ€ํ•œ RGB ์ƒ‰์ƒ ํŠœํ”Œ์ž…๋‹ˆ๋‹ค.
margin int 10 ํ…์ŠคํŠธ ํ‘œ์‹œ๋ฅผ ์œ„ํ•œ ์—ฌ๋ฐฑ.

์ธ์ˆ˜ model.track

์ด๋ฆ„ ์œ ํ˜• ๊ธฐ๋ณธ๊ฐ’ ์„ค๋ช…
source im0 None ์ด๋ฏธ์ง€ ๋˜๋Š” ๋น„๋””์˜ค์˜ ์†Œ์Šค ๋””๋ ‰ํ† ๋ฆฌ
persist bool False ํ”„๋ ˆ์ž„ ๊ฐ„ ํŠธ๋ž™ ์ง€์†
tracker str botsort.yaml ์ถ”์  ๋ฐฉ๋ฒ• '๋ฐ”์ดํŠธํŠธ๋ž™' ๋˜๋Š” '๋ด‡์†ŒํŠธ'
conf float 0.3 ์‹ ๋ขฐ ์ž„๊ณ„๊ฐ’
iou float 0.5 IOU ์ž„๊ณ„๊ฐ’
classes list None ํด๋ž˜์Šค๋ณ„๋กœ ๊ฒฐ๊ณผ๋ฅผ ํ•„ํ„ฐ๋งํ•ฉ๋‹ˆ๋‹ค(์˜ˆ: classes=0 ๋˜๋Š” classes=[0,2,3]).
verbose bool True ๊ฐœ์ฒด ์ถ”์  ๊ฒฐ๊ณผ ํ‘œ์‹œ


Created 2024-04-29, Updated 2024-06-10
Authors: glenn-jocher (6), IvorZhu331 (1), RizwanMunawar (3)

๋Œ“๊ธ€