pistreaming icon indicating copy to clipboard operation
pistreaming copied to clipboard

Error on OpenCV

Open 541380000 opened this issue 7 years ago • 1 comments

Dear author: After successfully installing Pistreaming on my RaspiberryPi, I can now watch the video by 192.168.137.2:8082 in my browser. But when I try to use it in the opencv, I failed to open the camera by VideoCapture video; video.open(192.168.137.2:8082); So how can I get the video in OpenCV?

541380000 avatar Mar 18 '18 08:03 541380000

This is basically a duplicate of #26...

OpenCV usually relies on local V4L (Video4Linux) devices for video capture. This is a considerably different thing to an MPEG1 stream over a websocket (which is what pistreaming provides). I've no idea if OpenCV can open a network stream directly; it can open a file so there's a possibility it might work with something like a FIFO or a UNIX socket (through which the stream is re-directed), but if it wants to seek within the file that obviously won't work.

If you're looking to perform operations in OpenCV on the stream you're probably better off passing the unencoded frames from the camera straight to OpenCV within the script (with an option to drop frames if processing gets behind). The BroadcastOutput.write method is what receives unencoded frames (currently in YUV420 format, you may want BGR for OpenCV instead but be warned that will double the frame size and the ffmpeg sub-process will need adjusting accordingly). You could send the data from there through a queue to something else wanting to process it (don't try and do processing within the write method; it's expected to return fast as it's running within the camera's thread).

waveform80 avatar Mar 18 '18 16:03 waveform80