I’m using this code snippet to access Jetson built-in camera directly through python and OpenCV:
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")
It runs fine on Jetson. But when I run this inside ROS node it gives this error:
OpenCV Error: Sizes of input arguments do not match (The lower bounary is neither an array of the same size and same type as src, nor a scalar) in inRange, file /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/core/src/arithm.cpp, line 2703
Traceback (most recent call last):
File "/home/ubuntu/catkin_ws/src/auto_drive/scripts/traffic_light.py", line 100, in <module>
traffic_light()
File "/home/ubuntu/catkin_ws/src/auto_drive/scripts/traffic_light.py", line 36, in traffic_light
mask_red = cv2.inRange(frame, lower_red, upper_red)
cv2.error: /hdd/buildbot/slave_jetson_tx_3/35-O4T-L4T-R24/opencv/modules/core/src/arithm.cpp:2703: error: (-209) The lower bounary is neither an array of the same size and same type as src, nor a scalar in function inRange
Exception in thread Thread-3 (most likely raised during interpreter shutdown):
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 801, in __bootstrap_inner
File "/usr/lib/python2.7/threading.py", line 754, in run
File "/opt/ros/kinetic/lib/python2.7/dist-packages/rospy/impl/tcpros_base.py", line 154, in run
<type 'exceptions.AttributeError'>: 'NoneType' object has no attribute 'timeout'
The error occurs on this line:
mask_red = cv2.inRange(frame, lower_red, upper_red)