

Stop after x (int) frames and save the video in case of streams.

$ python yolo_opencv.py -input rtsp://xxxxx:1935/live/sys.stream -framestart 100 -framelimit 100 -config cfg/yolov3-tiny.cfg -weights yolov3-tiny.weights -classes cfg/yolov3.txt $ python yolo_opencv.py -input sampledata/commuters.mp4 -config cfg/yolov3-tiny.cfg -weights yolov3-tiny.weights -classes cfg/yolov3.txtįor RTSP simply put the RTSP URL as -input Provided all the files are in the current directory, below command will apply object detection on the input image dog.jpg. Note: Python 2.x is not supported YOLO (You Only Look Once)ĭownload the pre-trained YOLO v3 weights file from this link or for tiny weights for slower machines link and place it in the current directory or you can directly download to the current directory in terminal using

Pip install numpy opencv-python imageio-ffmpeg Support for running YOLO/DarkNet has been added to OpenCV dnn module recently. When it comes to object detection, popular detection frameworks are OpenCV dnn module supports running inference on pre-trained deep learning models from popular frameworks like Caffe, Torch and TensorFlow. Recognized objects are stored in date seperated in folders per class for further training or face recognition. Object detection using deep learning with Yolo, OpenCV and Python via Real Time Streaming Protocol ( RTSP) I need something that is more efficient than doing it with opencv.Object Detection with Yolo, OpenCV and Python via Real Time Streaming Protocol (RTSP) If someone have a completely different solution, thats ok. Raw_frame = (width * height * 3)įrame = np.frombuffer(raw_frame, np.uint8).reshape((height, width, 3)) Process = sp.Popen(ffmpeg_cmd, stdout=sp.PIPE) # Release VideoCapture - it was used just for getting video resolution Height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) Width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) # Use OpenCV for getting the video resolution. I'm not completely convinced that my ffmpeg_cmd is correct. "ValueError: cannot reshape array of size 0 into shape (160,240,3)" - So there is no image in the frame. I want to fetch one single image with ffmpeg, but currently im not able to do that.

The drawback here is that ffmpeg opens a whole videostream, so a consequence is that this is not more efficient than opencv. So I'm going with a solution I found here Handle large number of rtsp cameras without real-time constraint My current solution is based on doing that with opencv, but i want to optimize this. Im looking for a way to extract one single image from an rtsp stream.
