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

CvBridgeError: [8SC1] is not a color format. but [mono8] is. The conversion does not make sense [closed]

asked 2016-01-18 12:01:18 -0600

anonymous user


I'm trying to convert a ROS message of class 'sensor_msgs.msg._Image.Image' to an OpenCV image using Python and cv_bridge. The ROS message encoding is "8SC1", which is a single-channel 8-bit (grayscale) format. However, when I go to use cv_bridge's "imgmsg_to_cv2", I receive the following CvBridgeError:

[8SC1] is not a color format. but [mono8] is. The conversion does not make sense

First of all, this is wrong because mono8 is NOT a color format. I set desired_encoding to "mono8" as this is my desired encoding.

I also tried having desired encoding = "passthrough", but since this gave negative pixel values, I am attempting the mono8 conversion. It should be known that my ROS message is raw disparity values in pixels. I have used imgmsg_to_cv2 on another ROS (color) image message with no problems.

Relevant Python code is below:

import numpy as np
import cv2
import rospy
import std_msgs
from sensor_msgs.msg import Image
from cv_bridge import CvBridge

cv_bridge_object = CvBridge()   

def ROS2OpenCV_disp_converter(input):
    output = cv_bridge_object.imgmsg_to_cv2(input, desired_encoding = "mono8")
    cv2.imshow('Disparity', output)

def stereoCameraSubscriber():
    rospy.Subscriber("/occam/disparity_image0", Image, ROS2OpenCV_disp_converter)

if __name__ == '__main__':
    except rospy.ROSInterruptException:
edit retag flag offensive reopen merge delete

Closed for the following reason question is not relevant or outdated by tfoote
close date 2017-04-20 14:03:13.054724


I had the same issue and fixed it by specifying the desired output format of the conversion to ROS format: cv_bridge.cv2_to_imgmsg(image, 'bgr8')

artifactz gravatar image artifactz  ( 2017-05-30 09:17:48 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2016-10-18 19:28:37 -0600

Yue gravatar image

Hello, did you find why? I'm interested as well. Thank you!

edit flag offensive delete link more


Did you find reason?My question : cv_bridge exception: [16UC1] is not a color format. but [mono16] is. The conversion does not make sense Very samiliar!

lixz123007 gravatar image lixz123007  ( 2019-08-27 05:27:40 -0600 )edit

Question Tools

1 follower


Asked: 2016-01-18 11:58:49 -0600

Seen: 4,349 times

Last updated: Oct 18 '16