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 <inki.dae@samsung.com>
+++ /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 __SINGLEO_INPUT_MANAGER_H__
-#define __SINGLEO_INPUT_MANAGER_H__
-
-#include <queue>
-#include <mutex>
-#include <memory>
-
-#include "SingleoCommonTypes.h"
-
-namespace singleo
-{
-class SingleoInputManager
-{
-private:
- std::queue<std::shared_ptr<BaseDataType> > _queue;
- std::mutex _queue_mutex;
-
-public:
- SingleoInputManager() = default;
- virtual ~SingleoInputManager() = default;
-
- void enqueue(std::shared_ptr<BaseDataType> input_data);
- std::shared_ptr<BaseDataType> dequeue();
- unsigned int size();
-};
-
-} // singleo
-
-#endif
+++ /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 "SingleoInputManager.h"
-
-using namespace std;
-
-namespace singleo
-{
-void SingleoInputManager::enqueue(shared_ptr<BaseDataType> input_data)
-{
- std::lock_guard<std::mutex> lock(_queue_mutex);
- _queue.push(input_data);
-}
-
-shared_ptr<BaseDataType> SingleoInputManager::dequeue()
-{
- std::lock_guard<std::mutex> lock(_queue_mutex);
- shared_ptr<BaseDataType> data = _queue.front();
-
- _queue.pop();
-
- return data;
-}
-
-unsigned int SingleoInputManager::size()
-{
- return _queue.size();
-}
-
-}
*/
#include <stdexcept>
-#include "SingleoInputManager.h"
#include "MvFaceDetection.h"
#include "SingleoLog.h"
*/
#include <stdexcept>
-#include "SingleoInputManager.h"
#include "MvFaceLandmark.h"
#include "SingleoLog.h"
*/
#include <stdexcept>
-#include "SingleoInputManager.h"
#include "MvObjectDetection.h"
#include "SingleoLog.h"
#include "IInputObserver.h"
#include "ICameraBackend.h"
-#include "SingleoInputManager.h"
#include "InputTypes.h"
namespace singleo
#include "IService.h"
#include "InputTypes.h"
#include "IInputObserver.h"
-#include "SingleoInputManager.h"
namespace singleo
{
#include <opencv2/opencv.hpp>
#include "ICameraBackend.h"
-#include "SingleoInputManager.h"
#include "InputTypes.h"
namespace singleo
#include "SingleoException.h"
#include "InputCamera.h"
#include "CameraBackendFactory.h"
-#include "SingleoInputManager.h"
#include "SingleoLog.h"
using namespace std;
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)
#include "IService.h"
#include "SingleoCommonTypes.h"
-#include "SingleoInputManager.h"
#include "IInputService.h"
#include "SingleoInferenceTypes.h"
#include "InputTypes.h"
std::unique_ptr<TaskManager> _taskManager;
std::unique_ptr<singleo::input::IInputService> _input_service;
std::unique_ptr<IPostprocessor> _postprocessor;
- SingleoInputManager _input_image_data;
+ std::queue<std::shared_ptr<BaseDataType> > _inputQ;
+ std::mutex _inputMutex;
AutoZoomResult _result {};
std::map<std::string, AutoZoomResultType> _result_keys = { { "X", AutoZoomResultType::X },
{ "Y", AutoZoomResultType::Y },
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) {
throw InvalidOperation("Only IMAGE and FILE types are allowed.");
}
- _input_image_data.enqueue(input_data.clone());
+ std::lock_guard<std::mutex> lock(_inputMutex);
+
+ _inputQ.push(input_data.clone());
}
void AutoZoom::runTaskManager(BaseDataType &input_data)
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<BaseDataType> result = _input_image_data.dequeue();
- auto data = dynamic_pointer_cast<FileDataType>(result);
+ std::lock_guard<std::mutex> lock(_inputMutex);
- preprocessor.update(*data);
+ preprocessor.update(*_inputQ.front());
+ _inputQ.pop();
} else {
ImageDataType input_data;