简体   繁体   中英

Conversion of Gstreamer launch to OpenCV pipeline for camera OV9281

I'm trying to convert a gst-launch command to opencv pipeline. Using the following gst-launch , I am able to launch the camera,

gst-launch-1.0 v4l2src device="/dev/video0" ! “video/x-raw,width=1280,height=800,format=(string)GRAY8” ! videoconvert ! videoscale ! “video/x-raw,width=640,height=400” ! xvimagesink sync=false

Now I need to convert this into Opencv Pipeline. I tried but I always get the following error:

[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (711) open OpenCV | GStreamer warning: Error opening bin: could not parse caps “video/x-raw, , format=(string)GRAY8” [ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created libpng warning: Image width is zero in IHDR libpng warning: Image height is zero in IHDR libpng error: Invalid IHDR data

This is the pipeline I'm trying to run. I know openCV requires BGR format so,

camSet=‘v4l2src device="/dev/video0" ! “video/x-raw,width=1280,height=800,format=(string)GRAY8” ! videoconvert ! “video/x-raw,width=640,height=400,format=BGRx” ! videoconvert ! video/x-raw, format=BGR ! appsink’
    
    cam = cv2.VideoCapture(camSet, cv2.CAP_GSTREAMER)
    _, frame = cam.read()
    cv2.imwrite(‘test’ +’.png’, frame)
    
    cam.release()

Can anyone assist me with this?

我通过使用解决了它

camSet = ‘v4l2src device=/dev/video0 ! video/x-raw,width=1280,height=800,format=(string)GRAY8 ! videoconvert ! videoscale ! video/x-raw,width=640,height=400,format=BGR ! appsink’

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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