[Python] How can i detect the objects by using a custom-trained RoboFlow data?

Discussão em 'Python' iniciado por Stack, Agosto 18, 2025.

  1. Stack

    Stack Membro Participativo

    I have been working on the detection of the objects based on the my custom-trained RoboFlow data (not yolov8n.pt). My code can open the webcam and take a photo, then it can classify the object by using the created image.

    It works; however, my code overwrites the new image and processes it again. I tried to use real-time webcam data to perform the same task, unfortunately i do not know how to achieve this.

    May you please help me about this issue?

    Thank you,

    import roboflow
    import cv2

    rf = roboflow.Roboflow(api_key="XYZ")
    project = rf.workspace().project("ABC")
    model = project.version(1).model

    cap = cv2.VideoCapture(0)
    cam_control = cap.isOpened()

    prev_frame_time = 0

    while cam_control == True:
    ret,frame = cap.read()
    if ret == False:
    print("Image not found!")
    break

    cv2.imwrite("captured_image.png", frame)

    prediction = model.predict("captured_image.png").json()


    I have tried cv2.imshow, cv2.imread etc., but i could not solve the problem.

    Continue reading...

Compartilhe esta Página