I am unable to capture camera output in opencv.
I can successfully run:
gst-launch-1.0 nvcamerasrc fpsRange=“30.0 30.0” ! ‘video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080, format=(string)I420, framerate=(fraction)30/1’ ! nvtee ! nvvidconv flip-method=2 ! ‘video/x-raw(memory:NVMM), format=(string)I420’ ! nvoverlaysink -e
also I can run
nvgstcapture-1.0 -m 2
But when I use opencv it gives error:
If I use:
cap = cv2.VideoCapture(“nvcamerasrc ! ‘video/x-raw(memory:NVMM), width=(int)640, height=(int)480, format=(string)I420, framerate=(fraction)30/1’ ! nvvidconv flip-method=2 ! ‘video/x-raw, format=(string)I420’ ! videoconvert ! ‘video/x-raw, format=(string)BGR’ ! appsink”)
I get None in frames.
I have also tried to use
cap = cv2.VideoCapture(“nvcamerasrc fpsRange=‘30 30’ ! ‘video/x-raw(memory:NVMM), width=(int)3840, height=(int)2160,format=(string)I420, framerate=(fraction)30/1’ ! nvtee ! nvivafilter cuda-process=true customer-lib-name=‘libnvsample_cudaprocess.so’ ! ‘video/x-raw(memory:NVMM), format=(string)NV12’ ! nvoverlaysink -e! appsink”)
which actually works in command line (I mean without open cv but with gst-launch)
It gives me the error:
appsink: Unable to query number of channels
If I just use :
cap = cv2.VideoCapture(0)
I get blank frames.
I have also tried to set
export LD_PRELOAD=“/usr/lib/aarch64-linux-gnu/libv4l/v4l1compat.so”
and
export LD_PRELOAD=“/usr/lib/libv4l/v4l2convert.so”
I am not sure where the problem is
with same results