From: Inki Dae Date: Thu, 30 May 2024 06:16:52 +0000 (+0900) Subject: drop SingleoInputManager X-Git-Tag: accepted/tizen/unified/20240903.110722~35 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F07%2F311907%2F2;p=platform%2Fcore%2Fapi%2Fsingleo.git drop SingleoInputManager Drop SingleoInputManager and use internal queue of AutoZoom instead. As for SingleoInputManager, I will introduce a reference counting based generic buffer manager later, which can be used commonly by other sub modules. As for now, the use of SingleoInputManager in AutoZoom is over-engineering. Change-Id: I1c281e5dcbd97d5714b19f74906a0222b9c0b002 Signed-off-by: Inki Dae --- diff --git a/common/include/SingleoInputManager.h b/common/include/SingleoInputManager.h deleted file mode 100644 index 663dd49..0000000 --- a/common/include/SingleoInputManager.h +++ /dev/null @@ -1,45 +0,0 @@ -/** - * 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 __SINGLEO_INPUT_MANAGER_H__ -#define __SINGLEO_INPUT_MANAGER_H__ - -#include -#include -#include - -#include "SingleoCommonTypes.h" - -namespace singleo -{ -class SingleoInputManager -{ -private: - std::queue > _queue; - std::mutex _queue_mutex; - -public: - SingleoInputManager() = default; - virtual ~SingleoInputManager() = default; - - void enqueue(std::shared_ptr input_data); - std::shared_ptr dequeue(); - unsigned int size(); -}; - -} // singleo - -#endif diff --git a/common/src/SingleoInputManager.cpp b/common/src/SingleoInputManager.cpp deleted file mode 100644 index 2bf4cab..0000000 --- a/common/src/SingleoInputManager.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/** - * 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 "SingleoInputManager.h" - -using namespace std; - -namespace singleo -{ -void SingleoInputManager::enqueue(shared_ptr input_data) -{ - std::lock_guard lock(_queue_mutex); - _queue.push(input_data); -} - -shared_ptr SingleoInputManager::dequeue() -{ - std::lock_guard lock(_queue_mutex); - shared_ptr data = _queue.front(); - - _queue.pop(); - - return data; -} - -unsigned int SingleoInputManager::size() -{ - return _queue.size(); -} - -} diff --git a/inference/backends/mediavision/src/MvFaceDetection.cpp b/inference/backends/mediavision/src/MvFaceDetection.cpp index ac2c61a..9e7ab0c 100644 --- a/inference/backends/mediavision/src/MvFaceDetection.cpp +++ b/inference/backends/mediavision/src/MvFaceDetection.cpp @@ -15,7 +15,6 @@ */ #include -#include "SingleoInputManager.h" #include "MvFaceDetection.h" #include "SingleoLog.h" diff --git a/inference/backends/mediavision/src/MvFaceLandmark.cpp b/inference/backends/mediavision/src/MvFaceLandmark.cpp index 99e73d4..a624c8d 100644 --- a/inference/backends/mediavision/src/MvFaceLandmark.cpp +++ b/inference/backends/mediavision/src/MvFaceLandmark.cpp @@ -15,7 +15,6 @@ */ #include -#include "SingleoInputManager.h" #include "MvFaceLandmark.h" #include "SingleoLog.h" diff --git a/inference/backends/mediavision/src/MvObjectDetection.cpp b/inference/backends/mediavision/src/MvObjectDetection.cpp index 4a7c279..1a6e689 100644 --- a/inference/backends/mediavision/src/MvObjectDetection.cpp +++ b/inference/backends/mediavision/src/MvObjectDetection.cpp @@ -15,7 +15,6 @@ */ #include -#include "SingleoInputManager.h" #include "MvObjectDetection.h" #include "SingleoLog.h" diff --git a/input/backends/camera_api/include/CameraApiBackend.h b/input/backends/camera_api/include/CameraApiBackend.h index 017e34f..3f3fbb2 100644 --- a/input/backends/camera_api/include/CameraApiBackend.h +++ b/input/backends/camera_api/include/CameraApiBackend.h @@ -27,7 +27,6 @@ #include "IInputObserver.h" #include "ICameraBackend.h" -#include "SingleoInputManager.h" #include "InputTypes.h" namespace singleo diff --git a/input/backends/include/ICameraBackend.h b/input/backends/include/ICameraBackend.h index 6dbc190..028b3d8 100644 --- a/input/backends/include/ICameraBackend.h +++ b/input/backends/include/ICameraBackend.h @@ -20,7 +20,6 @@ #include "IService.h" #include "InputTypes.h" #include "IInputObserver.h" -#include "SingleoInputManager.h" namespace singleo { diff --git a/input/backends/opencv/include/OpencvBackend.h b/input/backends/opencv/include/OpencvBackend.h index 855149e..d0df1ec 100644 --- a/input/backends/opencv/include/OpencvBackend.h +++ b/input/backends/opencv/include/OpencvBackend.h @@ -23,7 +23,6 @@ #include #include "ICameraBackend.h" -#include "SingleoInputManager.h" #include "InputTypes.h" namespace singleo diff --git a/input/src/InputCamera.cpp b/input/src/InputCamera.cpp index 0b556ef..22fb420 100644 --- a/input/src/InputCamera.cpp +++ b/input/src/InputCamera.cpp @@ -17,7 +17,6 @@ #include "SingleoException.h" #include "InputCamera.h" #include "CameraBackendFactory.h" -#include "SingleoInputManager.h" #include "SingleoLog.h" using namespace std; diff --git a/services/CMakeLists.txt b/services/CMakeLists.txt index e319e6e..189479c 100644 --- a/services/CMakeLists.txt +++ b/services/CMakeLists.txt @@ -3,8 +3,7 @@ CMAKE_MINIMUM_REQUIRED(VERSION 3.13) FILE(GLOB SINGLEO_SERVICE_SOURCE_FILES "${PROJECT_SOURCE_DIR}/*.cpp" "${PROJECT_SOURCE_DIR}/src/*.cpp" - "${PROJECT_SOURCE_DIR}/common/src/*.cpp" - "${PROJECT_SOURCE_DIR}/../common/src/*.cpp") + "${PROJECT_SOURCE_DIR}/common/src/*.cpp") INCLUDE(${ROOT_DIRECTORY}/input/CMakeLists.txt) INCLUDE(${ROOT_DIRECTORY}/inference/CMakeLists.txt) diff --git a/services/auto_zoom/include/AutoZoom.h b/services/auto_zoom/include/AutoZoom.h index d0e5901..ccf8b25 100644 --- a/services/auto_zoom/include/AutoZoom.h +++ b/services/auto_zoom/include/AutoZoom.h @@ -19,7 +19,6 @@ #include "IService.h" #include "SingleoCommonTypes.h" -#include "SingleoInputManager.h" #include "IInputService.h" #include "SingleoInferenceTypes.h" #include "InputTypes.h" @@ -42,7 +41,8 @@ private: std::unique_ptr _taskManager; std::unique_ptr _input_service; std::unique_ptr _postprocessor; - SingleoInputManager _input_image_data; + std::queue > _inputQ; + std::mutex _inputMutex; AutoZoomResult _result {}; std::map _result_keys = { { "X", AutoZoomResultType::X }, { "Y", AutoZoomResultType::Y }, diff --git a/services/auto_zoom/src/AutoZoom.cpp b/services/auto_zoom/src/AutoZoom.cpp index 8cfe2ef..4657ee3 100644 --- a/services/auto_zoom/src/AutoZoom.cpp +++ b/services/auto_zoom/src/AutoZoom.cpp @@ -121,10 +121,9 @@ bool AutoZoom::isKeyValid(std::string key) void AutoZoom::add_input(BaseDataType &input_data) { - // This service allows only one input data per a service request. - if (_input_image_data.size() > 0) { - SINGLEO_LOGW("This service allows only one input data."); - return; + if (_inputQ.size() > 0) { + SINGLEO_LOGE("Only one input data is allowed."); + throw InvalidOperation("Only one input data is allowed."); } if (input_data._data_type != DataType::IMAGE && input_data._data_type != DataType::FILE) { @@ -132,7 +131,9 @@ void AutoZoom::add_input(BaseDataType &input_data) throw InvalidOperation("Only IMAGE and FILE types are allowed."); } - _input_image_data.enqueue(input_data.clone()); + std::lock_guard lock(_inputMutex); + + _inputQ.push(input_data.clone()); } void AutoZoom::runTaskManager(BaseDataType &input_data) @@ -148,12 +149,12 @@ void AutoZoom::perform() ImagePreprocessor preprocessor; // If input service is not set, input data comes from user. - // In this case, get input data from queue, _input_image_data. + // In this case, get input data from _inputs. if (!_input_service) { - shared_ptr result = _input_image_data.dequeue(); - auto data = dynamic_pointer_cast(result); + std::lock_guard lock(_inputMutex); - preprocessor.update(*data); + preprocessor.update(*_inputQ.front()); + _inputQ.pop(); } else { ImageDataType input_data;