简体   繁体   English

Linux 上的 OpenCv + Gstreamer + python

[英]OpenCv + Gstreamer + python on linux

I tell them that I need to implement opencv with Gstreamer Hayo but not how to write with opencv on a pipe gstreamer.我告诉他们我需要用 Gstreamer Hayo 实现 opencv,而不是如何在管道 gstreamer 上用 opencv 编写。 the idea is to take the image and the webcam through OpenCV and process some filters but with GStreamer.这个想法是通过 OpenCV 获取图像和网络摄像头并处理一些过滤器,但使用 GStreamer。

also if I want to tell the VideoCapture () to take data from v4l2src device = / dev / video1, or failing to write it in v4l2src device = / dev / video0 (use linux, and I have a disp virtual video, video0) throws me the following error另外,如果我想告诉 VideoCapture() 从 v4l2src device = /dev/video1 中获取数据,或者无法将其写入 v4l2src device = /dev/video0(使用 linux,并且我有一个 disp 虚拟视频,video0)抛出我出现以下错误

GStreamer: cannot find appsink in manual pipeline in function cvCaptureFromCAM_GStreamer 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()

First, try the following command,首先,尝试以下命令,

gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! ximagesink

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM