SET(INFERENCE_DIRECTORY ${ROOT_DIRECTORY}/inference)
-IF (${USE_EXTERNAL_INFERENCE_SERVICE})
- SET(SINGLEO_SERVICE_SOURCE_FILES ${SINGLEO_SERVICE_SOURCE_FILES} ${INFERENCE_DIRECTORY}/src/InferenceServiceExternal.cpp)
-ELSE()
- SET(SINGLEO_SERVICE_SOURCE_FILES ${SINGLEO_SERVICE_SOURCE_FILES}
- ${INFERENCE_DIRECTORY}/src/InferenceServiceDefault.cpp
- ${INFERENCE_DIRECTORY}/src/MvInferenceServiceFactory.cpp)
-ENDIF()
-
INCLUDE(${INFERENCE_DIRECTORY}/backends/mediavision/CMakeLists.txt)
LIST(APPEND INFERENCE_HEADER_LIST ${INFERENCE_HEADER_LIST} ${INFERENCE_DIRECTORY}/include)
${SINGLEO_SERVICE_SOURCE_FILES}
${INFERENCE_MEDIAVISION_BACKEND_DIRECTORY}/src/MvFaceDetection.cpp
${INFERENCE_MEDIAVISION_BACKEND_DIRECTORY}/src/MvObjectDetection.cpp
+ ${INFERENCE_MEDIAVISION_BACKEND_DIRECTORY}/src/MvInferenceServiceFactory.cpp
)
LIST(APPEND INFERENCE_LIBRARY_LIST ${INFERENCE_LIBRARY_LIST} mv_common mv_inference mv_object_detection)
#ifndef __FACE_DETECTION_H__
#define __FACE_DETECTION_H__
-#include "IInferenceTaskInterface.h"
+#include "IInferenceServiceInterface.h"
#include "mv_face_detection_internal.h"
#include "SingleoCommonTypes.h"
{
namespace backends
{
-class MvFaceDetection : public IInferenceTaskInterface
+class MvFaceDetection : public IInferenceServiceInterface
{
private:
mv_face_detection_h _handle {};
--- /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 __MV_INFERENCE_SERVICE_FACTORY_H__
+#define __MV_INFERENCE_SERVICE_FACTORY_H__
+
+#include "IInferenceServiceFactory.h"
+
+namespace singleo
+{
+namespace inference
+{
+class MvInferenceServiceFactory : public IInferenceServiceFactory
+{
+private:
+ static bool _registered;
+
+public:
+ MvInferenceServiceFactory() = default;
+ virtual ~MvInferenceServiceFactory() = default;
+
+ std::unique_ptr<IInferenceServiceInterface> createImageClassification() override;
+ std::unique_ptr<IInferenceServiceInterface> createObjectDetection() override;
+ std::unique_ptr<IInferenceServiceInterface> createFaceDetection() override;
+ std::unique_ptr<IInferenceServiceInterface> createFaceLandmarkDetection() override;
+};
+
+}
+}
+
+#endif
#ifndef __OBJECT_DETECTION_H__
#define __OBJECT_DETECTION_H__
-#include "IInferenceTaskInterface.h"
+#include "IInferenceServiceInterface.h"
#include "mv_object_detection_internal.h"
#include "SingleoCommonTypes.h"
{
namespace backends
{
-class MvObjectDetection : public IInferenceTaskInterface
+class MvObjectDetection : public IInferenceServiceInterface
{
private:
mv_object_detection_h _handle {};
--- /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 "InferenceServiceFactory.h"
+#include "MvInferenceServiceFactory.h"
+#include "MvFaceDetection.h"
+#include "MvObjectDetection.h"
+#include "SingleoLog.h"
+#include "SingleoException.h"
+
+using namespace std;
+using namespace singleo::exception;
+using namespace singleo::inference::backends;
+
+namespace singleo
+{
+namespace inference
+{
+bool MvInferenceServiceFactory::_registered =
+ registerInferenceServiceFactory<MvInferenceServiceFactory>("MvInferenceServiceFactory");
+
+std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createImageClassification()
+{
+ throw InvalidOperation("Interface not supported yet.");
+}
+
+std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createObjectDetection()
+{
+ return make_unique<MvObjectDetection>();
+}
+
+std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createFaceDetection()
+{
+ return make_unique<MvFaceDetection>();
+}
+
+std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createFaceLandmarkDetection()
+{
+ throw InvalidOperation("Interface not supported yet.");
+}
+
+}
+}
+++ /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 __IINFERENCE_TASK_INTERFACE_H__
-#define __IINFERENCE_TASK_INTERFACE_H__
-
-#include "SingleoCommonTypes.h"
-
-namespace singleo
-{
-namespace inference
-{
-class IInferenceTaskInterface
-{
-public:
- virtual ~IInferenceTaskInterface() {};
-
- virtual void configure() = 0;
- virtual void prepare() = 0;
- virtual void invoke(BaseDataType &input, bool async = false) = 0;
- virtual BaseResultType &result() = 0;
-};
-
-} // inference
-} // 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.
- */
-
-#ifndef __INFERENCE_SERVICE_DEFAULT_H__
-#define __INFERENCE_SERVICE_DEFAULT_H__
-
-#include <memory>
-#include "IInferenceServiceInterface.h"
-#include "IInferenceTaskInterface.h"
-#include "SingleoInferenceTypes.h"
-#include "SingleoCommonTypes.h"
-
-namespace singleo
-{
-namespace inference
-{
-class InferenceServiceDefault : public IInferenceServiceInterface
-{
-private:
- std::unique_ptr<IInferenceTaskInterface> _task;
-
-public:
- explicit InferenceServiceDefault(TaskType task_type);
- virtual ~InferenceServiceDefault() = default;
-
- void configure() override;
- void prepare() override;
- void invoke(BaseDataType &input, bool async = false) override;
- BaseResultType &result() override;
-};
-
-} // inference
-} // 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.
- */
-
-#ifndef __INFERENCE_SERVICE_EXTERNAL_H__
-#define __INFERENCE_SERVICE_EXTERNAL_H__
-
-#include "IInferenceServiceInterface.h"
-#include "IInferenceTaskInterface.h"
-#include "SingleoInferenceTypes.h"
-#include "SingleoCommonTypes.h"
-
-namespace singleo
-{
-namespace inference
-{
-class InferenceServiceExternal : public IInferenceServiceInterface
-{
-public:
- explicit InferenceServiceExternal(TaskType task_type);
- virtual ~InferenceServiceExternal();
-
- void configure(TaskType task_type) override;
- void prepare() override;
- void invoke(BaseDataType &input, bool async = false) override;
- BaseResultType &result() override;
-};
-
-} // inference
-} // 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.
- */
-
-#ifndef __MV_INFERENCE_SERVICE_FACTORY_H__
-#define __MV_INFERENCE_SERVICE_FACTORY_H__
-
-#include "IInferenceServiceFactory.h"
-
-namespace singleo
-{
-namespace inference
-{
-class MvInferenceServiceFactory : public IInferenceServiceFactory
-{
-private:
- static bool _registered;
-
-public:
- MvInferenceServiceFactory() = default;
- virtual ~MvInferenceServiceFactory() = default;
-
- std::unique_ptr<IInferenceServiceInterface> createImageClassification() override;
- std::unique_ptr<IInferenceServiceInterface> createObjectDetection() override;
- std::unique_ptr<IInferenceServiceInterface> createFaceDetection() override;
- std::unique_ptr<IInferenceServiceInterface> createFaceLandmarkDetection() override;
-};
-
-}
-}
-
-#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 "InferenceServiceDefault.h"
-#include "MvObjectDetection.h"
-#include "MvFaceDetection.h"
-
-using namespace std;
-using namespace singleo::inference::backends;
-
-namespace singleo
-{
-namespace inference
-{
-InferenceServiceDefault::InferenceServiceDefault(TaskType task_type)
-{
- // TODO. add other task types later.
- if (task_type != TaskType::OBJECT_DETECTION && task_type != TaskType::FACE_DETECTION)
- invalid_argument("Task type not supported.");
-
- switch (task_type) {
- case TaskType::OBJECT_DETECTION:
- _task = make_unique<MvObjectDetection>();
- break;
- case TaskType::FACE_DETECTION:
- _task = make_unique<MvFaceDetection>();
- break;
- }
-}
-
-void InferenceServiceDefault::configure()
-{
- _task->configure();
-}
-
-void InferenceServiceDefault::prepare()
-{
- _task->prepare();
-}
-
-void InferenceServiceDefault::invoke(BaseDataType &input, bool async)
-{
- _task->invoke(input, async);
-}
-
-BaseResultType &InferenceServiceDefault::result()
-{
- return _task->result();
-}
-
-}
-}
+++ /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 <stdexcept>
-#include "InferenceServiceExternal.h"
-
-using namespace std;
-
-namespace singleo
-{
-namespace inference
-{
-InferenceServiceExternal::InferenceServiceExternal(TaskType task_type)
-{}
-InferenceServiceExternal::~InferenceServiceExternal()
-{}
-
-void InferenceServiceExternal::configure(TaskType task_type)
-{
- throw runtime_error("Not support yet.");
-}
-
-void InferenceServiceExternal::prepare()
-{
- throw runtime_error("Not support yet.");
-}
-
-void InferenceServiceExternal::invoke(BaseDataType &input, bool async)
-{
- throw runtime_error("Not support yet.");
-}
-
-BaseResultType &InferenceServiceExternal::result()
-{
- throw runtime_error("Not support yet.");
-}
-
-}
-}
+++ /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 "InferenceServiceFactory.h"
-#include "InferenceServiceDefault.h"
-#include "MvInferenceServiceFactory.h"
-#include "SingleoLog.h"
-#include "SingleoException.h"
-
-using namespace std;
-using namespace singleo::exception;
-
-namespace singleo
-{
-namespace inference
-{
-bool MvInferenceServiceFactory::_registered =
- registerInferenceServiceFactory<MvInferenceServiceFactory>("MvInferenceServiceFactory");
-
-std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createImageClassification()
-{
- throw InvalidOperation("Interface not supported yet.");
-}
-
-std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createObjectDetection()
-{
- return make_unique<InferenceServiceDefault>(TaskType::OBJECT_DETECTION);
-}
-
-std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createFaceDetection()
-{
- return make_unique<InferenceServiceDefault>(TaskType::FACE_DETECTION);
-}
-
-std::unique_ptr<IInferenceServiceInterface> MvInferenceServiceFactory::createFaceLandmarkDetection()
-{
- throw InvalidOperation("Interface not supported yet.");
-}
-
-}
-}