I have the problem when I open a camera with GStreamer, and the camera is not connected, I don't get an error code back from OpenCV. GStreamer returns an error in the console. When I check if the camera is open with .isOpend()
the return value is true
. When the camera is connected, it works without any issue.
std::string pipeline = "nvarguscamerasrc sensor_id=0 ! video/x-raw(memory:NVMM), width=(int)3264, height=(int)2464, format=(string)NV12, framerate=(fraction)21/1 ! nvvidconv flip-method=2 ! video/x-raw, width=(int)3264, height=(int)2464, format=(string)BGRx ! videoconvert ! video/x-raw, format=(string)BGR ! appsink"
cap_device_.open(pipeline, cv::CAP_GSTREAMER);
bool err = cap_device_.isOpened();
if (!err) {
printf("Not possible to open camera");
return EXIT_FAILURE;
}
The GStreamer error code in the console is:
(Argus) Error Timeout: (propagating from src/rpc/socket/client/SocketClientDispatch.cpp, function openSocketConnection(), line 219)
(Argus) Error Timeout: Cannot create camera provider (in src/rpc/socket/client/SocketClientDispatch.cpp, function createCameraProvider(), line 106)
Error generated. /dvs/git/dirty/git-master_linux/multimedia/nvgstreamer/gst-nvarguscamera/gstnvarguscamerasrc.cpp, execute:720 Failed to create CameraProvider
[ 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=0, value=-1, duration=-1
If I understand everything correct, .isOpend()
should return false
. If not, how can I check if the pipeline is initialized correct?
My system runs with Ubuntu 18.04 on an Nvidia Jetson Nano with a MIPI-CSI camera. GStreamer version 1.14.5, OpenCV version 4.1.1
This may just be because of a typo. nvarguscamerasrc has no property sensor_id but has sensor-id. It should work after fixing this.
In not working case, cap.read() should return false.