Ask Your Question

how to get rgb value from sensor_msgs/image

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

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 -0500

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 -0500 )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 -0500 )edit

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

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


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

Seen: 984 times

Last updated: Feb 08 '19