diff options
Diffstat (limited to 'source/application/main/UseCaseCommonUtils.cc')
-rw-r--r-- | source/application/main/UseCaseCommonUtils.cc | 16 |
1 files changed, 15 insertions, 1 deletions
diff --git a/source/application/main/UseCaseCommonUtils.cc b/source/application/main/UseCaseCommonUtils.cc index d740d10..67e784b 100644 --- a/source/application/main/UseCaseCommonUtils.cc +++ b/source/application/main/UseCaseCommonUtils.cc @@ -91,6 +91,20 @@ bool image::PresentInferenceResult( return true; } +void image::RgbToGrayscale(const uint8_t *srcPtr, uint8_t *dstPtr, const size_t dstImgSz) +{ + float R=0.299; + float G=0.587; + float B=0.114; + for (size_t i = 0; i < dstImgSz; ++i, srcPtr += 3) { + uint32_t int_gray = R * (*srcPtr) + + G * (*(srcPtr + 1)) + + B * (*(srcPtr + 2)); + *dstPtr++ = int_gray <= std::numeric_limits<uint8_t>::max() ? + int_gray : std::numeric_limits<uint8_t>::max(); + } +} + void IncrementAppCtxIfmIdx(arm::app::ApplicationContext& ctx, std::string useCase) { #if NUMBER_OF_FILES > 0 @@ -227,4 +241,4 @@ bool ListFilesHandler(ApplicationContext& ctx) } } /* namespace app */ -} /* namespace arm */
\ No newline at end of file +} /* namespace arm */ |