Ultralytics YOLO26을 사용한 VisionEye 뷰 객체 매핑

VisionEye 객체 매핑이란 무엇인가요?#

Ultralytics YOLO26의 VisionEye를 사용하면 컴퓨터가 객체를 식별하고 위치를 특정하여 사람의 눈과 유사한 관찰 정밀도를 구현할 수 있습니다. 이 기능을 통해 컴퓨터는 특정 시점에서 사람의 눈이 세부 사항을 관찰하는 것처럼 특정 객체를 식별하고 집중할 수 있습니다.

VisionEye object mapping with YOLO tracking

YOLO26으로 객체 매핑하기#

VisionEye는 프레임 내에 하나의 관찰 지점을 고정하고 해당 지점에서 추적 중인 각 객체까지 광선을 그려, 한 관점에서 장면을 어떻게 볼 수 있는지 시각화합니다. vision_point을 관찰자의 픽셀 좌표로 설정한 다음, Python API 또는 CLI를 사용해 동영상에 솔루션을 실행하세요.

Ultralytics YOLO를 사용한 VisionEye 매핑
# Monitor objects position with visioneye
yolo solutions visioneye show=True

# Pass a source video
yolo solutions visioneye source="path/to/video.mp4"

# Monitor the specific classes
yolo solutions visioneye classes="[0, 5]"

VisionEye 인수#

다음은 VisionEye 인수 표입니다:

인수유형기본값설명
modelstrNoneUltralytics YOLO 모델 파일의 경로입니다.
vision_pointtuple[int, int](20, 20)VisionEye 솔루션을 사용하여 객체를 추적하고 경로를 그릴 기준점입니다.
line_widthint2Solution에서 그리는 상자, 키포인트 및 개수 표시의 선 두께입니다.
verboseboolTrue프레임별 입력 형태, 클래스 개수 및 처리 속도 로그를 활성화합니다. 추적 호출 자체는 항상 로그를 출력하지 않습니다.

또한 VisionEye 솔루션에서 다양한 track 인수를 사용할 수 있습니다.

인수유형기본값설명
trackerstr'tracktrack.yaml'사용할 추적 알고리즘을 지정합니다. 기본 제공 옵션: botsort.yaml, bytetrack.yaml, ocsort.yaml, deepocsort.yaml, fasttrack.yaml, tracktrack.yaml.
conffloat0.25탐지에 대한 신뢰도 임계값을 설정합니다. 값을 낮추면 추적할 수 있는 객체가 늘어나지만 오탐이 포함될 수 있습니다.
ioufloat0.5중복 탐지를 필터링하기 위한 교집합 대비 합집합 (IoU) 임계값을 설정합니다.
classeslistNone클래스 인덱스로 결과를 필터링합니다. 예를 들어 classes=[0, 2, 3]은 지정된 클래스만 추적합니다.
devicestrNone추론에 사용할 장치를 지정합니다(예: cpu, cuda:0 또는 0). 사용자는 모델 실행에 사용할 CPU, 특정 GPU 또는 기타 연산 장치를 선택할 수 있습니다.
imgszint or tuple640추론 대상 이미지 크기입니다. 정사각형을 나타내는 정수 또는 (height, width) 쌍을 지정합니다. 모델 stride에 맞춰 형태가 조정됩니다.
max_detint300추적 전에 프레임별로 유지할 최대 탐지 수를 지정하여 밀집된 장면에서 솔루션이 처리하는 객체 수를 제한합니다.
quantizeint or strNone추론 정밀도: CPU 이외의 환경에서 PyTorch 및 TorchScript 모델은 16(FP16) 또는 32/unset(FP32)을 사용하며, 다른 형식은 아티팩트와 런타임이 선택하는 정밀도를 사용합니다. 더 이상 사용되지 않는 half 인수를 대체합니다.

또한 아래에 나열된 일부 시각화 인수도 지원됩니다.

인수유형기본값설명
showboolFalseTrue이면 주석이 추가된 이미지나 비디오를 창에 표시합니다. 개발 또는 테스트 중 즉각적인 시각적 피드백을 얻는 데 유용합니다.
show_confboolTrue각 감지 결과의 레이블 옆에 신뢰도 점수를 표시합니다. 각 감지 결과에 대한 모델의 확신도를 파악할 수 있습니다.
show_labelsboolTrue시각화 출력에 각 감지 결과의 레이블을 표시합니다. 감지된 객체를 즉시 파악할 수 있습니다.

VisionEye 작동 방식#

VisionEye는 프레임 내에 고정된 시야 지점을 설정하고 이 지점에서 감지된 객체까지 선을 그립니다. 이는 하나의 관점에서 여러 객체에 초점을 맞추는 인간의 시각을 구현합니다. 이 솔루션은 객체 추적을 사용해 프레임 전반에서 객체를 일관되게 식별하고, 관찰자(시야 지점)와 장면 내 객체 간의 공간적 관계를 시각적으로 표현합니다.

VisionEye 클래스의 process 메서드는 다음과 같은 주요 작업을 수행합니다.

  1. 입력 이미지에서 트랙(바운딩 박스, 클래스 및 트랙 ID)을 추출합니다.
  2. 바운딩 박스와 레이블을 그릴 어노테이터를 생성합니다.
  3. 감지된 각 객체에 대해 박스 레이블을 그리고 시야 지점에서 시작하는 시야선을 생성합니다.
  4. 추적 통계가 포함된 어노테이션 이미지를 반환합니다.

이 접근 방식은 감시 시스템, 자율 주행, 인터랙티브 설치물처럼 공간 인식 및 객체 관계 시각화가 필요한 애플리케이션에 특히 유용합니다.

VisionEye의 애플리케이션#

VisionEye 객체 매핑은 다양한 산업 분야에서 폭넓게 활용됩니다.

  • 보안 및 감시: 고정된 카메라 위치에서 관심 객체 여러 개를 모니터링합니다.
  • 리테일 분석: 매장 진열대와 관련된 고객의 이동 패턴을 추적합니다.
  • 스포츠 분석: 코치의 관점에서 선수의 위치와 움직임을 분석합니다.
  • 자율주행차: 차량이 주변 환경의 객체를 어떻게 '보고' 우선순위를 정하는지 시각화합니다.
  • 인간-컴퓨터 상호작용: 공간적 관계에 반응하는 더욱 직관적인 인터페이스를 만듭니다.

VisionEye를 거리 계산이나 속도 추정과 같은 다른 Ultralytics 솔루션과 결합하면 객체를 추적할 뿐 아니라 객체 간의 공간적 관계와 동작도 파악하는 종합 시스템을 구축할 수 있습니다.

자주 묻는 질문#

  • Ultralytics YOLO26에서 VisionEye Object Mapping을 사용하려면 먼저 pip를 통해 Ultralytics 패키지를 설치합니다. 그런 다음 문서의 샘플 코드를 사용하여 VisionEye로 객체 감지를 설정할 수 있습니다. 시작하기에 적합한 간단한 예제는 다음과 같습니다.

    import cv2
    
    from ultralytics import solutions
    
    cap = cv2.VideoCapture("path/to/video.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 = cv2.VideoWriter("vision-eye-mapping.avi", cv2.VideoWriter_fourcc(*"mp4v"), fps, (w, h))
    
    # VisionEye 객체 초기화
    visioneye = solutions.VisionEye(
        show=True,  # 출력을 표시합니다.
        model="yolo26n.pt",  # Ultralytics가 지원하는 모든 모델 사용(예: yolo26s.pt)
        classes=[0, 2],  # 특정 클래스에 대한 VisionEye 뷰 생성
    )
    
    # 비디오 처리
    while cap.isOpened():
        success, im0 = cap.read()
    
        if not success:
            print("Video frame is empty or video processing has been successfully completed.")
            break
    
        results = visioneye(im0)
    
        print(results)  # 출력에 액세스합니다
    
        video_writer.write(results.plot_im)  # 비디오 파일 저장
    
    cap.release()
    video_writer.release()
    cv2.destroyAllWindows()  # 열려 있는 모든 창 닫기
  • Ultralytics YOLO26은 속도, 정확도, 통합 편의성을 모두 갖춰 객체 매핑과 추적에 적합합니다. 주요 장점은 다음과 같습니다.

    1. 실시간 성능: 실시간 객체 감지에서 높은 정확도를 제공합니다.
    2. 유연성: 하나의 파이프라인에서 감지, 추적, 거리 계산을 지원합니다.
    3. 커뮤니티 및 지원: 문제 해결과 기능 개선을 위한 방대한 문서와 활발한 GitHub 커뮤니티를 제공합니다.
    4. 사용 편의성: 직관적인 API로 복잡한 작업을 간소화하여 신속한 배포와 반복 작업을 지원합니다.

    애플리케이션과 이점에 관한 자세한 내용은 Ultralytics YOLO26 문서를 참조하세요.

  • Ultralytics YOLO26은 Comet 및 ClearML과 같은 다양한 머신러닝 도구와 통합되어 실험 추적, 협업, 재현성을 지원합니다. 시작하려면 YOLO26과 Comet 통합 및 YOLO26과 ClearML 통합에 관한 상세 가이드를 참조하세요.

    더 많은 탐색 정보와 통합 예제는 Ultralytics 통합 가이드를 확인하세요.

댓글60

질문을 하거나 결과를 공유하거나 다른 사람을 도와주세요.

  1. TranDHoaGitHub

    Hey, you can adjust the viewing angle of the eyes and make it measure the distance from the center of an object instead of from the edge.

    1. Glenn JocherUltralytics

      VisionEye already draws the ray from vision_point to the bounding-box centroid (not the edge) via SolutionAnnotator.visioneye() as shown in the VisionEye guide and the SolutionAnnotator visioneye() reference; there isn’t a separate “viewing angle” parameter today since it’s a 2D overlay, so the intended control is moving vision_point, and if you need an actual distance value (vs just a line), please use the Distance Calculation solution and share your desired behavior here (plus a short clip/frame + vision_point) so the team can advise the cleanest extension.

    1. Glenn JocherUltralytics

      @dixroby the requirements.txt file typically includes dependencies like torch, opencv-python, and other libraries necessary for running Ultralytics YOLO models. For a detailed list, please check the file directly in the repository.

  2. skp4595GitHub

    rather than taking video as input fro testing, I want to test for an image, how can I do that? guide me on this.

    1. Glenn JocherUltralytics(수정됨)

      Hi there!

      Great question! If you want to test an image instead of a video using Ultralytics YOLO, it's quite straightforward. Below is a simple example to guide you through the process:

      Testing on an Image

      First, ensure you have the latest versions of torch and ultralytics installed. If not, please update them:

      pip install --upgrade torch ultralytics

      Next, you can use the following code to test an image:

      import cv2
      from ultralytics import YOLO
      from ultralytics.utils.plotting import Annotator, colors
      
      # Load the model
      model = YOLO("yolo26n.pt")
      
      # Load the image
      image_path = "path/to/your/image.jpg"
      im0 = cv2.imread(image_path)
      
      # Perform prediction
      results = model.predict(im0)
      boxes = results[0].boxes.xyxy.cpu()
      clss = results[0].boxes.cls.cpu().tolist()
      
      # Annotate the image
      annotator = Annotator(im0, line_width=2)
      names = model.model.names
      
      for box, cls in zip(boxes, clss):
          annotator.box_label(box, label=names[int(cls)], color=colors(int(cls)))
      
      # Display the annotated image
      cv2.imshow("YOLO Image Prediction", im0)
      cv2.waitKey(0)
      cv2.destroyAllWindows()
      Explanation
      1. Load the Model: We load the YOLO model.
      2. Load the Image: Read the image using OpenCV.
      3. Perform Prediction: Use the model to predict objects in the image.
      4. Annotate the Image: Draw bounding boxes and labels on the image.
      5. Display the Image: Show the annotated image using OpenCV.

      This should help you get started with testing images. If you encounter any issues or have further questions, feel free to ask! 😊

      For more detailed information, you can refer to the VisionEye Object Mapping Guide.

      Happy coding! 🚀

  3. skp4595GitHub

    I want to run VisionEye Object Mapping using YOLOv8 code on KITTI data set. the KITTI dataset is labeled as <class_name1, truncation, occlusion, observation angle alpha, bbox cordinantes, Dimension of object, Location, rotation_y, score > for each image. While model training, I'm getting this error train: WARNING ⚠️ /content/dataset/train/images/005936.png: ignoring corrupt image/label: could not convert string to float: 'Car' train: WARNING ⚠️ /content/dataset/train/images/005937.png: ignoring corrupt image/label: could not convert string to float: 'Pedestrian' train: WARNING ⚠️ /content/dataset/train/images/005938.png: ignoring corrupt image/label: could not convert string to float: 'Truck'

    with these args { EPOCHS = 5 !yolo
    task=detect
    mode=train
    model=yolov8s.pt
    imgsz=640
    data=depth_estimation_using_YOLOv8.yaml
    epochs={EPOCHS}
    batch=16
    name=yolov8s
    exist_ok=True
    amp=False } how do I fix this?

    1. Paula DerrengerUltralytics(수정됨)

      Hi! The model is trained using the YOLOv8 framework. You can train it on custom datasets like KITTI by converting the dataset to the YOLO format. The dataset should have labels in the format <class_id> <x_center> <y_center> <width> <height>.

      For more details on VisionEye Object Mapping, check out the Ultralytics VisionEye guide. If you have any specific questions, feel free to ask! 🚀

      Here's a sample training command:

      yolo task=detect mode=train model=yolo26s.pt data=your_dataset.yaml epochs=5 batch=16

      Happy training! 😊

      1
  4. skp4595GitHub

    what does this mean "It calculates this distance by analyzing the size and position of the object within the frame, using the camera's field of view and other calibration parameters if available"? what do you mean by 'other calibration parameter if possible'? The model is not a blackbox. Is it? there must be some calibration, some ground truth from where model must have learned. please explain this.

    1. Glenn JocherUltralytics(수정됨)

      Hello! Great questions about the VisionEye Object Mapping using Ultralytics YOLOv8.

      1. Distance Calculation: The phrase "It calculates this distance by analyzing the size and position of the object within the frame, using the camera's field of view and other calibration parameters if available" was inaccurate. The VisionEye distance example does not estimate camera-to-object distance from object size or field of view. It computes the pixel distance between the vision point and the bounding-box centroid and divides it by the pixel_per_meter value you set, so you calibrate that scale yourself.

      2. Other Calibration Parameters: The example uses none of these. You would need data such as camera intrinsic parameters (focal length, optical centers), extrinsic parameters (orientation and position of the camera), object size references, or a depth sensor only if you build a true camera-to-object distance estimate yourself.

      3. Model Transparency: YOLOv8 models are not black boxes in the sense that their architecture and training processes are open for examination and modification. They learn from labeled data (ground truth) where objects are manually annotated in images, teaching the model how to recognize similar objects in new images.

      For further details or specific implementations, feel free to check out our guide on VisionEye Object Mapping at Ultralytics VisionEye Guide. If you have more questions or need clarification, don't hesitate to reach out! 😊

    1. Paula DerrengerUltralytics(수정됨)

      Hey there! 😊 It sounds like you're encountering some version compatibility issues. For Ultralytics YOLOv8, we generally recommend using Python 3.8 or newer as it strikes a good balance between being up-to-date and maintaining compatibility with most dependencies.

      If you're using a Python version older than 3.7, you might run into issues, and it's a good idea to update to at least version 3.7 or newer if possible. Here's a quick way to check your current Python version from your terminal:

      python --version
      # or if you have Python 3 installed as 'python3'
      python3 --version

      And if you need to update Python, the official Python Downloads page is a great place to start.

      If you're still facing issues after checking your Python version, could you please provide more details about the error messages you're seeing? This information can help us pinpoint the problem more accurately. Thanks!

    2. Paula DerrengerUltralytics

      @mirhasnainsiba hi there! 👋 It seems there might be a discrepancy with the distance calculation in your setup. Typically, the distance calculated by the model would depend on the scale set in your system (for example, pixel_per_meter in the example). If the object is being reported as 61m away while it's actually about 1m away, you might want to adjust this scale factor accordingly. Here's a brief example:

      pixel_per_meter = 100  # Adjust this value based on your actual scale

      This adjustment helps calibrate the distance calculation to more accurately reflect real-world distances. If you continue to experience issues, double-check the calibration process or consider revisiting the portion of your code responsible for calculating distances. If further assistance is needed, feel free to reach out! 🛠️

    3. Paula DerrengerUltralytics

      Hey there! 😊 Thanks for reaching out. If you're observing an object distance as 61m while it's almost 1m away, you might want to adjust the pixel_per_meter scaling factor in your VisionEye implementation. This adjustment is crucial for accurate distance calculation.

      Here's a simplified approach:

      pixel_per_meter = 100 # This is just an example value. 
      # You'll need to calibrate this based on your specific setup and camera properties.

      By fine-tuning this variable, you can achieve more accurate distance measurements. Calibration involves comparing known distances with the pixel distances detected by your model to find the most suitable pixel_per_meter value. 🛠️

      Hope this helps! Let us know if you have any further questions or if there are more details you'd like to dive into.

    1. Paula DerrengerUltralytics

      Hey there! 🌟

      The video files used in our examples are not provided in the repository. You can use any video file that you have access to by placing it in an accessible directory and then modifying the "path/to/video/file.mp4" placeholder in the code snippets to point to your video file's location.

      For example:

      cap = cv2.VideoCapture("your/video/path/here.mp4")

      Just replace "your/video/path/here.mp4" with the actual path to your video. If you're looking for sample videos, online resources like Pexels Video or Pixabay Videos offer free footage that you might find useful for your projects.

      If you have any more questions or need further assistance, don't hesitate to reach out. Happy coding! 🚀

      1
    2. Paula DerrengerUltralytics

      Hey! Thank you for checking out the VisionEye Object Mapping with Ultralytics YOLOv8. 🚀 If you're keen to dive into VisionEye Object Mapping for pinpoint precision or even integrate object tracking and distance calculation, the provided Python examples can guide you seamlessly through the process.

      Just remember to replace "path/to/video/file.mp4" with the specific path to your video file, and you’re all set to explore the amazing capabilities of YOLOv8 with VisionEye!

      For pinpoint object mapping:

      model = YOLO("yolov8n.pt")  # Adjust model as needed
      cap = cv2.VideoCapture("your/video/path.mp4")  # Your video path here

      For any additional queries or discussions, feel free to drop a message in our GitHub Issue Section. Happy coding! 🎉

  5. AdadAlShababGitHub

    Hi, I just wanted to know about "VisionEye View with Distance". What does this 'Distance' means? I mean does it measure the distance from the camera to object? Please let me know. TIA.

    1. Paula DerrengerUltralytics(수정됨)

      @AdadAlShabab hey there! 👋

      No, the "Distance" in the VisionEye example is not a camera-to-object distance. It is the pixel distance between the vision point and the detected object's bounding-box centroid, divided by a pixel_per_meter scale that you set and calibrate yourself. Here's a simplified example of how you might calculate distance in a custom script:

      import cv2
      import math
      from ultralytics import YOLO
      
      model = YOLO("yolo26s.pt")
      cap = cv2.VideoCapture("path/to/video.mp4")
      
      while True:
          ret, im0 = cap.read()
          if not ret:
              break
      
          results = model.track(im0, persist=True)
          for box in results[0].boxes.xyxy.cpu():
              # Example: Calculate distance based on object size or position here
              # This is a placeholder for actual distance calculation logic
              distance = calculate_distance(box)
              print(f"Distance: {distance} meters")

      In this example, calculate_distance would be a function you define based on your specific distance estimation method. Keep in mind, accurate distance measurement might require camera calibration and knowing the actual size of the object or using depth sensors in conjunction with the camera.

      Hope this helps! Let us know if you have any more questions. 😊

    2. AdadAlShababGitHub

      Hi @pderrenger. Thanks a lot for your reply. I just wanted to know how can I divide the results by 10 ( ex: distance/10)? I'm dropping the code, please let me know in which line/lines I should make the changes? TIA.

      Code:

      if results[0].boxes.id is not None:
          track_ids = results[0].boxes.id.int().cpu().tolist()
      
          for box, track_id in zip(boxes, track_ids):
              annotator.box_label(box, label=str(track_id), color=bbox_clr)
              annotator.visioneye(box, center_point)
      
              x1, y1 = int((box[0] + box[2]) // 2), int((box[1] + box[3]) // 2)    # Bounding box centroid
      
              distance = (math.sqrt((x1 - center_point[0]) ** 2 + (y1 - center_point[1]) ** 2))/pixel_per_meter
      
              text_size, _ = cv2.getTextSize(f"Distance: {distance:.2f} m", cv2.FONT_HERSHEY_SIMPLEX,1.2, 3)
              cv2.rectangle(im0, (x1, y1 - text_size[1] - 10),(x1 + text_size[0] + 10, y1), txt_background, -1)
              cv2.putText(im0, f"Distance: {distance:.2f} m",(x1, y1 - 5), cv2.FONT_HERSHEY_SIMPLEX, 1.2,txt_color, 3)
    3. Paula DerrengerUltralytics

      Hi @AdadAlShabab! 👋

      To divide the calculated distance by 10, you can adjust the line where distance is calculated. Here's how you can modify it:

      distance = (math.sqrt((x1 - center_point[0]) ** 2 + (y1 - center_point[1]) ** 2)) / pixel_per_meter / 10

      This change will effectively scale down the calculated distance by a factor of 10. Just add / 10 at the end of the existing distance calculation line in your code.

      Hope this helps! Let me know if there's anything else you need. 😊

    4. skp4595GitHub

      what does this mean "It calculates this distance by analyzing the size and position of the object within the frame, using the camera's field of view and other calibration parameters if available"? what do you mean by 'other calibration parameter if possible'? The model is not a blackbox. Is it? there must be some calibration, some ground truth from where model must have learned. please explain this.

    5. skp4595GitHub

      why are we dividing "distance " by 'pixel_per_meter' ? what is the logic or explaination for this ?

    6. Paula DerrengerUltralytics

      Hey there! 👋

      The division by pixel_per_meter is used to convert the measured pixel distance into real-world units like meters. This conversion factor helps translate the scale of the image to actual distances based on how many pixels represent one meter in the image. It's essential for applications where you need to know the physical separation between objects or from the camera to an object, not just the distance in pixels.

      If you have more questions or need further clarification, feel free to ask! 😊

    7. skp4595GitHub

      you mean to say, if there's 1 unit Euclidean distance between two pixels in an image, than it'd be 10m in real world scenarios? And this scale can be adjusted according to our will as per "pixel_per_meter = 10" this code. Isn't it?

      if so, how is this calibration done? where's the ground truth?

    8. Paula DerrengerUltralytics

      Hey there! 👋

      Yes, exactly! If the pixel_per_meter is set to 10, it means that 1 pixel in the image corresponds to 0.1 meters in the real world. You can adjust this scale to fit the specific context or calibration of your camera setup.

      Calibration is typically done by measuring known distances in the real world and adjusting the pixel_per_meter value so that the distances in the image accurately reflect these measurements. Ground truth data for calibration might come from physical measurements or known dimensions within the scene.

      If you have any more questions or need further clarification, feel free to ask! 😊

    9. Paula DerrengerUltralytics(수정됨)

      You're welcome! 😊

      The "VisionEye View with Distance" feature calculates the pixel distance between a reference point and the detected object's centroid, not a true camera-to-object distance. The pixel_per_meter value is used to convert pixel measurements to real-world distances. Calibration involves setting this value based on known distances in your scene.

      To divide the distance by 10, modify the distance calculation line like this:

      distance = (math.sqrt((x1 - center_point[0]) ** 2 + (y1 - center_point[1]) ** 2)) / pixel_per_meter / 10

      For more details, check out the VisionEye guide.

      1
  6. leongjy2005GitHub

    Traceback (most recent call last): File "d:\Random_YOLO8_Tutorials\Human_Detection\visioneye.py", line 28, in annotator.visioneye(box, center_point) ^^^^^^^^^^^^^^^^^^^ AttributeError: 'Annotator' object has no attribute 'visioneye'

    1. Glenn JocherUltralytics(수정됨)

      @leongjy2005 visioneye is not a method of the base Annotator; it lives on SolutionAnnotator. Use from ultralytics.solutions.solutions import SolutionAnnotator and annotator = SolutionAnnotator(im0, line_width=2), or use the solutions.VisionEye solution from the VisionEye guide.

      1