Skip to content

Commit 8a88ded

Browse files
committed
Enable grayscale encoding in LibavStreamer
1 parent 29e684c commit 8a88ded

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/image_streamer.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff 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

src/libav_streamer.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff 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(

0 commit comments

Comments
 (0)