[Python] Using Yolo bounding box yxyx values, how can I obtain/define the induvial values to...

Discussão em 'Python' iniciado por Stack, Janeiro 24, 2025.

  1. Stack

    Stack Membro Participativo

    Thank you in advance for your kind assistance.

    I would like the defined and separate the induvial values of Yolo bounding box yxyx results.

    Here is what i have so far:

    from pyautogui import *
    from ultralytics import YOLO

    model = YOLO('Best.pt') # Load model

    results = model.predict('savedimage.png', conf=0.45)

    for result in results:
    boxes = result.boxes # Boxes object for bounding box outputs
    masks = result.masks # Masks object for segmentation masks outputs
    keypoints = result.keypoints # Keypoints object for pose outputs
    probs = result.probs # Probs object for classification outputs
    obb = result.obb # Oriented boxes object for OBB outputs

    origShapeH = boxes.orig_shape\[0\]
    origShapeW = boxes.orig_shape\[1\]

    print(boxes.xyxy)
    print("Height: ", origShapeH)
    print("Width: ", origShapeW)


    results from above code:

    tensor([[1169.7236, 265.5889, 1392.5630, 499.6911]])
    Height: 900
    Width: 1600


    However I would like to have the following results:

    x1 = 1169.7236
    y1 = 265.5889
    x2 = 1392.5630
    y2 = 499.6911

    Height: 900
    Width: 1600


    Please let me know if you have any questions.

    Continue reading...

Compartilhe esta Página