I'm just doing yolo object detection with opencv code snippet:
cap = cv2.VideoCapture("rtsp://admin:asv@123@192.168.1.24:554/main?tcp", cv2.CAP_FFMPEG)
show = True
while show:
ref, img = cap.read()
img = cv2.resize(img, (1024, 720))
img = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
res = model(img)
so, this is a normal code snippet for yolo object detection with opencv and torch
It's working good on with USB webcam, video files etc.
But with the RTSP stream and h264/h265 codec the cv2.VideoCapture() cannot decode it efficiently(at 30 FPS). But if it's on 6 FPS,it can. But I need to do it on 30 FPS.
I saw some documentation, i.e. opencv VideoCapture officially doesn't support h264/h265 codec. so is there any way to decode h264 encoded stream efficiently at 30 FPS in python and the use it to opencv and object detection?
Thanks.