have created a rtsp client in python that receives a h264 stream and returns single h264 raw frames as a binary strings. I am trying to process each h264 frames on-the-fly.
I have unsuccessfully tried several ways to convert this frame into a numpy array for processing.
So far I know that cv2.VideoCapture only accepts a file name as it argument, not a frame neither a StringIO object (file like pointer to a buffer), but I need to pass to it my string.
I have also tried something like:
nparr = np.fromstring(frame_bin_str, np.uint8)
img_np = cv2.imdecode(nparr, cv2.CV_LOAD_IMAGE_COLOR)
tried diferent flags. but also failed miserably.
after many other failed attempts , I ran out of ideas.
To summarize what I need to do: I have a h264 raw frame in a variable and I need to create an openvc valid numpy array of it, or somehow end up with a VideoCapture object containing that single frame, so I can process the frame.
Any pointers would be much appreciated.
Hope this all makes sense.
Thank you in advance