Convert ROS image to CV2 image

asked 2020-08-28 01:31:17 -0500

Chao Chen gravatar image

The default image type is 32FC1. How to export the image to CV image type? After change the format to 8UC1 and 16 UC1. The result is the same

image description

Here is the code:

count = 0; def callback(ros_image): bridge = CvBridge() cv_image = bridge.imgmsg_to_cv2(ros_image, '8UC1') global count count = count +1 img_title = "image"+str(count)+".jpg" cv2.imwrite(img_title, cv_image)

edit retag flag offensive close merge delete

Comments

I'm not sure on this, but I think you need to multiply every pixel by 255; if your source pixels in ros_image are between 0.0 and 1.0 they may need to be converted to 0 to 255.

KenYN gravatar image KenYN  ( 2020-08-28 02:58:54 -0500 )edit