ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

TypeError: cannot marshal <type 'numpy.uint8'> objects

asked 2021-05-12 17:43:11 -0500

dee-mikey gravatar image

I am unable to set parameters to the param server using the following code:

hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV)

rospy.set_param("lower_h", hsv[:, :, 0].min()) rospy.set_param("lower_s", hsv[:, :, 1].min()) rospy.set_param("lower_v", hsv[:, :, 2].min())

print('lower_h = {}\nlower_s = {}\nlower_v = {}'.format(hsv[:, :, 0].min(), hsv[:, :, 1].min(), hsv[:, :, 2].min()))

I am getting the following error: TypeError: cannot marshal <type 'numpy.uint8'> objects

In the above code I am able to print the values in the terminal but not set the values in the parameter server. Any help will be appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2021-05-12 19:25:34 -0500

miura gravatar image

There is a difference between uint8 and float64, but it looks like the same cause as this Question. I think converting numpy.uint8 to uint8 by doing the following will solve the problem.

rospy.set_param("lower_h", hsv[:, :, 0].min().item())
rospy.set_param("lower_s", hsv[:, :, 1].min().item())
rospy.set_param("lower_v", hsv[:, :, 2].min().item())
edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2021-05-12 17:43:11 -0500

Seen: 139 times

Last updated: May 12 '21