}
};
-enum class ServiceType { NONE, AUTO_ZOOM };
+enum class ServiceType { NONE, AUTO_ZOOM, FOCUS_FINDER };
enum class InputFeedType { NONE, CAMERA, SCREEN_CAPTURE };
-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}
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})
--- /dev/null
+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
--- /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.
+*/
+
+#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
--- /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 <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
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})
--- /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 <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