Код: Выделить всё
# Sender:
gst-launch-1.0 v4l2src ! "video/x-raw,format=YUY2,color-matrix=sdtv,chroma-site=mpeg2,width=(int)320, \
height=(int)240,framerate=(fraction)30/1" ! shmsink socket-path=/tmp/blah shm-size=2000000
# Receiver to verify:
gst-launch-1.0 shmsrc socket-path=/tmp/blah \
! "video/x-raw,format=YUY2,color-matrix=sdtv,chroma-site=mpeg2,width=(int)320,height=(int)240,framerate=(fraction)30/1" \
! queue ! videoconvert ! autovideosink
Код: Выделить всё
import time
import cv2
fps = 30.
frame_width = 320
frame_height = 240
cap = cv2.VideoCapture(0)
cap.set(cv2.CAP_PROP_FRAME_WIDTH, frame_width)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, frame_height)
cap.set(cv2.CAP_PROP_FPS, fps)
gst_str = "appsrc ! \"video/x-raw,format=YUY2,color-matrix=sdtv,chroma-site=mpeg2,width=(int)320, " \
"height=(int)240,framerate=(fraction)30/1\" ! shmsink socket-path=/tmp/blah shm-size=2000000"
# Create VideoWriter as a SHM sink
out = cv2.VideoWriter(gst_str, cv2.CAP_GSTREAMER, fps, (frame_width, frame_height), True)
while True:
ret, frame = cap.read()
if ret:
out.write(frame)
cv2.imshow("Frame", frame)
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
print("Camera error.")
time.sleep(10)
cap.release()
Есть идеи, почему opencv не создает цель shmsink-файл?
Подробнее здесь: https://stackoverflow.com/questions/694 ... hon-opencv