# Getting image from usb camera with gstream and opencv

**URL:** <https://forum.opencv.org/t/getting-image-from-usb-camera-with-gstream-and-opencv/4316>\
**Category:** Python\
**Tags:** gstreamer, videoio\
**Created:** [July 13, 2021, 11:00am UTC](https://forum.opencv.org/t/getting-image-from-usb-camera-with-gstream-and-opencv/4316 "2021-07-13T11:00:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![burak2175](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/burak2175/32/2543_2.png) [@burak2175](https://forum.opencv.org/u/burak2175)\
**Post date:** [July 13, 2021, 11:00am UTC](https://forum.opencv.org/t/getting-image-from-usb-camera-with-gstream-and-opencv/4316/1 "2021-07-13T11:00:28Z")

</div>

I want to capture images with opencv videocapture using gstreamer. This pipeline works when I type in terminal.

```auto
gst-launch-1.0 -v v4l2src device=/dev/video0 ! image/jpeg, width =1920, height=1800, framerate=15/1 ! jpegparse !! jpegdec ! videoconvert ! xvimagesing sync = false

```

but when i try the usage method i see from forums, i can’t get image.

```auto
import numpy as np
import cv2

cap = cv2.VideoCapture('gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg, width=1920, height=1080, framerate=15/1 ! jpegparse ! jpegdec ! videoconvert ! xvimagesink sync=false', cv2.CAP_GSTREAMER)

while True:
    ret,frame = cap.read()
    if not ret:
        print('empty frame')
        continue

    cv2.imshow('receive', frame)
    if cv2.waitKey(1)&0xFF == ord('q'):
        break

cap.release()

```

What could be the problem, what am I doing wrong?

---

<div class="post-metadata">

**Author:** ![crackwitz](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.opencv.org/crackwitz/32/14_2.png) [@crackwitz](https://forum.opencv.org/u/crackwitz)\
**Post date:** [July 13, 2021, 2:17pm UTC](https://forum.opencv.org/t/getting-image-from-usb-camera-with-gstream-and-opencv/4316/2 "2021-07-13T14:17:02Z")

</div>

> `xvimagesink `

you can’t just copy a pipeline that “works” in a terminal.

please read up on what `appsink` is.
