File tree Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Expand file tree Collapse file tree 1 file changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -163,9 +163,19 @@ bool GazeboRosRealsense::FillPointCloudHelper(sensor_msgs::PointCloud2 &point_cl
163163 if (this ->image_msg_ .data .size () == rows_arg * cols_arg * 3 )
164164 {
165165 // color
166- iter_rgb[0 ] = image_src[i * 3 + j * cols_arg * 3 + 0 ];
167- iter_rgb[1 ] = image_src[i * 3 + j * cols_arg * 3 + 1 ];
168- iter_rgb[2 ] = image_src[i * 3 + j * cols_arg * 3 + 2 ];
166+ if (this ->image_msg_ .encoding == sensor_msgs::image_encodings::RGB8) {
167+ iter_rgb[2 ] = image_src[i * 3 + j * cols_arg * 3 + 0 ];
168+ iter_rgb[1 ] = image_src[i * 3 + j * cols_arg * 3 + 1 ];
169+ iter_rgb[0 ] = image_src[i * 3 + j * cols_arg * 3 + 2 ];
170+ }
171+ else if (this ->image_msg_ .encoding == sensor_msgs::image_encodings::BGR8) {
172+ iter_rgb[0 ] = image_src[i * 3 + j * cols_arg * 3 + 0 ];
173+ iter_rgb[1 ] = image_src[i * 3 + j * cols_arg * 3 + 1 ];
174+ iter_rgb[2 ] = image_src[i * 3 + j * cols_arg * 3 + 2 ];
175+ }
176+ else {
177+ throw std::runtime_error (" unsupported colour encoding: " + this ->image_msg_ .encoding );
178+ }
169179 }
170180 else if (this ->image_msg_ .data .size () == rows_arg * cols_arg)
171181 {
You can’t perform that action at this time.
0 commit comments