From: hjkim Date: Mon, 29 Jan 2024 06:18:53 +0000 (+0900) Subject: [ITC][media-vision][Non-ACR]Replace deprecated image-util APIs to new one X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=290e59b0362365ac2dc296337a28e1b8b4828df2;p=test%2Ftct%2Fnative%2Fapi.git [ITC][media-vision][Non-ACR]Replace deprecated image-util APIs to new one Change-Id: I97ff61b81b8a3029b90f829666a7d0742bd584a5 --- diff --git a/src/itc/media-vision/ITs-media-vision-barcode.c b/src/itc/media-vision/ITs-media-vision-barcode.c index 2fb4d745e..afa82f04d 100644 --- a/src/itc/media-vision/ITs-media-vision-barcode.c +++ b/src/itc/media-vision/ITs-media-vision-barcode.c @@ -390,62 +390,6 @@ void LoadModels(const char *conf_file_path) g_object_unref(parser); } -/** - * @function LoadImageMediaSource - * @description Load image source - * @parameter const char *file_path, mv_source_h source - * @return Media vision error map value - */ -int LoadImageMediaSource(const char *file_path, mv_source_h source) -{ - if (NULL == file_path || NULL == source) { - FPRINTF("[Line : %d][%s] File path or source is NULL\n", __LINE__, API_NAMESPACE); - return MEDIA_VISION_ERROR_INVALID_PARAMETER; - } - - unsigned long nWidth = 0; - unsigned long nHeight = 0; - unsigned long long nBufSize = 0; - unsigned char *pszDataBuf = NULL; - int nRet1 = IMAGE_UTIL_ERROR_NONE; - int nRet2 = MEDIA_VISION_ERROR_NONE; - image_util_decode_h hDecoder = NULL; - - nRet1 = image_util_decode_create(&hDecoder); - PRINT_RESULT(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_create", ImageUtilGetError(nRet1)); - CHECK_HANDLE(&hDecoder, "image_util_decode_create"); - nRet1 = image_util_decode_set_input_path(hDecoder, file_path); - PRINT_RESULT_CLEANUP(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_set_input_path", ImageUtilGetError(nRet1), - image_util_decode_destroy(hDecoder)); - nRet1 = image_util_decode_set_colorspace(hDecoder, IMAGE_UTIL_COLORSPACE_RGB888); - PRINT_RESULT_CLEANUP(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_set_colorspace", ImageUtilGetError(nRet1), - image_util_decode_destroy(hDecoder)); - nRet1 = image_util_decode_set_output_buffer(hDecoder, &pszDataBuf); - PRINT_RESULT_CLEANUP(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_set_output_buffer", ImageUtilGetError(nRet1), - image_util_decode_destroy(hDecoder)); - nRet1 = image_util_decode_run(hDecoder, &nWidth, &nHeight, &nBufSize); - PRINT_RESULT_CLEANUP(IMAGE_UTIL_ERROR_NONE, nRet1, "image_util_decode_run", ImageUtilGetError(nRet1), - image_util_decode_destroy(hDecoder); - FREE_MEMORY(pszDataBuf)); - - // Only grayscale and RGB jpegs in test set: - mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888; - - nRet2 = mv_source_clear(source); - PRINT_RESULT_CLEANUP(MEDIA_VISION_ERROR_NONE, nRet2, "mv_source_clear", MediaVisionGetError(nRet2), - image_util_decode_destroy(hDecoder); - FREE_MEMORY(pszDataBuf)); - nRet2 = mv_source_fill_by_buffer(source, pszDataBuf, (unsigned int) nBufSize, (unsigned int) nWidth, - (unsigned int) nHeight, source_colorspace); - PRINT_RESULT_CLEANUP(MEDIA_VISION_ERROR_NONE, nRet2, "mv_source_fill_by_buffer", MediaVisionGetError(nRet2), - image_util_decode_destroy(hDecoder); - FREE_MEMORY(pszDataBuf)); - - image_util_decode_destroy(hDecoder); - FREE_MEMORY(pszDataBuf); - return MEDIA_VISION_ERROR_NONE; -} - /** * @function CreateAndGetEngineAttributes * @description Create Engine and get supported attributes @@ -707,9 +651,9 @@ int ITc_mv_barcode_detect_p(void) int nIndex = 0, nRet = -1; for (nIndex = 0; nIndex < nDetectModelLength; ++nIndex) { - nRet = LoadImageMediaSource(DetectModel[nIndex].image_path, g_hMvSource); - PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "LoadImageMediaSource", MediaVisionGetError(nRet)); - FPRINTF("[Line : %d][%s] LoadImageMediaSource done successfully\n", __LINE__, API_NAMESPACE); + nRet = image_load(DetectModel[nIndex].image_path, g_hMvSource); + PRINT_RESULT(MEDIA_VISION_ERROR_NONE, nRet, "image_load", MediaVisionGetError(nRet)); + FPRINTF("[Line : %d][%s] image_load done successfully\n", __LINE__, API_NAMESPACE); mv_rectangle_s roi; roi.point.x = 0; diff --git a/src/itc/media-vision/ITs-media-vision-common.c b/src/itc/media-vision/ITs-media-vision-common.c index 6bfc8abd2..bcc38bff8 100644 --- a/src/itc/media-vision/ITs-media-vision-common.c +++ b/src/itc/media-vision/ITs-media-vision-common.c @@ -377,11 +377,12 @@ int image_load(const char *file_path, mv_source_h source) return MEDIA_VISION_ERROR_INVALID_PARAMETER; } - unsigned long width = 0; - unsigned long height = 0; - unsigned long long buffer_size = 0; + unsigned int width = 0; + unsigned int height = 0; + size_t buffer_size = 0; unsigned char *data_buffer = NULL; image_util_decode_h hDecoder = NULL; + image_util_image_h _decoded_image = NULL; int ret = image_util_decode_create(&hDecoder); if (IMAGE_UTIL_ERROR_NONE != ret) { @@ -408,18 +409,18 @@ int image_load(const char *file_path, mv_source_h source) FPRINTF("[Line : %d][%s] image_util_decode_set_colorspace Failed\n", __LINE__, API_NAMESPACE); return ret; } - ret = image_util_decode_set_output_buffer(hDecoder, &data_buffer); + ret = image_util_decode_run2(hDecoder, &_decoded_image); if (IMAGE_UTIL_ERROR_NONE != ret) { ret = image_util_decode_destroy(hDecoder); if (IMAGE_UTIL_ERROR_NONE != ret) { FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\n", __LINE__, API_NAMESPACE); return ret; } - FPRINTF("[Line : %d][%s] image_util_decode_set_output_buffer Failed\n", __LINE__, API_NAMESPACE); + FPRINTF("[Line : %d][%s] image_util_decode_run2 Failed\n", __LINE__, API_NAMESPACE); return ret; } - ret = image_util_decode_run(hDecoder, &width, &height, &buffer_size); + ret = image_util_get_image(hDecoder, &width, &height, NULL, &data_buffer, &buffer_size); if (IMAGE_UTIL_ERROR_NONE != ret) { if (data_buffer) { free(data_buffer); @@ -430,12 +431,10 @@ int image_load(const char *file_path, mv_source_h source) FPRINTF("[Line : %d][%s] image_util_decode_destroy Failed\n", __LINE__, API_NAMESPACE); return ret; } - FPRINTF("[Line : %d][%s] image_util_decode_run Failed\n", __LINE__, API_NAMESPACE); + FPRINTF("[Line : %d][%s] image_util_get_image Failed\n", __LINE__, API_NAMESPACE); return ret; } - mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888; - ret = mv_source_clear(source); if (MEDIA_VISION_ERROR_NONE != ret) { if (data_buffer) { @@ -451,7 +450,7 @@ int image_load(const char *file_path, mv_source_h source) return ret; } - ret = mv_source_fill_by_buffer(source, data_buffer, buffer_size, width, height, source_colorspace); + ret = mv_source_fill_by_buffer(source, data_buffer, buffer_size, width, height, MEDIA_VISION_COLORSPACE_RGB888); if (MEDIA_VISION_ERROR_NONE != ret) { if (data_buffer) { free(data_buffer); diff --git a/src/itc/media-vision/ITs-media-vision-common.h b/src/itc/media-vision/ITs-media-vision-common.h index 72832703b..387d624ff 100644 --- a/src/itc/media-vision/ITs-media-vision-common.h +++ b/src/itc/media-vision/ITs-media-vision-common.h @@ -300,5 +300,7 @@ bool CreateMediaPacket(void); bool DestroyMediaPacket(void); bool CreateFilledMediaSource(void); char *ImageUtilGetError(int nRet); +int image_load(const char *file_path, mv_source_h source); + /** @} */ #endif //_ITS_MEDIA_VISION_COMMON_H_