mv_3d: Drop open functions
authorKwanghoon Son <k.son@samsung.com>
Wed, 30 Aug 2023 06:46:08 +0000 (15:46 +0900)
committerKwanghoon Son <k.son@samsung.com>
Mon, 4 Sep 2023 05:01:05 +0000 (14:01 +0900)
[Issue type] refactoring

3d open functions was created for individual adapter layer
requirements, but was never used. Delete it because it slows down
execution and only increases complexity.

Change-Id: I1ad39ece35e808a4fde2f5f9bc32bf342bbb1153
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
mv_3d/3d/include/mv_3d_open.h [deleted file]
mv_3d/3d/src/mv_3d.c [deleted file]
mv_3d/3d/src/mv_3d.cpp [moved from mv_3d/3d/src/mv_3d_open.cpp with 66% similarity]

diff --git a/mv_3d/3d/include/mv_3d_open.h b/mv_3d/3d/include/mv_3d_open.h
deleted file mode 100644 (file)
index 9d572e5..0000000
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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__ */
diff --git a/mv_3d/3d/src/mv_3d.c b/mv_3d/3d/src/mv_3d.c
deleted file mode 100644 (file)
index 36a9d5a..0000000
+++ /dev/null
@@ -1,167 +0,0 @@
-/**
- * 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
similarity index 66%
rename from mv_3d/3d/src/mv_3d_open.cpp
rename to mv_3d/3d/src/mv_3d.cpp
index fbc93ef..ee37176 100644 (file)
 #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)
+int mv_3d_create(mv_3d_h *mv3d)
 {
-       if (!mv3d) {
-               LOGE("Handle pointer is NULL");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
+       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());
@@ -40,29 +38,25 @@ int mv3dCreate(mv_3d_h *mv3d)
                return MEDIA_VISION_ERROR_OUT_OF_MEMORY;
        }
 
+       MEDIA_VISION_FUNCTION_LEAVE();
        return MEDIA_VISION_ERROR_NONE;
 }
 
-int mv3dDestroy(mv_3d_h mv3d)
+int mv_3d_destroy(mv_3d_h mv3d)
 {
-       if (!mv3d) {
-               LOGE("Handle is NULL");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
+       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)
 {
-       LOGI("ENTER");
-
-       if (!mv3d || !engine_config) {
-               LOGE("Handle is NULL");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
+       MEDIA_VISION_FUNCTION_ENTER();
 
        auto pMv3d = static_cast<Mv3d *>(mv3d);
 
@@ -71,20 +65,17 @@ int mv3dSetDepthParameters(mv_3d_h mv3d, mv_engine_config_h engine_config)
                                                 3, // aggregation window height
                                                 0 // speckleSize
        );
-       LOGI("LEAVE");
 
+       MEDIA_VISION_FUNCTION_LEAVE();
        return MEDIA_VISION_ERROR_NONE;
 }
 
-int mv3dConfigure(mv_3d_h mv3d, mv_engine_config_h engine_config)
+int mv_3d_configure(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;
-       }
+       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;
 
@@ -166,67 +157,52 @@ int mv3dConfigure(mv_3d_h mv3d, mv_engine_config_h engine_config)
                                                                                                &pointcloudOutputFilePath);
        if (ret != MEDIA_VISION_ERROR_NONE) {
                LOGE("Failed to get stereo configuration file path");
-               goto out;
+               free(stereoConfigFilePath);
+               return ret;
        }
 
-       pMv3d = static_cast<Mv3d *>(mv3d);
+       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");
-               goto out;
        }
 
-out:
        free(pointcloudOutputFilePath);
        pointcloudOutputFilePath = NULL;
 
        free(stereoConfigFilePath);
        stereoConfigFilePath = NULL;
 
-       LOGI("LEAVE");
-
+       MEDIA_VISION_FUNCTION_LEAVE();
        return ret;
 }
 
-int mv3dSetDepthCallback(mv_3d_h mv3d, mv_3d_depth_cb depth_cb, void *user_data)
+int mv_3d_set_depth_cb(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;
-       }
+       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);
 
-       LOGI("LEAVE");
-
+       MEDIA_VISION_FUNCTION_LEAVE();
        return MEDIA_VISION_ERROR_NONE;
 }
 
 // LCOV_EXCL_START
-int mv3dSetPointcloudCallback(mv_3d_h mv3d, mv_3d_pointcloud_cb pointcloud_cb, void *user_data)
+int mv_3d_set_pointcloud_cb(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;
-       }
+       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);
@@ -235,19 +211,16 @@ int mv3dSetPointcloudCallback(mv_3d_h mv3d, mv_3d_pointcloud_cb pointcloud_cb, v
                return ret;
        }
 
-       LOGI("LEAVE");
+       MEDIA_VISION_FUNCTION_LEAVE();
        return MEDIA_VISION_ERROR_NONE;
 }
 // LCOV_EXCL_STOP
 
-int mv3dPrepare(mv_3d_h mv3d)
+int mv_3d_prepare(mv_3d_h mv3d)
 {
-       LOGI("ENTER");
-
-       if (!mv3d) {
-               LOGE("Handle is NULL");
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
+       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();
@@ -256,19 +229,16 @@ int mv3dPrepare(mv_3d_h mv3d)
                return ret;
        }
 
-       LOGI("LEAVE");
-
+       MEDIA_VISION_FUNCTION_LEAVE();
        return ret;
 }
 
-int mv3dRun(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra)
+int mv_3d_run(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra, mv_source_h color)
 {
-       LOGI("ENTER");
-
-       if (!source || !mv3d) {
-               LOGE("source[%p], mv3d[%p]", source, mv3d);
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
+       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);
 
@@ -278,19 +248,16 @@ int mv3dRun(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra)
                return ret;
        }
 
-       LOGI("LEAVE");
-
+       MEDIA_VISION_FUNCTION_LEAVE();
        return ret;
 }
 
-int mv3dRunAsync(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra)
+int mv_3d_run_async(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra, mv_source_h color)
 {
-       LOGI("ENTER");
-
-       if (!source || !mv3d) {
-               LOGE("source[%p], mv3d[%p]", source, mv3d);
-               return MEDIA_VISION_ERROR_INVALID_PARAMETER;
-       }
+       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);
@@ -299,30 +266,28 @@ int mv3dRunAsync(mv_3d_h mv3d, mv_source_h source, mv_source_h source_extra)
                return ret;
        }
 
-       LOGI("LEAVE");
-
+       MEDIA_VISION_FUNCTION_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)
+int mv_3d_pointcloud_write_file(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;
-       }
+       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);
+       int ret = pMv3d->WritePointcloudFile(pointcloud, type, filename);
        if (ret != MEDIA_VISION_ERROR_NONE) {
                LOGE("Failed to write pointcloud file");
                return ret;
        }
 
-       LOGI("LEAVE");
-
+       MEDIA_VISION_FUNCTION_LEAVE();
        return ret;
 }
 // LCOV_EXCL_STOP