Add FocusFinder class as dummy 39/317339/4
authorTae-Young Chung <ty83.chung@samsung.com>
Mon, 9 Sep 2024 06:14:30 +0000 (15:14 +0900)
committerInki Dae <inki.dae@samsung.com>
Mon, 9 Sep 2024 07:35:22 +0000 (07:35 +0000)
As the first commit for FocusFinder,
FocusFinder class is added to Service and
FocusFinderTest for Create and Destroy is added as gtest.

Details implementation codes will be added with next patches.

Change-Id: I981612aee1ef9767af6f1cb4f497abaaf1058d6d
Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
common/include/SingleoCommonTypes.h
packaging/singleo.spec
services/CMakeLists.txt
services/focus_finder/CMakeLists.txt [new file with mode: 0644]
services/focus_finder/include/FocusFinder.h [new file with mode: 0644]
services/focus_finder/src/FocusFinder.cpp [new file with mode: 0644]
test/services/CMakeLists.txt
test/services/test_focusfinder_dummy.cpp [new file with mode: 0644]

index d885552ff79fbd1fb8df662780f4b45afc691005..268b2caad2a978aa6690623f32ce74fe5d31087b 100644 (file)
@@ -218,7 +218,7 @@ struct FrResultType : public BaseResultType {
        }
 };
 
-enum class ServiceType { NONE, AUTO_ZOOM };
+enum class ServiceType { NONE, AUTO_ZOOM, FOCUS_FINDER };
 
 enum class InputFeedType { NONE, CAMERA, SCREEN_CAPTURE };
 
index 76800fbe2ade663d4de8f0801a5f1fde9b779a2f..5b77619d1c61fecb533a05df1ef5d3be82eb6dbb 100644 (file)
@@ -57,6 +57,7 @@ MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'`
          -DUSE_EXTERNAL_INFERENCE_SERVICE=OFF \
          -DUSE_INPUT_OPENCV_BACKEND=ON \
          -DUSE_AUTOZOOM_API=ON \
+         -DUSE_FOCUSFINDER_API=ON \
          -DUSE_INPUT_CAMERA_API_BACKEND=ON
 
 make %{?jobs:-j%jobs}
index 6df9aa956aad0ae1f58d7c1353eda0c832e3dcb7..c4ad0f19092551a4ea9b2467d410855ce90fe2d6 100644 (file)
@@ -16,6 +16,10 @@ IF (${USE_AUTOZOOM_API})
     INCLUDE(auto_zoom/CMakeLists.txt)
 ENDIF()
 
+IF (${USE_FOCUSFINDER_API})
+    INCLUDE(focus_finder/CMakeLists.txt)
+ENDIF()
+
 ADD_LIBRARY(${PROJECT_NAME} SHARED ${SINGLEO_SERVICE_SOURCE_FILES})
 
 TARGET_INCLUDE_DIRECTORIES(${PROJECT_NAME} PRIVATE include common/include ${ROOT_DIRECTORY}/capi/ ${COMMON_HEADER_LIST} ${INPUT_HEADER_LIST} ${INFERENCE_HEADER_LIST} ${SERVICE_HEADER_LIST} ${LOG_HEADER_LIST})
diff --git a/services/focus_finder/CMakeLists.txt b/services/focus_finder/CMakeLists.txt
new file mode 100644 (file)
index 0000000..cd3db39
--- /dev/null
@@ -0,0 +1,7 @@
+SET(SINGLEO_SERVICE_SOURCE_FILES
+    ${SINGLEO_SERVICE_SOURCE_FILES}
+    focus_finder/src/FocusFinder.cpp
+)
+
+LIST(APPEND SERVICE_LIBRARY_LIST ${SERVICE_LIBRARY_LIST})
+LIST(APPEND SERVICE_HEADER_LIST ${SERVICE_HEADER_LIST} ${CMAKE_CURRENT_SOURCE_DIR}/focus_finder/include)
\ No newline at end of file
diff --git a/services/focus_finder/include/FocusFinder.h b/services/focus_finder/include/FocusFinder.h
new file mode 100644 (file)
index 0000000..d87759c
--- /dev/null
@@ -0,0 +1,67 @@
+/**
+ * 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.
+*/
+
+#ifndef __FOCUS_FINDER_H__
+#define __FOCUS_FINDER_H__
+
+#include <map>
+#include <queue>
+#include <mutex>
+#include "IService.h"
+#include "SingleoCommonTypes.h"
+#include "IInputService.h"
+#include "SingleoInferenceTypes.h"
+#include "InputTypes.h"
+#include "IInputObserver.h"
+#include "ServiceDataType.h"
+
+namespace singleo
+{
+namespace services
+{
+namespace focusfinder
+{
+class FocusFinder : public IService, public input::IInputObserver
+{
+private:
+       static bool _registered;
+       std::unique_ptr<singleo::input::IInputService> _data_feeder;
+
+       singleo_user_cb_t _user_cb {};
+       void *_user_data {};
+
+public:
+       FocusFinder();
+       virtual ~FocusFinder();
+       static IService *create()
+       {
+               return new FocusFinder();
+       }
+
+       void inputFeedCb(BaseDataType &data) override;
+       void configure(input::InputConfigBase &config) override;
+       void add_input(BaseDataType &input_data) override;
+       void perform() override;
+       void performAsync() override;
+       void getResultCnt(unsigned int *cnt) override;
+       void getResultInt(unsigned int idx, std::string key, unsigned int *value) override;
+       void registerUserCallback(singleo_user_cb_t user_cb, void *user_data) override;
+       void unregisterUserCallback() override;
+};
+} // focusfinder
+} // services
+} // singleo
+#endif
\ No newline at end of file
diff --git a/services/focus_finder/src/FocusFinder.cpp b/services/focus_finder/src/FocusFinder.cpp
new file mode 100644 (file)
index 0000000..0a022d2
--- /dev/null
@@ -0,0 +1,101 @@
+/**
+ * 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 <memory>
+#include <variant>
+#include <algorithm>
+#include "SingleoException.h"
+#include "FocusFinder.h"
+#include "SingleoLog.h"
+#include "ImagePreprocessor.h"
+#include "ServiceFactory.h"
+#include "InputCamera.h"
+#include "InputTypes.h"
+
+using namespace std;
+using namespace singleo::input;
+using namespace singleo::exception;
+
+namespace singleo
+{
+namespace services
+{
+namespace focusfinder
+{
+bool FocusFinder::_registered = registerService<FocusFinder>("FocusFinder");
+
+FocusFinder::FocusFinder()
+{}
+
+FocusFinder::~FocusFinder()
+{}
+
+void FocusFinder::configure(InputConfigBase &config)
+{
+       // Create InputCamera service if input service type is CAMERA.
+       if (config._input_feed_type == InputFeedType::CAMERA) {
+               CameraConfig cameraConfig;
+
+               try {
+                       cameraConfig = dynamic_cast<CameraConfig &>(config);
+               } catch (bad_cast &e) {
+                       SINGLEO_LOGE("Camera input service requires CameraConfig.");
+                       throw InvalidOperation("Camera input service requires CameraConfig.");
+               }
+
+               _data_feeder = make_unique<InputCamera>(cameraConfig.backend_type);
+               _data_feeder->registerObserver(this);
+               _data_feeder->configure(cameraConfig);
+
+               SINGLEO_LOGD("Camera input service has been initialized.");
+       }
+}
+
+void FocusFinder::inputFeedCb(BaseDataType &data)
+{}
+
+void FocusFinder::add_input(BaseDataType &input_data)
+{}
+
+void FocusFinder::perform()
+{}
+
+void FocusFinder::performAsync()
+{
+       throw FuncNotImpl("performAsync Not Supported Yet");
+}
+
+void FocusFinder::getResultCnt(unsigned int *cnt)
+{}
+
+void FocusFinder::getResultInt(unsigned int idx, std::string key, unsigned int *value)
+{}
+
+void FocusFinder::registerUserCallback(singleo_user_cb_t user_cb, void *user_data)
+{
+       _user_cb = user_cb;
+       _user_data = user_data;
+}
+
+void FocusFinder::unregisterUserCallback()
+{
+       _user_cb = nullptr;
+       _user_data = nullptr;
+}
+
+} // focusfinder
+} // services
+} //singleo
index a67614e73819351b4e37df6060a6ae9b07b1fe7c..580a3cdb51fdefeef0909b08ca88af3184f72589 100644 (file)
@@ -7,6 +7,10 @@ IF (${USE_AUTOZOOM_API})
     SET(TEST_SOURCE_LIST ${TEST_SOURCE_LIST} test_autozoom.cpp)
 ENDIF()
 
+IF (${USE_FOCUSFINDER_API})
+    SET(TEST_SOURCE_LIST ${TEST_SOURCE_LIST} test_focusfinder_dummy.cpp)
+ENDIF()
+
 SET(SRC_FILES
     ${TEST_SOURCE_LIST})
 
diff --git a/test/services/test_focusfinder_dummy.cpp b/test/services/test_focusfinder_dummy.cpp
new file mode 100644 (file)
index 0000000..8f623ae
--- /dev/null
@@ -0,0 +1,39 @@
+/**
+ * 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 <iostream>
+#include <algorithm>
+#include <memory>
+#include <string.h>
+#include <thread>
+
+#include "gtest/gtest.h"
+#include "singleo_native_capi.h"
+#include "singleo_error.h"
+
+using namespace testing;
+using namespace std;
+
+TEST(FocusFinderTest, CreateDestroyShouldBeOK)
+{
+       singleo_service_h handle;
+
+       int ret = singleo_service_create("service=FocusFinder", &handle);
+       ASSERT_EQ(ret, SINGLEO_ERROR_NONE);
+
+       ret = singleo_service_destroy(handle);
+       ASSERT_EQ(ret, SINGLEO_ERROR_NONE);
+}
\ No newline at end of file