Vision Basic Follow the line

Hello, I’m doing the unit 3 of this course but I have a problem, when I try to execute the Fourth Step: Get the Centroids, Draw a Circle for the Centroid and Show the Images using two scripts in python( and in the terminal it show me the next error:

[ERROR] [1641497669.657422, 3545.925000]: bad callback: <bound method LineFollower.camera_callback of <main.LineFollower object at 0x7f48581aedc0>>
Traceback (most recent call last):
File “/opt/ros/noetic/lib/python3/dist-packages/rospy/”, line 750, in _invoke_callback
File “/home/user/catkin_ws/src/my_following_line_package/scrips/”, line 33, in camera_callback
crop_img = cv_image[(height)/2+descentre:(height)/2+(descentre+rows_to_watch)][1:width]
TypeError: slice indices must be integers or None or have an index method

^C[INFO] [1641497669.691094, 3545.955000]: shutdown time!
Traceback (most recent call last):
File “/home/user/catkin_ws/src/my_following_line_package/scrips/”, line 115, in
File “/home/user/catkin_ws/src/my_following_line_package/scrips/”, line 110, inmain
File “/opt/ros/noetic/lib/python3/dist-packages/rospy/”, line 103, in sleep
File “/opt/ros/noetic/lib/python3/dist-packages/rospy/”, line 165, in sleep
raise rospy.exceptions.ROSInterruptException(“ROS shutdown request”)
rospy.exceptions.ROSInterruptException: ROS shutdown request

someone have any idea why it happend? I tryed to copy the same code but is the same, thanks so much

Hi, could post the code here so we can check it? Do you continue having this issue? Normally this error could be because you are not getting the image data correctly, but without seeing the code it’s just a wold guess.

Lets us know if you still experience that issue

The problem still exists. The code is the given one in the notebook,

Just solved it by type casting the indices to int.
crop_img = cv_image[int((height)/2+descentre):int((height)/2+(descentre+rows_to_watch))][1:width]


This topic was automatically closed after 3 days. New replies are no longer allowed.