Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 4829

Camera board • Using grayscale image in TfStage

$
0
0
Dear Forum,

we are using grayscale images in our tflite models for performance reasons. In order to integrate our models into the post processing stages, we need to convert the image data into grayscale image data.
This should be done in the method TfStage::runInference(...).

Code:

void TfStage::runInference(){int input = interpreter_->inputs()[0];StreamInfo tf_info;tf_info.width = tf_w_, tf_info.height = tf_h_, tf_info.stride = tf_w_ * 3;std::vector<uint8_t> rgb_image = Yuv420ToRgb(lores_copy_.data(), lores_info_, tf_info);...interpretOutputs();}
Currently you support only the conversion from Yuv420 into RGB. Can you give us a hint of how to modify the method Yuv420ToRgb(...) into Yuv420ToGray(...)? We assume that it could be done as a last processing step of Yuv420ToRgb (example: grayval = factor1 * R0 + factor2 * G0 + factor3 * B0.

Code:

void PostProcessingStage::Yuv420ToRgb(uint8_t *dst, const uint8_t *src, StreamInfo &src_info, StreamInfo &dst_info){       ...       // Any straggling final row is done with extreme steam power.for (; y < dst_info.height; y++){unsigned int x = 0;for (; x < dst_info.width; x++){...*(dst0++) = R0;*(dst0++) = G0;*(dst0++) = B0;}}}

Statistics: Posted by gftrobots — Mon Jul 22, 2024 9:40 am



Viewing all articles
Browse latest Browse all 4829

Trending Articles