I just add an camera ros package to handle csi camera with below commands
sudo apt-get install ros-noetic-cv-camera
When I launch the package it failed, any one knows how to fix this issue?
$ rosrun cv_camera cv_camera_node
[ WARN:0] global ../modules/videoio/src/cap.cpp (163) open VIDEOIO(GSTREAMER): trying capture cameraNum=0 ...
(cv_camera_node:14209): GStreamer-CRITICAL **: 12:58:10.268:
Trying to dispose element pipeline0, but it is in PAUSED instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (888) open OpenCV | GStreamer warning: unable to start pipeline
(cv_camera_node:14209): GStreamer-CRITICAL **: 12:58:10.269:
Trying to dispose element videoconvert0, but it is in PLAYING instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (480) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created
(cv_camera_node:14209): GStreamer-CRITICAL **: 12:58:10.269:
Trying to dispose element appsink0, but it is in READY instead of the NULL state.
You need to explicitly set elements to the NULL state before
dropping the final reference, to allow them to clean up.
This problem may also be caused by a refcounting bug in the
application or some element.
[ WARN:0] global ../modules/videoio/src/cap.cpp (183) open VIDEOIO(GSTREAMER): can't create capture
[ WARN:0] global ../modules/videoio/src/cap.cpp (163) open VIDEOIO(V4L2): trying capture cameraNum=0 ...
(cv_camera_node:14209): GStreamer-CRITICAL **: 12:58:10.280: gst_element_post_message: assertion 'GST_IS_ELEMENT (element)' failed
[ WARN:0] global ../modules/videoio/src/cap.cpp (174) open VIDEOIO(V4L2): created, isOpened=1
Hi,
In the sample width,height,framerate is set to 1920x1080p30. Probably your camera source does not support this mode. Please check which modes your camera support and configure width,height,framerate to fit the mode.
daniel@nvidia:~/Test$ python3 test.py
GST_ARGUS: Creating output stream
CONSUMER: Waiting until producer is connected...
GST_ARGUS: Available Sensor modes :
GST_ARGUS: 3280 x 2464 FR = 21.000000 fps Duration = 47619048 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 3280 x 1848 FR = 28.000001 fps Duration = 35714284 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1920 x 1080 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1640 x 1232 FR = 29.999999 fps Duration = 33333334 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: 1280 x 720 FR = 59.999999 fps Duration = 16666667 ; Analog Gain range min 1.000000, max 10.625000; Exposure Range min 13000, max 683709000;
GST_ARGUS: Running with following settings:
Camera index = 0
Camera mode = 2
Output Stream W = 1920 H = 1080
seconds to Run = 0
Frame Rate = 29.999999
GST_ARGUS: Setup Complete, Starting captures for 0 seconds
GST_ARGUS: Starting repeat capture requests.
CONSUMER: Producer has connected; continuing.
[ WARN:0] global ../modules/videoio/src/cap_gstreamer.cpp (935) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
^CTraceback (most recent call last):
File "test.py", line 19, in <module>
read_cam()
File "test.py", line 11, in read_cam
cv2.waitKey(10)
KeyboardInterrupt
GST_ARGUS: Cleaning up
CONSUMER: Done Success
GST_ARGUS: Done Success
daniel@nvidia:~/Test$ cat test.py
import sys
import cv2
def read_cam():
cap = cv2.VideoCapture("nvarguscamerasrc ! video/x-raw(memory:NVMM), width=(int)1920, height=(int)1080,format=(string)NV12, framerate=(fraction)30/1 ! nvvidconv ! video/x-raw, format=(string)BGRx ! videoconvert ! appsink")
if cap.isOpened():
cv2.namedWindow("demo", cv2.WINDOW_AUTOSIZE)
while True:
ret_val, img = cap.read();
cv2.imshow('demo',img)
cv2.waitKey(10)
else:
print("camera open failed")
cv2.destroyAllWindows()
if __name__ == '__main__':
read_cam()