--- /dev/null
+/**
+ * Copyright (c) 2022 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_3d.h>
+#include <mv_3d_type.h>
+
+#include <glib.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+
+#include <image_util.h>
+#include <system_info.h>
+#include <storage.h>
+#include "tct_common.h"
+
+#define FILE_PATH_SIZE 1024
+#define API_NAMESPACE "[MediaVision]"
+#define MV3D_BASE_IMAGE_FILENAME "im0.jpeg"
+#define MV3D_EXTRA_IMAGE_FILENAME "im1.jpeg"
+#define MV3D_CALIBRATION_FILENAME "calibOcv.yaml"
+#define MV3D_POINTCLOUD_OUT_FILENAME "test.pcd"
+#define MV3D_DEPTH_FEATURE "http://tizen.org/feature/vision.3d.depth"
+#define MV3D_POINTCLOUD_FEATURE "http://tizen.org/feature/vision.3d.pointcloud"
+#define MV3D_DEPTH_WIDTH 718
+#define MV3D_DEPTH_HEIGHT 496
+#define MV3D_MINIMUN_DISPARITY 8
+#define MV3D_MAXIMUM_DISPARITY 65
+#define MV3D_SAMPLING_RATIO 0.01
+#define MV3D_OUTLIER_REMOVAL_POINTS 3
+#define MV3D_OUTLIER_REMOVAL_RAIDUS 0.5
+#define TIMEOUT_CB 5000
+
+GMainLoop *g_MainLoop = NULL;
+int g_nTimeoutId;
+
+const char *gMv3dExampleDir = NULL;
+static bool gIsMv3dSupported = false;
+static bool gIsMv3dDepthSupported = false;
+static bool gIsMv3dPointCloudSupported = false;
+static int gStartupError;
+
+static mv_engine_config_h gEngineConfigHandle = NULL;
+static mv_source_h gBaseSourceHandle = NULL;
+static mv_source_h gExtraSourceHandle = NULL;
+static bool gMv3dDepthCallBackInvoked = false;
+static bool gMv3dPointCloudCallBackInvoked = false;
+static int gMv3dPcdWriteResultErr;
+static gboolean TimeoutFunction(gpointer data)
+{
+ GMainLoop *pMainLoop = NULL;
+ pMainLoop = (GMainLoop *)data;
+ if (pMainLoop != NULL)
+ g_main_loop_quit(pMainLoop);
+
+ return false;
+}
+
+#define RUN_POLLING_LOOP {\
+ g_MainLoop = g_main_loop_new(NULL, false); \
+ g_nTimeoutId = g_timeout_add(TIMEOUT_CB, TimeoutFunction, g_MainLoop); \
+ g_main_loop_run(g_MainLoop); \
+ g_source_remove(g_nTimeoutId); \
+ g_MainLoop = NULL; \
+ g_nTimeoutId = 0; \
+}
+
+#define QUIT_GMAIN_LOOP { \
+ if (g_MainLoop) { \
+ g_main_loop_quit(g_MainLoop); \
+ g_MainLoop = NULL; \
+ } \
+}
+
+static int set_3d_engine_config(mv_engine_config_h engine_cfg)
+{
+ int ret = mv_engine_config_set_int_attribute(
+ engine_cfg, MV_3D_DEPTH_MODE, MV_3D_DEPTH_MODE_STEREO);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(
+ engine_cfg, MV_3D_DEPTH_WIDTH, MV3D_DEPTH_WIDTH);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(
+ engine_cfg, MV_3D_DEPTH_HEIGHT, MV3D_DEPTH_HEIGHT);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(
+ engine_cfg, MV_3D_DEPTH_MIN_DISPARITY, MV3D_MINIMUN_DISPARITY);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(
+ engine_cfg, MV_3D_DEPTH_MAX_DISPARITY, MV3D_MAXIMUM_DISPARITY);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ char calibFilename[FILE_PATH_SIZE];
+ snprintf(calibFilename, FILE_PATH_SIZE, "%s/%s", gMv3dExampleDir, MV3D_CALIBRATION_FILENAME);
+ ret = mv_engine_config_set_string_attribute(
+ engine_cfg, MV_3D_DEPTH_STEREO_CONFIG_FILE_PATH, calibFilename);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_double_attribute(
+ engine_cfg, MV_3D_POINTCLOUD_SAMPLING_RATIO, MV3D_SAMPLING_RATIO);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_int_attribute(
+ engine_cfg, MV_3D_POINTCLOUD_OUTLIER_REMOVAL_POINTS, MV3D_OUTLIER_REMOVAL_POINTS);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_engine_config_set_double_attribute(
+ engine_cfg, MV_3D_POINTCLOUD_OUTLIER_REMOVAL_RADIUS, MV3D_OUTLIER_REMOVAL_RAIDUS);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ char mediaFilename[FILE_PATH_SIZE];
+ snprintf(mediaFilename, FILE_PATH_SIZE, "%s", "/tmp");
+ ret = mv_engine_config_set_string_attribute(
+ engine_cfg, MV_3D_POINTCLOUD_OUTPUT_FILE_PATH, mediaFilename);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ 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)
+{
+ gMv3dDepthCallBackInvoked = true;
+ QUIT_GMAIN_LOOP;
+}
+
+static void _pointcloud_cb(mv_source_h source,
+ mv_3d_pointcloud_h pointcloud,
+ void *user_data)
+{
+ gMv3dPointCloudCallBackInvoked = true;
+}
+
+/**
+ * @function utc_capi_media_vision_3d_startup
+ * @description 3d module UTC startup code
+ * @parameter NA
+ * @return NA
+ */
+void utc_capi_media_vision_3d_startup(void)
+{
+ printf("capi-media-vision 3d tests STARTUP is launched\n");
+
+ system_info_get_platform_bool(MV3D_DEPTH_FEATURE, &gIsMv3dDepthSupported);
+ system_info_get_platform_bool(MV3D_POINTCLOUD_FEATURE, &gIsMv3dPointCloudSupported);
+
+ if (gIsMv3dDepthSupported || gIsMv3dPointCloudSupported)
+ gIsMv3dSupported = true;
+ else
+ gIsMv3dSupported = false;
+
+ char pszValue[CONFIG_VALUE_LEN_MAX] = {0,};
+ if (true == GetValueForTCTSetting("DEVICE_SUITE_TARGET_30", pszValue, API_NAMESPACE)) {
+ PRINT_UTC_LOG("[Line : %d][%s] 'DEVICE_SUITE_TARGET_30' Values Received %s\\n", __LINE__, API_NAMESPACE, pszValue);
+
+ gMv3dExampleDir=(char*)calloc(strlen(pszValue)+strlen("/res/res/3d")+1, sizeof(char));
+ snprintf(gMv3dExampleDir, strlen(pszValue)+strlen("/res/res/3d")+1, "%s/res/res/3d", pszValue);
+
+ } else {
+ PRINT_UTC_LOG("[Line : %d][%s] GetValueForTCTSetting returned error for 'DEVICE_SUITE_TARGET_30'\\n", __LINE__, API_NAMESPACE);
+ }
+
+ gStartupError = mv_create_engine_config(&gEngineConfigHandle);
+ if (MEDIA_VISION_ERROR_NONE != gStartupError) {
+ gEngineConfigHandle = NULL;
+ printf("mv_engine_config_h create is failed\n");
+ return;
+ }
+
+ printf("capi-media-vision 3d tests STARTUP is completed\n");
+}
+
+/**
+ * @function utc_capi_media_vision_3d_cleanup
+ * @description 3d module UTC cleanup code
+ * @parameter NA
+ * @return NA
+ */
+void utc_capi_media_vision_3d_cleanup(void)
+{
+ printf("capi-media-vision 3d tests CLEANUP is launched\n");
+
+ if (gEngineConfigHandle) {
+ mv_destroy_engine_config(gEngineConfigHandle);
+ gEngineConfigHandle = NULL;
+ }
+
+ if (gBaseSourceHandle) {
+ mv_destroy_source(gBaseSourceHandle);
+ gBaseSourceHandle = NULL;
+ }
+
+ if (gExtraSourceHandle) {
+ mv_destroy_source(gExtraSourceHandle);
+ gExtraSourceHandle = NULL;
+ }
+ printf("capi-media-vision 3d tests CLEANUP is completed\n");
+}
+
+/**
+ * @brief Positive test case of mv_3d_create()
+ * @testcase utc_mediavision_mv_3d_create_p
+ * @since_tizen 7.0
+ * @description Create 3d handle
+ */
+int utc_mediavision_mv_3d_create_p(void)
+{
+ printf("mv_3d_create_p\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_create_p pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_3d_create()
+ * @testcase utc_mediavision_mv_3d_create_n
+ * @since_tizen 7.0
+ * @description Create 3d handle,
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_3d_create_n(void)
+{
+ printf("mv_3d_create_n\n");
+
+ int ret = mv_3d_create(NULL);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("mv_3d_create_n pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_3d_destroy()
+ * @testcase utc_mediavision_mv_3d_destroy_p
+ * @since_tizen 7.0
+ * @description Destroy 3d handle
+ */
+int utc_mediavision_mv_3d_destroy_p(void)
+{
+ printf("mv_3d_destroy_p\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_destroy_p pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_3d_destroy()
+ * @testcase utc_mediavision_mv_3d_destroy_n
+ * @since_tizen 7.0
+ * @description Destroy 3d handle,
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_3d_destroy_n(void)
+{
+ printf("mv_3d_destroy_n\n");
+
+ int ret = mv_3d_destroy(NULL);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("mv_3d_destroy_n pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_3d_configure()
+ * @testcase utc_mediavision_mv_3d_configure_p
+ * @since_tizen 7.0
+ * @description Configure 3d handle
+ */
+int utc_mediavision_mv_3d_configure_p(void)
+{
+ printf("mv_3d_configure_p\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_configure_p pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_3d_configure()
+ * @testcase utc_mediavision_mv_3d_configure_n
+ * @since_tizen 7.0
+ * @description Configure 3d handle,
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_3d_configure_n(void)
+{
+ printf("mv_3d_configure_n\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(NULL, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_3d_configure(mv3d_handle, NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_configure_n pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_3d_set_depth_cb()
+ * @testcase utc_mediavision_mv_3d_set_depth_cb_p
+ * @since_tizen 7.0
+ * @description Set depth callback to 3d handle
+ */
+int utc_mediavision_mv_3d_set_depth_cb_p(void)
+{
+ printf("mv_3d_set_depth_cb_p\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, _depth_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_set_depth_cb_p pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_3d_set_depth_cb()
+ * @testcase utc_mediavision_mv_3d_set_depth_cb_n
+ * @since_tizen 7.0
+ * @description Set depth callback to 3d handle,
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_3d_set_depth_cb_n(void)
+{
+ printf("mv_3d_set_depth_cb_n\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, NULL, NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_3d_set_depth_cb(NULL, _depth_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_set_depth_cb_n pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_3d_set_pointcloud_cb()
+ * @testcase utc_mediavision_mv_3d_set_pointcloud_cb_p
+ * @since_tizen 7.0
+ * @description Set pointcloud callback to 3d handle
+ */
+int utc_mediavision_mv_3d_set_pointcloud_cb_p(void)
+{
+ printf("mv_3d_set_pointcloud_cb_p\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_cb, mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_set_pointcloud_cb_p pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_3d_set_pointcloud_cb()
+ * @testcase utc_mediavision_mv_3d_set_pointcloud_cb_n
+ * @since_tizen 7.0
+ * @description Set pointcloud callback to 3d handle,
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_3d_set_pointcloud_cb_n(void)
+{
+ printf("mv_3d_set_pointcloud_cb_n\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, NULL, NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_3d_set_pointcloud_cb(NULL, _pointcloud_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_set_pointcloud_cb_n pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_3d_prepare()
+ * @testcase utc_mediavision_mv_3d_prepare_p
+ * @since_tizen 7.0
+ * @description Prepare 3d handle
+ */
+int utc_mediavision_mv_3d_prepare_p(void)
+{
+ printf("mv_3d_prepare_p\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, _depth_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_cb, mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_prepare(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_prepare_p pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_3d_prepare()
+ * @testcase utc_mediavision_mv_3d_prepare_n1
+ * @since_tizen 7.0
+ * @description Prepare 3d handle,
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_3d_prepare_n1(void)
+{
+ printf("mv_3d_prepare_n1\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, _depth_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_cb, mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_prepare(NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_prepare_n1 pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_3d_prepare()
+ * @testcase utc_mediavision_mv_3d_prepare_n2
+ * @since_tizen 7.0
+ * @description Prepare 3d handle,
+ * but fail because mv_3d_prepare() calls before mv_3d_configure()
+ */
+int utc_mediavision_mv_3d_prepare_n2(void)
+{
+ printf("mv_3d_prepare_n2\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, _depth_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_cb, mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_prepare(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_OPERATION, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_prepare_n2 pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_3d_run()
+ * @testcase utc_mediavision_mv_3d_run_p
+ * @since_tizen 7.0
+ * @description Run 3d handle
+ */
+int utc_mediavision_mv_3d_run_p(void)
+{
+ printf("mv_3d_run_p\n");
+
+ char baseImageFilename[FILE_PATH_SIZE];
+ snprintf(baseImageFilename, 1024, "%s/%s", gMv3dExampleDir, MV3D_BASE_IMAGE_FILENAME);
+ int ret = mv_create_source(&gBaseSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = load_image_to_media_source(baseImageFilename, gBaseSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ char extraImageFilename[FILE_PATH_SIZE];
+ snprintf(extraImageFilename, 1024, "%s/%s", gMv3dExampleDir, MV3D_EXTRA_IMAGE_FILENAME);
+ ret = mv_create_source(&gExtraSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = load_image_to_media_source(extraImageFilename, gExtraSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ mv_3d_h mv3d_handle = NULL;
+ ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, _depth_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_cb, mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_prepare(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_run(mv3d_handle, gBaseSourceHandle, gExtraSourceHandle, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+ assert_eq(true, gMv3dDepthCallBackInvoked);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_run_p pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_3d_run()
+ * @testcase utc_mediavision_mv_3d_run_n
+ * @since_tizen 7.0
+ * @description Run 3d handle,
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_3d_run_n(void)
+{
+ printf("mv_3d_run_n1\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, _depth_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_cb, mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_prepare(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_run(mv3d_handle, NULL, NULL, NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_run_n pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_3d_run_async()
+ * @testcase utc_mediavision_mv_3d_run_async_p
+ * @since_tizen 7.0
+ * @description Run 3d handle asynchronously
+ */
+int utc_mediavision_mv_3d_run_async_p(void)
+{
+ printf("mv_3d_run_p\n");
+
+ char baseImageFilename[FILE_PATH_SIZE];
+ snprintf(baseImageFilename, 1024, "%s/%s", gMv3dExampleDir, MV3D_BASE_IMAGE_FILENAME);
+ int ret = mv_create_source(&gBaseSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = load_image_to_media_source(baseImageFilename, gBaseSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ char extraImageFilename[FILE_PATH_SIZE];
+ snprintf(extraImageFilename, 1024, "%s/%s", gMv3dExampleDir, MV3D_EXTRA_IMAGE_FILENAME);
+ ret = mv_create_source(&gExtraSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = load_image_to_media_source(extraImageFilename, gExtraSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ mv_3d_h mv3d_handle = NULL;
+ ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, _depth_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_cb, mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_prepare(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_run_async(mv3d_handle, gBaseSourceHandle, gExtraSourceHandle, NULL);
+ RUN_POLLING_LOOP;
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+ assert_eq(true, gMv3dDepthCallBackInvoked);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_run_p pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Negative test case of mv_3d_run_async()
+ * @testcase utc_mediavision_mv_3d_run_async_n
+ * @since_tizen 7.0
+ * @description Run 3d handle asynchronously
+ * but fail because input parameter is NULL
+ */
+int utc_mediavision_mv_3d_run_async_n(void)
+{
+ printf("mv_3d_run_async_n\n");
+
+ mv_3d_h mv3d_handle = NULL;
+ int ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, _depth_cb, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_cb, mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_prepare(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_run_async(mv3d_handle, NULL, NULL, NULL);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("mv_3d_run_async_n pass\n");
+
+ return 0;
+}
+
+static void _depth_cb1(mv_source_h source,
+ unsigned short* depth,
+ unsigned int width,
+ unsigned int height,
+ void* user_data)
+{
+ gMv3dDepthCallBackInvoked = true;
+}
+
+static void _pointcloud_cb1(mv_source_h source,
+ mv_3d_pointcloud_h pointcloud,
+ void *user_data)
+{
+ gMv3dPointCloudCallBackInvoked = true;
+ mv_3d_h mv3d_handle = (mv_3d_h)user_data;
+
+ char outfilename[FILE_PATH_SIZE];
+ snprintf(outfilename, 1024, "/tmp/%s", gMv3dExampleDir, MV3D_POINTCLOUD_OUT_FILENAME);
+ gMv3dPcdWriteResultErr = mv_3d_pointcloud_write_file(
+ mv3d_handle,
+ pointcloud,
+ MV_3D_POINTCLOUD_TYPE_PCD_BIN,
+ MV3D_POINTCLOUD_OUT_FILENAME);
+}
+
+/**
+ * @brief Positive test case of mv_3d_pointcloud_write_file()
+ * @testcase utc_mediavision_mv_3d_pointcloud_write_file_p
+ * @since_tizen 7.0
+ * @description Write pointcloud file
+ */
+int utc_mediavision_mv_3d_pointcloud_write_file_p(void)
+{
+ printf("utc_mediavision_mv_3d_pointcloud_write_file_p\n");
+
+ char baseImageFilename[FILE_PATH_SIZE];
+ snprintf(baseImageFilename, 1024, "%s/%s", gMv3dExampleDir, MV3D_BASE_IMAGE_FILENAME);
+ int ret = mv_create_source(&gBaseSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = load_image_to_media_source(baseImageFilename, gBaseSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ char extraImageFilename[FILE_PATH_SIZE];
+ snprintf(extraImageFilename, 1024, "%s/%s", gMv3dExampleDir, MV3D_EXTRA_IMAGE_FILENAME);
+ ret = mv_create_source(&gExtraSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = load_image_to_media_source(extraImageFilename, gExtraSourceHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ mv_3d_h mv3d_handle = NULL;
+ ret = mv_3d_create(&mv3d_handle);
+ if (!gIsMv3dSupported) {
+ assert_eq(ret, MEDIA_VISION_ERROR_NOT_SUPPORTED);
+ return 0;
+ }
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ assert_eq(gStartupError, MEDIA_VISION_ERROR_NONE);
+
+ assert_eq(set_3d_engine_config(gEngineConfigHandle), MEDIA_VISION_ERROR_NONE);
+
+ ret = mv_3d_configure(mv3d_handle, gEngineConfigHandle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_depth_cb(mv3d_handle, _depth_cb1, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_set_pointcloud_cb(mv3d_handle, _pointcloud_cb1, mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_prepare(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ ret = mv_3d_run(mv3d_handle, gBaseSourceHandle, gExtraSourceHandle, NULL);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+ assert_eq(true, gMv3dDepthCallBackInvoked);
+ assert_eq(MEDIA_VISION_ERROR_NONE, gMv3dPcdWriteResultErr);
+
+ ret = mv_3d_destroy(mv3d_handle);
+ assert_eq(MEDIA_VISION_ERROR_NONE, ret);
+
+ printf("utc_mediavision_mv_3d_pointcloud_write_file_p pass\n");
+
+ return 0;
+}
+
+/**
+ * @brief Positive test case of mv_3d_pointcloud_write_file()
+ * @testcase utc_mediavision_mv_3d_pointcloud_write_file_n
+ * @since_tizen 7.0
+ * @description Write pointcloud file,
+ * fail because input parameter is NULL
+ */
+int utc_mediavision_mv_3d_pointcloud_write_file_n(void)
+{
+ printf("utc_mediavision_mv_3d_pointcloud_write_file_n\n");
+
+ char outfilename[FILE_PATH_SIZE];
+ snprintf(outfilename, 1024, "%s/%s", gMv3dExampleDir, MV3D_POINTCLOUD_OUT_FILENAME);
+ int ret = mv_3d_pointcloud_write_file(NULL,
+ NULL,
+ MV_3D_POINTCLOUD_TYPE_PCD_BIN,
+ outfilename);
+ assert_eq(MEDIA_VISION_ERROR_INVALID_PARAMETER, ret);
+
+ printf("utc_mediavision_mv_3d_pointcloud_write_file_n pass\n");
+
+ return 0;
+}
\ No newline at end of file