File tree Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Expand file tree Collapse file tree 2 files changed +7
-5
lines changed Original file line number Diff line number Diff line change @@ -148,10 +148,6 @@ cv::Mat ImageTransportImageStreamer::decodeImage(
148148 cv::Mat_<float > float_image = float_image_bridge;
149149 double max_val;
150150 cv::minMaxIdx (float_image, 0 , &max_val);
151-
152- if (max_val > 0 ) {
153- float_image *= (255 / max_val);
154- }
155151 return float_image;
156152 } else {
157153 // Convert to OpenCV native BGR color
Original file line number Diff line number Diff line change @@ -225,7 +225,13 @@ void LibavStreamer::sendImage(
225225 first_image_time_ = time;
226226 }
227227
228- AVPixelFormat input_coding_format = AV_PIX_FMT_BGR24;
228+ AVPixelFormat input_coding_format;
229+ if (img.channels () == 1 ) {
230+ img.convertTo (img, CV_32FC1);
231+ input_coding_format = AV_PIX_FMT_GRAYF32;
232+ } else {
233+ input_coding_format = AV_PIX_FMT_BGR24;
234+ }
229235
230236 AVFrame * raw_frame = av_frame_alloc ();
231237 av_image_fill_arrays (
You can’t perform that action at this time.
0 commit comments