我告诉他们我需要用 Gstreamer Hayo 实现 opencv,但不需要如何在管道 gstreamer 上用 opencv 编写。这个想法是通过 OpenCV 获取图像和网络摄像头,并使用 GStreamer 处理一些过滤器。
另外,如果我想告诉 VideoCapture() 从 v4l2src device = /dev/video1 获取数据,或者未能将其写入 v4l2src device = /dev/video0(使用 linux,并且我有一个 disp 虚拟视频,video0)抛出我出现以下错误
GStreamer:在函数 cvCaptureFromCAM_GStreamer 的手动管道中找不到 appsink
import cv2
cv2.namedWindow('webCam')
cap = cv2.VideoCapture(1) # "v4l2src device=/dev/video1"
# cap.open("img/bg.avi")
if cap.isOpened():
ret, frame = cap.read()
else:
ret = False
print "problema aqui?"
while True:
#se toma cada frame
ret,frame = cap.read()
frame = cv2.flip(frame,1)
cv2.imshow('webCam', frame)
width = cap.get(cv2.CAP_PROP_FRAME_WIDTH)
height = cap.get(cv2.CAP_PROP_FRAME_HEIGHT)
# cv2.imwrite("/dev/video0", frame)
fourcc = cv2.VideoWriter_fourcc('m','p','4','v')
pathVid = "/dev/video0" # 'img/output2.avi'
# out = cv2.VideoWriter(pathVid, fourcc, 30, (width,height))
out = cv2.VideoWriter(pathVid, fourcc, 30, (640,480))
out.write(frame)
cv2.VideoWr
esc = cv2.waitKey(5) & 0xFF == 27
if esc:
break
cap.release()
cv2.destroyAllWindows()