Beginner question: OpenCV Error: Assertion failed, Ros
Ubuntu 18.04 Ros Melodic
in the shell:
python serit.py
the output:
OpenCV Error: Assertion failed (cn <= 4) in scalarToRawData, file /build/opencv-L2vuMj/opencv-3.2.0+dfsg/modules/core/src/matrix.cpp, line 1104
[ERROR] [1651748901.105022]: bad callback: <function func at 0x7fedfaa5f1d0>
Traceback (most recent call last):
File "/opt/ros/melodic/lib/python2.7/dist-packages/rospy/topics.py", line 750, in _invoke_callback
cb(msg)
File "serit.py", line 338, in func
srchap,left_curverad,right_curverad=search_around_poly(blur)
File "serit.py", line 255, in search_around_poly
leftx, lefty, rightx, righty, out_img = find_lane_pixels(image)
File "serit.py", line 195, in find_lane_pixels
cv2.rectangle(out_img, (win_xleft_low, win_y_low), (win_xleft_high, win_y_high), (0, 255, 0), 4)
error: /build/opencv-L2vuMj/opencv-3.2.0+dfsg/modules/core/src/matrix.cpp:1104: error: (-215) cn <= 4 in function scalarToRawData
run without ROS in the VsCode: use /usr/bin/python3
I understand that there is a problem with the python version. If so how can I fix this? ı am new here and Ros.
Thanks in advance
In that function, "cn" is the number of channels per pixel. For example, an RGB image has 3 channels per pixel. So assuming you are using python2, it would appear you are not passing in an acceptable image format.