experiencor / keras-yolo2

Easy training on custom dataset. Various backends (MobileNet and SqueezeNet) supported. A YOLO demo to detect raccoon run entirely in brower is accessible at https://git.io/vF7vI (not on Windows).
MIT License
1.73k stars 787 forks source link

How to test on a live video stream #421

Open vismayaps opened 5 years ago

vismayaps commented 5 years ago

I have trained on my dataset and weights are generated. I want to test the model on a live video stream connected to a camera and display the live results. Any help would be appreciated.

LuanBaviloni commented 4 years ago

If you want to use a webcam, you can replace:

    video_reader = cv2.VideoCapture(image_path)

with:

    video_reader = cv2.VideoCapture(0)

or if you want to use a RTSP transmission, you could use something like this:

    video_reader = cv2.VideoCapture("rtsp://username:password@ip:port/cam/realmonitor?channel=1&subtype=1")

and inside the for loop, you can use this code below to show the image:

    cv2.imshow("video", image)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

Read more: https://docs.opencv.org/2.4/modules/highgui/doc/reading_and_writing_images_and_video.html