+++ /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.
- */
-
-#ifndef __MEDIA_VISION_3D_OPEN_H__
-#define __MEDIA_VISION_3D_OPEN_H__
-
-#include <mv_common.h>
-#include "mv_3d_type.h"
-#include "mv_3d.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @brief Creates mv3d handle.
- * @since_tizen 7.0
- */
-int mv3dCreate(mv_3d_h *mv3d);
-
-/**
- * @brief Destroys mv3d handle and release all its resources.
- * @since_tizen 7.0
- */
-int mv3dDestroy(mv_3d_h mv3d);
-
-/**
- * @brief Configure mv3d handle.
- * @since_tizen 7.0
- */
-int mv3dConfigure(mv_3d_h mv3d, mv_engine_config_h engine_config);
-
-/**
- * @brief Set depth callback to mv3d handle.
- * @since_tizen 7.0
- */
-int mv3dSetDepthCallback(mv_3d_h mv3d, mv_3d_depth_cb depth_cb, void *user_data);
-
-/**
- * @brief Set pointcloud callback to mv3d handle.
- * @since_tizen 7.0
- */
-int mv3dSetPointcloudCallback(mv_3d_h mv3d, mv_3d_pointcloud_cb pointcloud_cb, void *user_data);
-
-/**
- * @brief Prepares mv3d handle.
- * @since_tizen 7.0
- */
-int mv3dPrepare(mv_3d_h mv3d);
-
-/**
- * @brief Gets depth data from source(s).
- * @since_tizen 7.0
- */
-int mv3dRun(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra);
-
-/**
- * @brief Run depth estimation asynchronousely with source(s).
- * @since_tizen 7.0
- */
-int mv3dRunAsync(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra);
-
-/**
- * @brief Write Pointcloud file.
- * @since_tizen 7.0
- */
-int mv3dWritePointcloudFile(mv_3d_h mv3d, mv_3d_pointcloud_h pointcloud, mv_3d_pointcloud_type_e type, char *fileName);
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __MEDIA_VISION_3D_OPEN_H__ */
+++ /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 "mv_private.h"
-#include "mv_3d.h"
-#include "mv_3d_type.h"
-#include "mv_3d_open.h"
-
-/**
- * @file mv_3d.c
- * @brief This file contains Media Vision 3D module.
- */
-
-int mv_3d_create(mv_3d_h *mv3d)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
- MEDIA_VISION_NULL_ARG_CHECK(mv3d);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv3dCreate(mv3d);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_3d_destroy(mv_3d_h mv3d)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(mv3d);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv3dDestroy(mv3d);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_3d_configure(mv_3d_h mv3d, mv_engine_config_h engine_config)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(mv3d);
- MEDIA_VISION_INSTANCE_CHECK(engine_config);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv3dConfigure(mv3d, engine_config);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_3d_set_depth_cb(mv_3d_h mv3d, mv_3d_depth_cb depth_cb, void *user_data)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_3d_depth_check_system_info_feature_supported() &&
- _mv_3d_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(mv3d);
-
- MEDIA_VISION_NULL_ARG_CHECK(depth_cb);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv3dSetDepthCallback(mv3d, depth_cb, user_data);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-// LCOV_EXCL_START
-int mv_3d_set_pointcloud_cb(mv_3d_h mv3d, mv_3d_pointcloud_cb pointcloud_cb, void *user_data)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_3d_pointcloud_check_system_info_feature_supported() &&
- _mv_3d_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(mv3d);
-
- MEDIA_VISION_NULL_ARG_CHECK(pointcloud_cb);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv3dSetPointcloudCallback(mv3d, pointcloud_cb, user_data);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-// LCOV_EXCL_STOP
-
-int mv_3d_prepare(mv_3d_h mv3d)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(mv3d);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv3dPrepare(mv3d);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_3d_run(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra, mv_source_h color)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(mv3d);
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv3dRun(mv3d, source, source_extra);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-int mv_3d_run_async(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra, mv_source_h color)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(mv3d);
- MEDIA_VISION_INSTANCE_CHECK(source);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv3dRunAsync(mv3d, source, source_extra);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-
-// LCOV_EXCL_START
-int mv_3d_pointcloud_write_file(mv_3d_h mv3d, mv_3d_pointcloud_h pointcloud, mv_3d_pointcloud_type_e type,
- char *filename)
-{
- MEDIA_VISION_SUPPORT_CHECK(_mv_3d_pointcloud_check_system_info_feature_supported() &&
- _mv_3d_check_system_info_feature_supported());
- MEDIA_VISION_INSTANCE_CHECK(mv3d);
- MEDIA_VISION_INSTANCE_CHECK(pointcloud);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
- int ret = mv3dWritePointcloudFile(mv3d, pointcloud, type, filename);
-
- MEDIA_VISION_FUNCTION_LEAVE();
-
- return ret;
-}
-// LCOV_EXCL_STOP
--- /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 <new>
+#include <exception>
+#include <cstddef>
+
+#include "mv_private.h"
+#include "mv_common.h"
+#include "mv_3d.h"
+#include "Mv3d.h"
+
+using namespace mediavision::mv3d;
+
+int mv_3d_create(mv_3d_h *mv3d)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
+ MEDIA_VISION_NULL_ARG_CHECK(mv3d);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ try {
+ (*mv3d) = static_cast<mv_3d_h>(new Mv3d());
+ } catch (const std::exception &e) {
+ LOGE("Failed to create mv3d handle with %s", e.what());
+ return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_3d_destroy(mv_3d_h mv3d)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(mv3d);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ delete static_cast<Mv3d *>(mv3d);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv3dSetDepthParameters(mv_3d_h mv3d, mv_engine_config_h engine_config)
+{
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto pMv3d = static_cast<Mv3d *>(mv3d);
+
+ pMv3d->SetParameters(127.5, // threshold
+ 3, // aggregation window width
+ 3, // aggregation window height
+ 0 // speckleSize
+ );
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_3d_configure(mv_3d_h mv3d, mv_engine_config_h engine_config)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(mv3d);
+ MEDIA_VISION_INSTANCE_CHECK(engine_config);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ int mode = MV_3D_DEPTH_MODE_NONE;
+
+ int ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_MODE, &mode);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get depth mode");
+ return ret;
+ }
+
+ ret = mv3dSetDepthParameters(mv3d, engine_config);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to set dfs parameters");
+ return ret;
+ }
+
+ int depthWidth, depthHeight, minDisp, maxDisp;
+ ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_WIDTH, &depthWidth);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get depth width");
+ return ret;
+ }
+
+ ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_HEIGHT, &depthHeight);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get depth height");
+ return ret;
+ }
+
+ if (depthWidth <= 0 || depthHeight <= 0) {
+ LOGE("Invalid depth resolution %d x %d", depthWidth, depthHeight);
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
+
+ ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_MIN_DISPARITY, &minDisp);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get min disparity");
+ return ret;
+ }
+
+ ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_MAX_DISPARITY, &maxDisp);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get max disparity");
+ return ret;
+ }
+
+ double samplingRatio;
+ ret = mv_engine_config_get_double_attribute(engine_config, MV_3D_POINTCLOUD_SAMPLING_RATIO, &samplingRatio);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get stereo configuration file path");
+ return ret;
+ }
+
+ int outlierRemovalPoints;
+ ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_POINTCLOUD_OUTLIER_REMOVAL_POINTS,
+ &outlierRemovalPoints);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get stereo configuration file path");
+ return ret;
+ }
+
+ double outlierRemovalRadius;
+ ret = mv_engine_config_get_double_attribute(engine_config, MV_3D_POINTCLOUD_OUTLIER_REMOVAL_RADIUS,
+ &outlierRemovalRadius);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get stereo configuration file path");
+ return ret;
+ }
+
+ char *stereoConfigFilePath = NULL;
+ ret = mv_engine_config_get_string_attribute(engine_config, MV_3D_DEPTH_STEREO_CONFIG_FILE_PATH,
+ &stereoConfigFilePath);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get stereo configuration file path");
+ return ret;
+ }
+
+ char *pointcloudOutputFilePath = NULL;
+ ret = mv_engine_config_get_string_attribute(engine_config, MV_3D_POINTCLOUD_OUTPUT_FILE_PATH,
+ &pointcloudOutputFilePath);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to get stereo configuration file path");
+ free(stereoConfigFilePath);
+ return ret;
+ }
+
+ auto pMv3d = static_cast<Mv3d *>(mv3d);
+ ret = pMv3d->Configure(mode, static_cast<unsigned int>(depthWidth), static_cast<unsigned int>(depthHeight), minDisp,
+ maxDisp, samplingRatio, outlierRemovalPoints, outlierRemovalRadius, stereoConfigFilePath,
+ pointcloudOutputFilePath);
+
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to configure Depth");
+ }
+
+ free(pointcloudOutputFilePath);
+ pointcloudOutputFilePath = NULL;
+
+ free(stereoConfigFilePath);
+ stereoConfigFilePath = NULL;
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_3d_set_depth_cb(mv_3d_h mv3d, mv_3d_depth_cb depth_cb, void *user_data)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_3d_depth_check_system_info_feature_supported() &&
+ _mv_3d_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(mv3d);
+ MEDIA_VISION_NULL_ARG_CHECK(depth_cb);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto pMv3d = static_cast<Mv3d *>(mv3d);
+ pMv3d->SetDepthCallback(depth_cb, user_data);
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+// LCOV_EXCL_START
+int mv_3d_set_pointcloud_cb(mv_3d_h mv3d, mv_3d_pointcloud_cb pointcloud_cb, void *user_data)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_3d_pointcloud_check_system_info_feature_supported() &&
+ _mv_3d_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(mv3d);
+ MEDIA_VISION_NULL_ARG_CHECK(pointcloud_cb);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto pMv3d = static_cast<Mv3d *>(mv3d);
+ int ret = pMv3d->SetPointcloudCallback(pointcloud_cb, user_data);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to run depth");
+ return ret;
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return MEDIA_VISION_ERROR_NONE;
+}
+// LCOV_EXCL_STOP
+
+int mv_3d_prepare(mv_3d_h mv3d)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(mv3d);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto pMv3d = static_cast<Mv3d *>(mv3d);
+ int ret = pMv3d->Prepare();
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to prepare depth");
+ return ret;
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_3d_run(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra, mv_source_h color)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(mv3d);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto pMv3d = static_cast<Mv3d *>(mv3d);
+
+ int ret = pMv3d->Run(source, source_extra);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to run depth");
+ return ret;
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+int mv_3d_run_async(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra, mv_source_h color)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_3d_all_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(mv3d);
+ MEDIA_VISION_INSTANCE_CHECK(source);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto pMv3d = static_cast<Mv3d *>(mv3d);
+ int ret = pMv3d->RunAsync(source, source_extra);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to run depth");
+ return ret;
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+
+// LCOV_EXCL_START
+int mv_3d_pointcloud_write_file(mv_3d_h mv3d, mv_3d_pointcloud_h pointcloud, mv_3d_pointcloud_type_e type,
+ char *filename)
+{
+ MEDIA_VISION_SUPPORT_CHECK(_mv_3d_pointcloud_check_system_info_feature_supported() &&
+ _mv_3d_check_system_info_feature_supported());
+ MEDIA_VISION_INSTANCE_CHECK(mv3d);
+ MEDIA_VISION_INSTANCE_CHECK(pointcloud);
+ MEDIA_VISION_FUNCTION_ENTER();
+
+ auto pMv3d = static_cast<Mv3d *>(mv3d);
+ int ret = pMv3d->WritePointcloudFile(pointcloud, type, filename);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ LOGE("Failed to write pointcloud file");
+ return ret;
+ }
+
+ MEDIA_VISION_FUNCTION_LEAVE();
+ return ret;
+}
+// LCOV_EXCL_STOP
+++ /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 <new>
-#include <exception>
-#include <cstddef>
-
-#include "mv_private.h"
-#include "mv_common.h"
-#include "mv_3d.h"
-#include "mv_3d_open.h"
-#include "Mv3d.h"
-
-using namespace mediavision::mv3d;
-
-int mv3dCreate(mv_3d_h *mv3d)
-{
- if (!mv3d) {
- LOGE("Handle pointer is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- try {
- (*mv3d) = static_cast<mv_3d_h>(new Mv3d());
- } catch (const std::exception &e) {
- LOGE("Failed to create mv3d handle with %s", e.what());
- return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
- }
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv3dDestroy(mv_3d_h mv3d)
-{
- if (!mv3d) {
- LOGE("Handle is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- delete static_cast<Mv3d *>(mv3d);
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv3dSetDepthParameters(mv_3d_h mv3d, mv_engine_config_h engine_config)
-{
- LOGI("ENTER");
-
- if (!mv3d || !engine_config) {
- LOGE("Handle is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto pMv3d = static_cast<Mv3d *>(mv3d);
-
- pMv3d->SetParameters(127.5, // threshold
- 3, // aggregation window width
- 3, // aggregation window height
- 0 // speckleSize
- );
- LOGI("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-int mv3dConfigure(mv_3d_h mv3d, mv_engine_config_h engine_config)
-{
- LOGI("ENTER");
-
- Mv3d *pMv3d = NULL;
- if (!mv3d || !engine_config) {
- LOGE("Handle is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- int mode = MV_3D_DEPTH_MODE_NONE;
-
- int ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_MODE, &mode);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get depth mode");
- return ret;
- }
-
- ret = mv3dSetDepthParameters(mv3d, engine_config);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to set dfs parameters");
- return ret;
- }
-
- int depthWidth, depthHeight, minDisp, maxDisp;
- ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_WIDTH, &depthWidth);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get depth width");
- return ret;
- }
-
- ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_HEIGHT, &depthHeight);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get depth height");
- return ret;
- }
-
- if (depthWidth <= 0 || depthHeight <= 0) {
- LOGE("Invalid depth resolution %d x %d", depthWidth, depthHeight);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_MIN_DISPARITY, &minDisp);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get min disparity");
- return ret;
- }
-
- ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_DEPTH_MAX_DISPARITY, &maxDisp);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get max disparity");
- return ret;
- }
-
- double samplingRatio;
- ret = mv_engine_config_get_double_attribute(engine_config, MV_3D_POINTCLOUD_SAMPLING_RATIO, &samplingRatio);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get stereo configuration file path");
- return ret;
- }
-
- int outlierRemovalPoints;
- ret = mv_engine_config_get_int_attribute(engine_config, MV_3D_POINTCLOUD_OUTLIER_REMOVAL_POINTS,
- &outlierRemovalPoints);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get stereo configuration file path");
- return ret;
- }
-
- double outlierRemovalRadius;
- ret = mv_engine_config_get_double_attribute(engine_config, MV_3D_POINTCLOUD_OUTLIER_REMOVAL_RADIUS,
- &outlierRemovalRadius);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get stereo configuration file path");
- return ret;
- }
-
- char *stereoConfigFilePath = NULL;
- ret = mv_engine_config_get_string_attribute(engine_config, MV_3D_DEPTH_STEREO_CONFIG_FILE_PATH,
- &stereoConfigFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get stereo configuration file path");
- return ret;
- }
-
- char *pointcloudOutputFilePath = NULL;
- ret = mv_engine_config_get_string_attribute(engine_config, MV_3D_POINTCLOUD_OUTPUT_FILE_PATH,
- &pointcloudOutputFilePath);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to get stereo configuration file path");
- goto out;
- }
-
- pMv3d = static_cast<Mv3d *>(mv3d);
- ret = pMv3d->Configure(mode, static_cast<unsigned int>(depthWidth), static_cast<unsigned int>(depthHeight), minDisp,
- maxDisp, samplingRatio, outlierRemovalPoints, outlierRemovalRadius, stereoConfigFilePath,
- pointcloudOutputFilePath);
-
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to configure Depth");
- goto out;
- }
-
-out:
- free(pointcloudOutputFilePath);
- pointcloudOutputFilePath = NULL;
-
- free(stereoConfigFilePath);
- stereoConfigFilePath = NULL;
-
- LOGI("LEAVE");
-
- return ret;
-}
-
-int mv3dSetDepthCallback(mv_3d_h mv3d, mv_3d_depth_cb depth_cb, void *user_data)
-{
- LOGI("ENTER");
-
- if (!mv3d) {
- LOGE("Handle is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- if (!depth_cb) {
- LOGE("Callback is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto pMv3d = static_cast<Mv3d *>(mv3d);
- pMv3d->SetDepthCallback(depth_cb, user_data);
-
- LOGI("LEAVE");
-
- return MEDIA_VISION_ERROR_NONE;
-}
-
-// LCOV_EXCL_START
-int mv3dSetPointcloudCallback(mv_3d_h mv3d, mv_3d_pointcloud_cb pointcloud_cb, void *user_data)
-{
- LOGI("ENTER");
-
- if (!mv3d) {
- LOGE("Handle is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- if (!pointcloud_cb) {
- LOGE("Callback is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto pMv3d = static_cast<Mv3d *>(mv3d);
- int ret = pMv3d->SetPointcloudCallback(pointcloud_cb, user_data);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to run depth");
- return ret;
- }
-
- LOGI("LEAVE");
- return MEDIA_VISION_ERROR_NONE;
-}
-// LCOV_EXCL_STOP
-
-int mv3dPrepare(mv_3d_h mv3d)
-{
- LOGI("ENTER");
-
- if (!mv3d) {
- LOGE("Handle is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto pMv3d = static_cast<Mv3d *>(mv3d);
- int ret = pMv3d->Prepare();
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to prepare depth");
- return ret;
- }
-
- LOGI("LEAVE");
-
- return ret;
-}
-
-int mv3dRun(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra)
-{
- LOGI("ENTER");
-
- if (!source || !mv3d) {
- LOGE("source[%p], mv3d[%p]", source, mv3d);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto pMv3d = static_cast<Mv3d *>(mv3d);
-
- int ret = pMv3d->Run(source, source_extra);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to run depth");
- return ret;
- }
-
- LOGI("LEAVE");
-
- return ret;
-}
-
-int mv3dRunAsync(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra)
-{
- LOGI("ENTER");
-
- if (!source || !mv3d) {
- LOGE("source[%p], mv3d[%p]", source, mv3d);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto pMv3d = static_cast<Mv3d *>(mv3d);
- int ret = pMv3d->RunAsync(source, source_extra);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to run depth");
- return ret;
- }
-
- LOGI("LEAVE");
-
- return ret;
-}
-
-// LCOV_EXCL_START
-int mv3dWritePointcloudFile(mv_3d_h mv3d, mv_3d_pointcloud_h pointcloud, mv_3d_pointcloud_type_e type, char *fileName)
-{
- LOGI("ENTER");
-
- if (!mv3d) {
- LOGE("Handle is NULL");
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- auto pMv3d = static_cast<Mv3d *>(mv3d);
- int ret = pMv3d->WritePointcloudFile(pointcloud, type, fileName);
- if (ret != MEDIA_VISION_ERROR_NONE) {
- LOGE("Failed to write pointcloud file");
- return ret;
- }
-
- LOGI("LEAVE");
-
- return ret;
-}
-// LCOV_EXCL_STOP