I am trying to achieve results as shown on the video (Method 3 using netcat)https://www.youtube.com/watch?v=sYGdge3T30o
The point is to stream video from raspberry pi to ubuntu PC and process it using openCV and python.
I use command
raspivid -vf -n -w 640 -h 480 -o - -t 0 -b 2000000 | nc 192.168.0.20 5777
to stream the video to my PC and then on the PC I created name pipe 'fifo' and redirected the output
nc -l -p 5777 -v > fifo
then i am trying to read the pipe and display the result in the python script
import cv2
import sysvideo_capture = cv2.VideoCapture(r'fifo')
video_capture.set(cv2.CAP_PROP_FRAME_WIDTH, 640);
video_capture.set(cv2.CAP_PROP_FRAME_HEIGHT, 480);while True:# Capture frame-by-frameret, frame = video_capture.read()if ret == False:passcv2.imshow('Video', frame)if cv2.waitKey(1) & 0xFF == ord('q'):break# When everything is done, release the capture
video_capture.release()
cv2.destroyAllWindows()
However I just end up with an error
[mp3 @ 0x18b2940] Header missing this error is produced by the command video_capture = cv2.VideoCapture(r'fifo')
When I redirect the output of netcat on PC to a file and then reads it in python the video works, however it is speed up by 10 times approximately.
I know the problem is with the python script, because the nc transmission works (to a file) but I am unable to find any clues.
How can I achieve the results as shown on the provided video (method 3) ?