Ask Your Question
0

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
1

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

Comments

thanks bro !!

Cinnamoroll gravatar imageCinnamoroll ( 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 imageCinnamoroll ( 2019-02-22 02:57:09 -0600 )edit

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

mali gravatar imagemali ( 2019-02-22 03:20:56 -0600 )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

Stats

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

Seen: 276 times

Last updated: Feb 08