I have trouble when opening camera with cv::VideoCapture(gst_str, cv::CAP_GSTREAMER)
:
if I use nvjpegdec
In command line
gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 ! image/jpeg,width=1280,height=480 ! nvjpegdec ! xvimagesink
It works well, and the fps is about 50. But if I use it in OpenCV:
std::string gst_str = "v4l2src device=/dev/video0 io-mode=2 ! image/jpeg,width=1280,height=480,framerate=60/1 ! nvjpegdec ! appsink"
the error is:
Bus error(core dump)
if I use jpegdec
In command line
gst-launch-1.0 v4l2src device=/dev/video0 ! image/jpeg,width=1280,height=480 ! jpegdec ! xvimagesink
It also works well, and the fps is about 50, too. But if I use it in OpenCV:
std::string gst_str = "v4l2src device=/dev/video0 io-mode=2 ! image/jpeg,width=1280,height=480,framerate=60/1 ! jpegdec ! appsink"
the error is:
[WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp(1757) handleMessage OpenCV | GStreamer warning: Embedded video playback halted; module v4l2src0 reported: Internal data stream error.
[WARN:0] global /home/nvidia/host/build)opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp(886) open OpenCV | Gstreamer warning: unable to start pipeline
[WARN:0] global /home/nvidia/host/build_opencvnv_opencv/modules/videoio/src/cap_gstreamer.cpp(480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer:pipeline have not been created
If I use nvv4l2decoder
In command line
gst-launch-1.0 v4l2src device=/dev/video0 io-mode=2 ! image/jpeg,width=1280,height=480 framerate=60/1 ! nvv4l2decoder mjpeg=1 ! nvvidconv ! xvimagesink
It can work but the pictures it shows are black and white.
In OpenCV
std::string gst_str = "v4l2src device=/dev/video0 io-mode=2 ! image/jpeg,width=1280,height=480,framerate=60/1 ! nvv4l2decoder mjpeg=1 ! nvvidconv ! appsink"
This time there is no error, and the fps is about 50, but the pictures are black and white. And the command line ouput is:
Opening in BLOCKING MODE
NvMMLiteOpen : Block : BlockType = 277
NVMEDIA: Reading vendor.tegra.display-size : status: 6
NvMMLiteBlockCreate : Block : BlockType = 277
[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=1, value=86, duration=-1
Camera imformations
470-W10DG:~$ v4l2-ctl -d /dev/video0 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'MJPEG' (compressed)
Name : Motion-JPEG
Size: Discrete 640x240
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 960x960
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1264x960
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x960
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 1280x480
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 2560x720
Interval: Discrete 0.017s (60.000 fps)
Size: Discrete 2560x960
Interval: Discrete 0.017s (60.000 fps)
Index : 1
Type : Video Capture
PSixel Format : 'YUYV'
Name : YUYV 4:2:2
Size: Discrete 640x240
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 640x480
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 1280x720
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 960x960
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 1264x960
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 1280x960
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 1280x480
Interval: Discrete 0.100s (10.000 fps)
Size: Discrete 2560x720
Interval: Discrete 0.200s (5.000 fps)
Size: Discrete 2560x960
Interval: Discrete 0.200s (5.000 fps)
More imformation:
Jetpack version: 4.4.1[L4T 32.4.4],
OpenCV: 4.1.1 compiled CUDA: NO
How to capture MJPG in OpenCV on Jeston Nano?