[UTC][media-vision][Non-ACR]Replace deprecated image-util APIs to new one 20/305120/5
authorhjkim <backto.kim@samsung.com>
Mon, 29 Jan 2024 01:37:39 +0000 (10:37 +0900)
committerhjkim <backto.kim@samsung.com>
Mon, 5 Feb 2024 09:27:51 +0000 (18:27 +0900)
Change-Id: I342716f77f7c1d89d5d7d131f18ebd34daaa4986

src/utc/capi-media-vision/CMakeLists.txt
src/utc/capi-media-vision/utc-mv_3d.c
src/utc/capi-media-vision/utc-mv_barcode.c
src/utc/capi-media-vision/utc-mv_face.c
src/utc/capi-media-vision/utc-mv_image.c
src/utc/capi-media-vision/utc-mv_roi_tracker.c
src/utc/capi-media-vision/utc-mv_surveillance.c
src/utc/capi-media-vision/utc-mv_util.c [new file with mode: 0644]
src/utc/capi-media-vision/utc-mv_util.h [new file with mode: 0644]

index a384d71d225534b2008b8f599869c790b7fbda56..a61948cf34c3516f002a07604caa7d0cdfe0fb03 100755 (executable)
@@ -5,12 +5,13 @@ SET(RPM_NAME "core-${PKG_NAME}-tests")
 
 SET(CAPI_LIB "capi-media-vision")
 SET(TC_SOURCES
+    utc-mv_util.c
     utc-mv_common.c
     utc-mv_barcode.c
     utc-mv_face.c
     utc-mv_image.c
     utc-mv_surveillance.c
-       utc-mv_3d.c
+    utc-mv_3d.c
 )
 
 IF( DEFINED TIZENIOT || DEFINED MOBILE || DEFINED WEARABLE)
index 8c78371bff23cb658dc5b6e6b5c38ca851807ce6..adf4201703c8b00d54d47a3c8c3d4bdde6f4b3f3 100644 (file)
@@ -26,7 +26,7 @@
 #include <unistd.h>
 
 #include "tct_common.h"
-#include <image_util.h>
+#include "utc-mv_util.h"
 #include <storage.h>
 #include <system_info.h>
 
@@ -131,58 +131,6 @@ static int set_3d_engine_config(mv_engine_config_h engine_cfg)
        return ret;
 }
 
-static int load_image_to_media_source(const char *file_path, mv_source_h source)
-{
-       if (NULL == file_path || NULL == source) {
-               printf("File path or source is NULL\n");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       unsigned long width = 0;
-       unsigned long height = 0;
-       unsigned long long buffer_size = 0;
-       unsigned char *data_buffer = NULL;
-       int ret1 = IMAGE_UTIL_ERROR_NONE;
-       int ret2 = MEDIA_VISION_ERROR_NONE;
-       image_util_decode_h _decoder = NULL;
-
-       ret1 = image_util_decode_create(&_decoder);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_input_path(_decoder, file_path);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_output_buffer(_decoder, &data_buffer);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_run(_decoder, &width, &height, &buffer_size);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       // Only grayscale and RGB jpegs in test set:
-       mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
-
-       ret2 = mv_source_clear(source);
-       if (ret2 != MEDIA_VISION_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width,
-                                                                       (unsigned int) height, source_colorspace);
-
-_LOAD_IMAGE_FAIL:
-       image_util_decode_destroy(_decoder);
-       if (data_buffer)
-               free(data_buffer);
-
-       assert_eq(IMAGE_UTIL_ERROR_NONE, ret1);
-       assert_eq(MEDIA_VISION_ERROR_NONE, ret2);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
 static void _depth_cb(mv_source_h source, unsigned short *depth, unsigned int width, unsigned int height,
                                          void *user_data)
 {
index 2befc9a952a6dfd4fdf534bfbb54e02a3a4e8189..7792ab2bdf2c6e32324a740f2e65d9e5482cb01b 100644 (file)
@@ -23,7 +23,7 @@
 #include <string.h>
 
 #include "tct_common.h"
-#include <image_util.h>
+#include "utc-mv_util.h"
 #include <json-glib/json-glib.h>
 #include <storage.h>
 #include <system_info.h>
@@ -398,58 +398,6 @@ static int load_raw_file_to_media_source(const char *file_path, mv_source_h sour
        return MEDIA_VISION_ERROR_NONE;
 }
 
-static int load_image_to_media_source(const char *file_path, mv_source_h source)
-{
-       if (NULL == file_path || NULL == source) {
-               printf("File path or source is NULL\n");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       unsigned long width = 0;
-       unsigned long height = 0;
-       unsigned long long buffer_size = 0;
-       unsigned char *data_buffer = NULL;
-       int ret1 = IMAGE_UTIL_ERROR_NONE;
-       int ret2 = MEDIA_VISION_ERROR_NONE;
-       image_util_decode_h _decoder = NULL;
-
-       ret1 = image_util_decode_create(&_decoder);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_input_path(_decoder, file_path);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_output_buffer(_decoder, &data_buffer);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_run(_decoder, &width, &height, &buffer_size);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       // Only grayscale and RGB jpegs in test set:
-       mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
-
-       ret2 = mv_source_clear(source);
-       if (ret2 != MEDIA_VISION_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width,
-                                                                       (unsigned int) height, source_colorspace);
-
-_LOAD_IMAGE_FAIL:
-       image_util_decode_destroy(_decoder);
-       if (data_buffer)
-               free(data_buffer);
-
-       assert_eq(IMAGE_UTIL_ERROR_NONE, ret1);
-       assert_eq(MEDIA_VISION_ERROR_NONE, ret2);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
 void barcode_detected_p_cb(mv_source_h source, mv_engine_config_h engine_cfg, const mv_quadrangle_s *barcode_locations,
                                                   const char *messages[], const mv_barcode_type_e *types, int number_of_barcodes,
                                                   void *user_data)
index 407efaa62787363dc09b2d91aae8ec9dd1ebbe3a..fb30e87387dfb72311ea28cfeb0011bd6103013e 100644 (file)
@@ -23,7 +23,7 @@
 #include <string.h>
 
 #include "tct_common.h"
-#include <image_util.h>
+#include "utc-mv_util.h"
 #include <storage.h>
 #include <system_info.h>
 
@@ -94,57 +94,6 @@ static bool check_model_files(const char *file_name_src, const char *file_name_d
        return ret;
 }
 
-static int load_image_to_media_source(const char *file_path, mv_source_h source)
-{
-       if (NULL == file_path || NULL == source) {
-               printf("File path or source is NULL\n");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       unsigned long width = 0;
-       unsigned long height = 0;
-       unsigned long long buffer_size = 0;
-       unsigned char *data_buffer = NULL;
-       int ret1 = IMAGE_UTIL_ERROR_NONE;
-       int ret2 = MEDIA_VISION_ERROR_NONE;
-       image_util_decode_h _decoder = NULL;
-
-       ret1 = image_util_decode_create(&_decoder);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_input_path(_decoder, file_path);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_output_buffer(_decoder, &data_buffer);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_run(_decoder, &width, &height, &buffer_size);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       // Only grayscale and RGB jpegs in test set:
-       mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
-
-       ret2 = mv_source_clear(source);
-       if (ret2 != MEDIA_VISION_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned long long) buffer_size, (unsigned int) width,
-                                                                       (unsigned int) height, source_colorspace);
-
-_LOAD_IMAGE_FAIL:
-       image_util_decode_destroy(_decoder);
-       if (data_buffer)
-               free(data_buffer);
-
-       assert_eq(IMAGE_UTIL_ERROR_NONE, ret1);
-       assert_eq(MEDIA_VISION_ERROR_NONE, ret2);
-       return MEDIA_VISION_ERROR_NONE;
-}
-
 static int init_examples_by_dir(const char *dir, unsigned int ex_n, mv_source_h **out_examples)
 {
        int err = MEDIA_VISION_ERROR_NONE;
index 2e3cf1fbcb013b3ccc96672e09ef209bd1f5f6ec..5fd9b37a8c03437aa6456e975829509b57aadb49 100644 (file)
@@ -23,7 +23,7 @@
 #include <unistd.h>
 
 #include "tct_common.h"
-#include <image_util.h>
+#include "utc-mv_util.h"
 #include <storage.h>
 #include <system_info.h>
 
@@ -86,63 +86,11 @@ static bool check_image_model_files(const char *file_name_src, const char *file_
        return ret;
 }
 
-static int load_source(const char *file_path, mv_source_h source)
-{
-       if (NULL == file_path || NULL == source) {
-               printf("File path or source is NULL\n");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       unsigned long width = 0;
-       unsigned long height = 0;
-       unsigned long long buffer_size = 0;
-       unsigned char *data_buffer = NULL;
-       int ret1 = IMAGE_UTIL_ERROR_NONE;
-       int ret2 = MEDIA_VISION_ERROR_NONE;
-       image_util_decode_h _decoder = NULL;
-
-       ret1 = image_util_decode_create(&_decoder);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_input_path(_decoder, file_path);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_output_buffer(_decoder, &data_buffer);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_run(_decoder, &width, &height, &buffer_size);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       // Only grayscale and RGB jpegs in test set:
-       mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
-
-       ret2 = mv_source_clear(source);
-       if (ret2 != MEDIA_VISION_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width,
-                                                                       (unsigned int) height, source_colorspace);
-
-_LOAD_IMAGE_FAIL:
-       image_util_decode_destroy(_decoder);
-       if (data_buffer)
-               free(data_buffer);
-
-       assert_eq(IMAGE_UTIL_ERROR_NONE, ret1);
-       assert_eq(MEDIA_VISION_ERROR_NONE, ret2);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
 static int load_tracking_frame(int frame_number, mv_source_h source)
 {
        char frame_path[100] = { 0 };
        snprintf(frame_path, 100, "%s%i%s", tracking_squence_path, frame_number, tracking_frame_type);
-       return load_source(frame_path, source);
+       return load_image_to_media_source(frame_path, source);
 }
 
 /**
@@ -632,7 +580,7 @@ int utc_mediavision_mv_image_recognize_p(void)
        int ret = mv_create_source(&target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
-       ret = load_source(target_image_source_path, target_image);
+       ret = load_image_to_media_source(target_image_source_path, target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
        mv_image_object_h target;
@@ -646,7 +594,7 @@ int utc_mediavision_mv_image_recognize_p(void)
        ret = mv_create_source(&scene_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
-       ret = load_source(scene_image_source_path, scene_image);
+       ret = load_image_to_media_source(scene_image_source_path, scene_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
        bool is_called = false;
@@ -813,7 +761,7 @@ int utc_mediavision_mv_image_object_fill_p(void)
        int ret = mv_create_source(&target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
-       ret = load_source(target_image_source_path, target_image);
+       ret = load_image_to_media_source(target_image_source_path, target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
        mv_image_object_h target;
@@ -1319,7 +1267,7 @@ int utc_mediavision_mv_image_track_p(void)
        int ret = mv_create_source(&target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
-       ret = load_source(target_image_source_path, target_image);
+       ret = load_image_to_media_source(target_image_source_path, target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
        mv_image_object_h target;
@@ -1411,7 +1359,7 @@ int utc_mediavision_mv_image_tracking_model_refresh_p(void)
        int ret = mv_create_source(&target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
-       ret = load_source(target_image_source_path, target_image);
+       ret = load_image_to_media_source(target_image_source_path, target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
        mv_image_object_h target;
@@ -1488,7 +1436,7 @@ int utc_mediavision_mv_image_tracking_model_set_target_p(void)
        int ret = mv_create_source(&target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
-       ret = load_source(target_image_source_path, target_image);
+       ret = load_image_to_media_source(target_image_source_path, target_image);
        assert_eq(MEDIA_VISION_ERROR_NONE, ret);
 
        mv_image_object_h target;
index bd5c07af7fee8e7b6847f6d9b9e4abdc13feb089..7d9f99743269ab4b49383232d56ea8739e878812 100644 (file)
@@ -25,7 +25,7 @@
 #include <unistd.h>
 
 #include "tct_common.h"
-#include <image_util.h>
+#include "utc-mv_util.h"
 #include <storage.h>
 #include <system_info.h>
 
@@ -51,58 +51,6 @@ static int set_roi_tracker_engine_config(mv_engine_config_h engine_cfg)
        return ret;
 }
 
-static int load_image_to_media_source(const char *file_path, mv_source_h source)
-{
-       if (NULL == file_path || NULL == source) {
-               printf("File path or source is NULL\n");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       unsigned long width = 0;
-       unsigned long height = 0;
-       unsigned long long buffer_size = 0;
-       unsigned char *data_buffer = NULL;
-       int ret1 = IMAGE_UTIL_ERROR_NONE;
-       int ret2 = MEDIA_VISION_ERROR_NONE;
-       image_util_decode_h _decoder = NULL;
-
-       ret1 = image_util_decode_create(&_decoder);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_input_path(_decoder, file_path);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_output_buffer(_decoder, &data_buffer);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_run(_decoder, &width, &height, &buffer_size);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       // Only grayscale and RGB jpegs in test set:
-       mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
-
-       ret2 = mv_source_clear(source);
-       if (ret2 != MEDIA_VISION_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width,
-                                                                       (unsigned int) height, source_colorspace);
-
-_LOAD_IMAGE_FAIL:
-       image_util_decode_destroy(_decoder);
-       if (data_buffer)
-               free(data_buffer);
-
-       assert_eq(IMAGE_UTIL_ERROR_NONE, ret1);
-       assert_eq(MEDIA_VISION_ERROR_NONE, ret2);
-
-       return MEDIA_VISION_ERROR_NONE;
-}
-
 /**
  * @function   utc_capi_media_vision_roi_tracker_startup
  * @description        Inference module UTC startup code
index 641681f06fc112a96b24450992abfb27447ac755..75e0c22c3461a3ec3172367c3e6fdac05cb0d776 100644 (file)
@@ -18,8 +18,8 @@
 
 #include "assert.h"
 #include "tct_common.h"
+#include "utc-mv_util.h"
 #include <dirent.h>
-#include <image_util.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <storage.h>
@@ -175,60 +175,6 @@ void utc_capi_media_vision_surveillance_cleanup(void)
        printf("Before return utc_capi_media_vision_surveillance_cleanup\n");
 }
 
-static int load_image_to_media_source(const char *file_path, mv_source_h source)
-{
-       printf("Inside load_image_to_media_source\n");
-       if (NULL == file_path || NULL == source) {
-               printf("File path or source is NULL\n");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
-
-       unsigned long width = 0;
-       unsigned long height = 0;
-       unsigned long long buffer_size = 0;
-       unsigned char *data_buffer = NULL;
-       int ret1 = IMAGE_UTIL_ERROR_NONE;
-       int ret2 = MEDIA_VISION_ERROR_NONE;
-       image_util_decode_h _decoder = NULL;
-
-       ret1 = image_util_decode_create(&_decoder);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_input_path(_decoder, file_path);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_set_output_buffer(_decoder, &data_buffer);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-       ret1 = image_util_decode_run(_decoder, &width, &height, &buffer_size);
-       if (ret1 != IMAGE_UTIL_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       /* Only grayscale and RGB jpegs in test set: */
-       mv_colorspace_e source_colorspace = MEDIA_VISION_COLORSPACE_RGB888;
-
-       ret2 = mv_source_clear(source);
-       if (ret2 != MEDIA_VISION_ERROR_NONE)
-               goto _LOAD_IMAGE_FAIL;
-
-       ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, (unsigned int) width,
-                                                                       (unsigned int) height, source_colorspace);
-
-_LOAD_IMAGE_FAIL:
-       image_util_decode_destroy(_decoder);
-       if (data_buffer)
-               free(data_buffer);
-
-       assert_eq(IMAGE_UTIL_ERROR_NONE, ret1);
-       assert_eq(MEDIA_VISION_ERROR_NONE, ret2);
-
-       printf("Before return load_image_to_media_source\n");
-       return MEDIA_VISION_ERROR_NONE;
-}
-
 void empty_cb(mv_surveillance_event_trigger_h person_appeared_trigger, mv_source_h source, int video_id,
                          mv_surveillance_result_h event_result, void *user_data)
 {
diff --git a/src/utc/capi-media-vision/utc-mv_util.c b/src/utc/capi-media-vision/utc-mv_util.c
new file mode 100644 (file)
index 0000000..e77569e
--- /dev/null
@@ -0,0 +1,70 @@
+/**
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "assert.h"
+
+#include <mv_common.h>
+#include <image_util.h>
+
+int load_image_to_media_source(const char *file_path, mv_source_h source)
+{
+       image_util_decode_h _decoder = NULL;
+       image_util_image_h _decoded_image = NULL;
+       unsigned int width = 0;
+       unsigned int height = 0;
+       size_t buffer_size = 0;
+       unsigned char *data_buffer = NULL;
+       int ret1 = IMAGE_UTIL_ERROR_NONE;
+       int ret2 = MEDIA_VISION_ERROR_NONE;
+
+       if (NULL == file_path || NULL == source) {
+               printf("File path or source is NULL\n");
+               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+       }
+
+       ret1 = image_util_decode_create(&_decoder);
+       if (ret1 != IMAGE_UTIL_ERROR_NONE)
+               goto _LOAD_IMAGE_FAIL;
+       ret1 = image_util_decode_set_input_path(_decoder, file_path);
+       if (ret1 != IMAGE_UTIL_ERROR_NONE)
+               goto _LOAD_IMAGE_FAIL;
+       ret1 = image_util_decode_set_colorspace(_decoder, IMAGE_UTIL_COLORSPACE_RGB888);
+       if (ret1 != IMAGE_UTIL_ERROR_NONE)
+               goto _LOAD_IMAGE_FAIL;
+       ret1 = image_util_decode_run2(_decoder, &_decoded_image);
+       if (ret1 != IMAGE_UTIL_ERROR_NONE)
+               goto _LOAD_IMAGE_FAIL;
+       ret1 = image_util_get_image(_decoder, &width, &height, NULL, &data_buffer, &buffer_size);
+       if (ret1 != IMAGE_UTIL_ERROR_NONE)
+               goto _LOAD_IMAGE_FAIL;
+
+       ret2 = mv_source_clear(source);
+       if (ret2 != MEDIA_VISION_ERROR_NONE)
+               goto _LOAD_IMAGE_FAIL;
+
+       ret2 = mv_source_fill_by_buffer(source, data_buffer, (unsigned int) buffer_size, width,
+                                                                       height, MEDIA_VISION_COLORSPACE_RGB888);
+
+_LOAD_IMAGE_FAIL:
+       image_util_decode_destroy(_decoder);
+       if (data_buffer)
+               free(data_buffer);
+
+       assert_eq(IMAGE_UTIL_ERROR_NONE, ret1);
+       assert_eq(MEDIA_VISION_ERROR_NONE, ret2);
+
+       return MEDIA_VISION_ERROR_NONE;
+}
diff --git a/src/utc/capi-media-vision/utc-mv_util.h b/src/utc/capi-media-vision/utc-mv_util.h
new file mode 100644 (file)
index 0000000..1270393
--- /dev/null
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <mv_common.h>
+
+#ifndef __UTC_MV_UTIL_H__
+#define __UTC_MV_UTIL_H__
+
+int load_image_to_media_source(const char *file_path, mv_source_h source);
+
+#endif // __UTC_MV_UTIL_H__
\ No newline at end of file