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

how to get rgb value from sensor_msgs/image

asked 2019-02-07 21:46:34 -0600

Cinnamoroll gravatar image

hello, i need to use rgb value from /camera/color/image_raw topic. i want to know how to get rgb value from this topic. thank you for answer

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2019-02-08 02:53:30 -0600

mali gravatar image

Hi, First you might need to convert the image from ros message image to open cv image using cv_bridge, then use the available functions of Opencv to read color values, like

cv:: Mat image ;
Point3_<uchar>* p =image.ptr< Point3_<uchar> > (y,x);
p->x //B
p->y //R
p->z //G

and probably you can find other methods here

edit flag offensive delete link more


thanks bro !!

Cinnamoroll gravatar image Cinnamoroll  ( 2019-02-22 00:20:24 -0600 )edit

the last question what is a y and x in p =image.ptr< Point3_<uchar> > (y,x) ? width and and height right ?

Cinnamoroll gravatar image Cinnamoroll  ( 2019-02-22 02:57:09 -0600 )edit

yes, x,y are the pixel coordinates (width and height )

mali gravatar image mali  ( 2019-02-22 03:20:56 -0600 )edit

Question Tools


Asked: 2019-02-07 21:46:34 -0600

Seen: 1,757 times

Last updated: Feb 08 '19