[ITC][media-vision][Non-ACR]Replace deprecated image-util APIs to new one 33/305133/4
authorhjkim <backto.kim@samsung.com>
Mon, 29 Jan 2024 06:18:53 +0000 (15:18 +0900)
committerhjkim <backto.kim@samsung.com>
Mon, 5 Feb 2024 10:32:12 +0000 (19:32 +0900)
Change-Id: I97ff61b81b8a3029b90f829666a7d0742bd584a5

src/itc/media-vision/ITs-media-vision-barcode.c
src/itc/media-vision/ITs-media-vision-common.c
src/itc/media-vision/ITs-media-vision-common.h

index 2fb4d745e18d59b8820f880de1ad87ca8e059aaa..afa82f04dd17190800065f66a99d45a9b3c051c4 100644 (file)
@@ -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;
index 6bfc8abd2263deed31ed8435bcb569fa96bfdd92..bcc38bff8b29feb045c42be5407e8e34fe950d5b 100644 (file)
@@ -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);
index 72832703b6127ac0c9d3ee63ce242d9c1da65bc4..387d624fffa783746aefb36053de83569c860e12 100644 (file)
@@ -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_