Convert to greyscale instead of rgb

This commit is contained in:
King_DuckZ 2021-11-01 23:56:44 +01:00
parent eae5f4cfdf
commit 1413f76d2a

View file

@ -48,7 +48,7 @@ int main() {
mgs::ffmpeg::AVCodec avcodec{::AVCodecID::AV_CODEC_ID_MJPEG};
auto cam_frame_format = cam.frame_size();
auto decoder{avcodec.make_decoder(cam_frame_format.width, cam_frame_format.height, ::AVPixelFormat::AV_PIX_FMT_RGB24)};
auto decoder{avcodec.make_decoder(cam_frame_format.width, cam_frame_format.height, ::AVPixelFormat::AV_PIX_FMT_GRAY8)};
print_supported_frame_formats(cam);
cam.start_streaming();
@ -67,7 +67,7 @@ int main() {
std::cout << "Decoded buffer size: " << out_data_size << '\n';
std::ofstream rgb_file_wr("rgb.data", std::ios::binary | std::ios::out);
rgb_file_wr.write(reinterpret_cast<const char*>(buff.data()), buff.size());
rgb_file_wr.write(reinterpret_cast<const char*>(buff.data()), out_data_size);
}
catch (const std::runtime_error& err) {
std::cerr << "Unhandled exception: " << err.what() << '\n';