Thanks for detailing! What is the simplest way to convert
void PostProcessingStage::Yuv420ToRgb(uint8_t *dst, const uint8_t *src, StreamInfo &src_info, StreamInfo &dst_info)
into
void PostProcessingStage::Yuv420ToGray(uint8_t *dst, const uint8_t *src, StreamInfo &src_info, StreamInfo &dst_info)
Source code link
https://github.com/raspberrypi/rpicam- ... stage.cpp
Meanwhile I use a dirty hack:
void PostProcessingStage::Yuv420ToRgb(uint8_t *dst, const uint8_t *src, StreamInfo &src_info, StreamInfo &dst_info)
into
void PostProcessingStage::Yuv420ToGray(uint8_t *dst, const uint8_t *src, StreamInfo &src_info, StreamInfo &dst_info)
Source code link
https://github.com/raspberrypi/rpicam- ... stage.cpp
Meanwhile I use a dirty hack:
Code:
std::vector<uint8_t> TfStage::Yuv420ToGray(const uint8_t *src, StreamInfo &src_info){// convert YUV420 frame buffer to RGB outputStreamInfo dst_info;dst_info.width = src_info.width, dst_info.height = src_info.height, dst_info.stride = src_info.width*3;std::vector<uint8_t> output(dst_info.height * dst_info.stride);Yuv420ToRgb(output.data(), src, src_info, dst_info);uint8_t *ptr = (uint8_t *)output.data();// convert RGB buffer to rgb Matcv::Mat rgb = cv::Mat(dst_info.height, dst_info.width, CV_8UC3, ptr, dst_info.stride);cv::Mat gray;// convert RGB Mat to BGR Mat (opencv internal format)cvtColor(rgb, gray, cv::COLOR_RGB2GRAY);std::vector<uint8_t> gray_image(gray.begin<uint8_t>(), gray.end<uint8_t>());return output;}
Statistics: Posted by gftrobots — Tue Jul 23, 2024 12:17 pm