2

I used gstreamer and capture images from network camera by :

gst-launch-1.0 -e rtspsrc location='rtsp://admin:admin@10.0.4.139:554/cam/realmonitor?channel=1&subtype=0' ! rtph264depay ! vpudec ! vpuenc_jpeg ! filesink location=/dev/video_stream0 -v

/dev/video_stream0 is mkfifo but when I want to grab jpeg from OpenCv by code:

import cv2
cap = cv2.VideoCapture('/dev/video_stream0')
#cap = cv2.CreateFileCapture('/dev/video_stream0')
count = 0
while cap.isOpened():
    ret,frame = cap.read()
    cv2.imshow('window-name',frame)
    #cv2.imwrite("frame%d.jpg" % count, frame)
    count = count + 1
    if cv2.waitKey(10) & 0xFF == ord('q'):
        break


cap.release()
cap.destroyAllWindows()

It gives me error

OpenCV Error: Assertion failed (size.width>0 && size.height>0) in imshow, file /home/user/fsl-release-bsp/build-mcd/tmp/work/cortexa9hf-vfp-neon-poky-linux-gnueabi/opencv/2.4.11+gitAUTOINC+2c9547e314-r0/git/modules/highgui/src/window.cpp, line 261

How can I share for example jpegs between gstreamer and OpenCv? If there is simpler way like sharing video stream or emulate camera device I will be gratefull. Thank You

  • can you not test the mkfifo with some other tool? also you can add identity after: `vpuenc_jpeg ! identity silent=false ! filesink -v ...` and check what it dumps out (you should see buffer sizes) .. also when you display it (after dec) with autovideosink it works fine? – nayana Aug 11 '16 at 07:28
  • When i do cat /dev/video_stream0 I see that it works because it display data. – sebastianpszczolka Aug 11 '16 at 12:10
  • hm I think you can test the reading of mkfifo with GStreamer.. the cat dump can theoretically be empty video frames.. btw there are fdsink and fdsrc.. maybe you should use those, also [this](http://stackoverflow.com/a/22384104/3876138) is interesting but with older gstreamer.. and VideoCapture with OpenCV v3+ is [able to open](http://stackoverflow.com/a/23795492/3876138) GStreamer pipeline - isnt this better solution for you? – nayana Aug 12 '16 at 06:54
  • I will try with OpenCV 3.0;) Thank you very much how use fdsink and fdsrc? – sebastianpszczolka Aug 12 '16 at 07:07

0 Answers0