Convert ROS image to CV2 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
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)
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.