3

I tell them that I need to implement opencv with Gstreamer Hayo but not how to write with opencv on a pipe gstreamer. the idea is to take the image and the webcam through OpenCV and process some filters but with 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

GStreamer: cannot find appsink in manual pipeline in function cvCaptureFromCAM_GStreamer

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()
jota svec
  • 41
  • 1
  • 5
  • This might be helpful for you. In a nutshell, Opencv3 supports gstreamer plugin. http://stackoverflow.com/questions/23570572/using-custom-camera-in-opencv-via-gstreamer – joshsuihn Sep 09 '16 at 17:22
  • thx, but i resolve this problem, make a filter on gstreamer first then i read this filters with opencv. thanks you – jota svec Mar 10 '17 at 15:24

1 Answers1

1

First, try the following command,

gst-launch-1.0 v4l2src device=/dev/video0 ! videoconvert ! ximagesink
Bussller
  • 1,961
  • 6
  • 36
  • 50
Wade Huang
  • 11
  • 1