diff options
author | Isabella Gottardi <isabella.gottardi@arm.com> | 2022-01-27 16:39:37 +0000 |
---|---|---|
committer | Kshitij Sisodia <kshitij.sisodia@arm.com> | 2022-02-08 16:32:28 +0000 |
commit | 3107aa2152de9be8317e62da1d0327bcad6552e2 (patch) | |
tree | 2ba12a5dd39f28ae1b646e132fbe575c6a442ee9 /source/application/main | |
parent | 5cdfa9b834dc5a94c70f9f2b1f5c849dc5439e85 (diff) | |
download | ml-embedded-evaluation-kit-3107aa2152de9be8317e62da1d0327bcad6552e2.tar.gz |
MLECO-2873: Object detection usecase follow-up
Change-Id: Ic14e93a50fb7b3f3cfd9497bac1280794cc0fc15
Signed-off-by: Isabella Gottardi <isabella.gottardi@arm.com>
Diffstat (limited to 'source/application/main')
-rw-r--r-- | source/application/main/UseCaseCommonUtils.cc | 16 | ||||
-rw-r--r-- | source/application/main/include/UseCaseCommonUtils.hpp | 10 |
2 files changed, 24 insertions, 2 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 */ diff --git a/source/application/main/include/UseCaseCommonUtils.hpp b/source/application/main/include/UseCaseCommonUtils.hpp index c91dc4a..84b5de3 100644 --- a/source/application/main/include/UseCaseCommonUtils.hpp +++ b/source/application/main/include/UseCaseCommonUtils.hpp @@ -57,7 +57,15 @@ namespace image{ **/ bool PresentInferenceResult(hal_platform & platform, const std::vector < arm::app::ClassificationResult > & results); - } + + /** + * @brief Converts RGB image to grayscale. + * @param[in] srcPtr Pointer to RGB source image. + * @param[out] dstPtr Pointer to grayscale destination image. + * @param[in] imgSz Destination image size. + **/ + void RgbToGrayscale(const uint8_t *srcPtr, uint8_t *dstPtr, const size_t dstImgSz); +} /** * @brief Helper function to increment current input feature vector index. |