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)
#include <unistd.h>
#include "tct_common.h"
-#include <image_util.h>
+#include "utc-mv_util.h"
#include <storage.h>
#include <system_info.h>
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)
{
#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>
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)
#include <string.h>
#include "tct_common.h"
-#include <image_util.h>
+#include "utc-mv_util.h"
#include <storage.h>
#include <system_info.h>
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;
#include <unistd.h>
#include "tct_common.h"
-#include <image_util.h>
+#include "utc-mv_util.h"
#include <storage.h>
#include <system_info.h>
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);
}
/**
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;
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;
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;
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;
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;
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;
#include <unistd.h>
#include "tct_common.h"
-#include <image_util.h>
+#include "utc-mv_util.h"
#include <storage.h>
#include <system_info.h>
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
#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>
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)
{
--- /dev/null
+/**
+ * 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;
+}
--- /dev/null
+/**
+ * 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