SET(PC_NAME ${PROJECT_NAME})
SET(PC_LDFLAGS -l${PROJECT_NAME})
-SET(PC_CFLAGS -I\${includedir}/media)
+SET(PC_CFLAGS -I\${includedir}/media/singleo)
CONFIGURE_FILE(
${PROJECT_NAME}.pc.in
${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc
@ONLY
)
-INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
\ No newline at end of file
+INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${PROJECT_NAME}.pc DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)
+install(
+ FILES ${PROJECT_SOURCE_DIR}/common/include/singleo_error.h
+ ${PROJECT_SOURCE_DIR}/common/include/SingleoCommonTypes.h
+ ${PROJECT_SOURCE_DIR}/common/include/SingleoException.h
+ ${PROJECT_SOURCE_DIR}/common/include/SharedBuffer.h
+ ${PROJECT_SOURCE_DIR}/services/common/include/IService.h
+ ${PROJECT_SOURCE_DIR}/services/common/include/AsyncManager.h
+ ${PROJECT_SOURCE_DIR}/services/common/include/IPreprocessor.h
+ ${PROJECT_SOURCE_DIR}/services/common/include/IPostprocessor.h
+ ${PROJECT_SOURCE_DIR}/services/common/include/ImagePreprocessor.h
+ ${PROJECT_SOURCE_DIR}/services/common/include/ServiceConfigParser.h
+ ${PROJECT_SOURCE_DIR}/services/common/include/ServiceDataType.h
+ ${PROJECT_SOURCE_DIR}/services/common/include/ServiceFactory.h
+ ${PROJECT_SOURCE_DIR}/log/include/SingleoLog.h
+ ${PROJECT_SOURCE_DIR}/log/include/SingleoLogBackend.h
+ ${PROJECT_SOURCE_DIR}/log/include/SingleoLogType.h
+ ${PROJECT_SOURCE_DIR}/inference/include/IInferenceTaskFactory.h
+ ${PROJECT_SOURCE_DIR}/inference/include/InferenceTaskFactory.h
+ ${PROJECT_SOURCE_DIR}/inference/include/IInferenceTaskInterface.h
+ ${PROJECT_SOURCE_DIR}/inference/include/SingleoInferenceTypes.h
+ ${PROJECT_SOURCE_DIR}/input/include/IInputService.h
+ ${PROJECT_SOURCE_DIR}/input/include/InputCamera.h
+ ${PROJECT_SOURCE_DIR}/input/include/IInputObserver.h
+ ${PROJECT_SOURCE_DIR}/input/include/InputTypes.h
+ DESTINATION include/media/singleo
+)
\ No newline at end of file
#include "singleo_native_capi.h"
-typedef void (*singleo_user_cb_t)(unsigned char *buffer, unsigned int width, unsigned int height,
- unsigned int bytes_per_pixel, void *user_data);
-
/**
* @internal
* @brief Registers user-given callback for user to receive result mixed with input data.
enum class CameraBackendType { NONE, OPENCV, CAMERA_API, VISION_SOURCE };
+typedef void (*singleo_user_cb_t)(unsigned char *buffer, unsigned int width, unsigned int height,
+ unsigned int bytes_per_pixel, void *user_data);
+
} // singleo
#endif
\ No newline at end of file
%description
SingleO AI Service Framework
-%package release
-Summary: SingleO AI Service Framework
-Group: Multimedia/Framework
-
-%description release
-SingleO AI Service Framework
-
%package devel
Summary: SingleO AI Service Framework
Group: Multimedia/Framework
-Requires: %{name} = %{version}-%{release}
+Requires: %{name}
%description devel
SingleO AI Service Framework (Dev)
%package test
Summary: Test case for SingleO AI Service Framework
Group: Multimedia/Framework
-Requires: %{name} = %{version}-%{release}
+Requires: %{name}
%description test
Test case for SingleO AI Service Framework (Dev)
%post -p /sbin/ldconfig
%postun -p /sbin/ldconfig
-%files release
+%files
%manifest singleo.manifest
%license LICENSE.APLv2
+%{_libdir}/libsingleo_service.so
+%{_libdir}/libsingleo_visualizer.so
%files devel
%{_libdir}/pkgconfig/*.pc
-%{_libdir}/libsingleo_service.so
-%{_libdir}/libsingleo_visualizer.so
+%{_includedir}/media/singleo/IInferenceTaskFactory.h
+%{_includedir}/media/singleo/IInferenceTaskInterface.h
+%{_includedir}/media/singleo/InferenceTaskFactory.h
+%{_includedir}/media/singleo/SingleoInferenceTypes.h
+%{_includedir}/media/singleo/SingleoCommonTypes.h
+%{_includedir}/media/singleo/SingleoException.h
+%{_includedir}/media/singleo/singleo_error.h
+%{_includedir}/media/singleo/SharedBuffer.h
+%{_includedir}/media/singleo/IService.h
+%{_includedir}/media/singleo/AsyncManager.h
+%{_includedir}/media/singleo/IPreprocessor.h
+%{_includedir}/media/singleo/IPostprocessor.h
+%{_includedir}/media/singleo/ImagePreprocessor.h
+%{_includedir}/media/singleo/ServiceConfigParser.h
+%{_includedir}/media/singleo/ServiceDataType.h
+%{_includedir}/media/singleo/ServiceFactory.h
+%{_includedir}/media/singleo/SingleoLog.h
+%{_includedir}/media/singleo/SingleoLogBackend.h
+%{_includedir}/media/singleo/SingleoLogType.h
+%{_includedir}/media/singleo/IInputService.h
+%{_includedir}/media/singleo/InputCamera.h
+%{_includedir}/media/singleo/IInputObserver.h
+%{_includedir}/media/singleo/InputTypes.h
%files test
%{_bindir}/test_singleo
*/
#include <algorithm>
+#include <map>
#include "SingleoException.h"
#include "AutoZoom.h"
#include "InferenceTaskFactory.h"
#include "IService.h"
#include "SingleoException.h"
#include "SingleoCommonTypes.h"
-#include "ImagePreprocessor.h"
namespace singleo
{
#ifndef __ISERVICE_H__
#define __ISERVICE_H__
-#include "singleo_native_capi_internal.h"
-
#include "SingleoCommonTypes.h"
#include "InputTypes.h"
#include "IPreprocessor.h"
{
private:
std::map<std::string, std::string> _params;
- ServiceType _service_type { ServiceType::NONE };
+ std::string _service_name;
InputFeedType _input_feed_type { InputFeedType::NONE };
ImagePixelFormat _image_pixel_format { ImagePixelFormat::NONE };
unsigned int _fps {};
bool isKeyValid(std::map<std::string, bool> &valid_keys, const std::string &key);
void parse(std::map<std::string, bool> &valid_keys, std::string option);
void update();
- void setServiceType(std::string key);
+ void setServiceName(std::string key);
void setInputFeedType(std::string key);
void setCameraDeviceId(std::string key);
void setFps(std::string key);
void parseService(std::string option);
void parseInput(std::string option);
- ServiceType getServiceType();
+ std::string &getServiceName();
InputFeedType getInputFeedType();
ImagePixelFormat getImagePixelFormat();
CameraBackendType getCameraBackendType();
}
}
-#endif
\ No newline at end of file
+#endif
return true;
}
-void ServiceConfigParser::setServiceType(string key)
+void ServiceConfigParser::setServiceName(string key)
{
- static map<string, ServiceType> valid_services = { { "AUTO_ZOOM", ServiceType::AUTO_ZOOM } };
-
- auto it = valid_services.find(key);
- if (it == valid_services.end())
- throw InvalidOperation("Invalid service type.");
-
- _service_type = it->second;
+ _service_name = key;
}
void ServiceConfigParser::setInputFeedType(std::string key)
_image_pixel_format = it->second;
}
-ServiceType ServiceConfigParser::getServiceType()
+string &ServiceConfigParser::getServiceName()
{
- return _service_type;
+ return _service_name;
}
InputFeedType ServiceConfigParser::getInputFeedType()
throw InvalidParameter("Invalid option string.");
transform(key.begin(), key.end(), key.begin(), ::toupper);
- transform(value.begin(), value.end(), value.begin(), ::toupper);
+
+ // Do not transform value to uppercase if key is SERVICE.
+ if (key != "SERVICE")
+ transform(value.begin(), value.end(), value.begin(), ::toupper);
if (!isKeyValid(valid_keys, key))
throw InvalidParameter("A given key is invalid.");
SINGLEO_LOGD("Parsed : key(%s) -> value(%s)", key.c_str(), it->second.c_str());
};
- setParam("SERVICE", &ServiceConfigParser::setServiceType);
+ setParam("SERVICE", &ServiceConfigParser::setServiceName);
setParam("INPUT_FEED", &ServiceConfigParser::setInputFeedType);
setParam("CAMERA_ID", &ServiceConfigParser::setCameraDeviceId);
setParam("FPS", &ServiceConfigParser::setFps);
using namespace singleo::services;
using namespace singleo::input;
+// TODO. Add json based plugin list file support later
+// to add new services and use them without recompiling SingleO framework.
+static vector<string> _pluginNames = { "libsingleo-example-plugin.so" };
+static vector<void *> _pluginHandles;
+
+static void singleo_service_open_plugins()
+{
+ for (const auto &pluginName : _pluginNames) {
+ void *plugin_handle = dlopen(pluginName.c_str(), RTLD_LAZY);
+ if (!plugin_handle) {
+ SINGLEO_LOGW("Fail to load external plugin library(%s).", pluginName.c_str());
+ continue;
+ }
+
+ SINGLEO_LOGD("Opened new service plugin(%s).", pluginName.c_str());
+ _pluginHandles.push_back(plugin_handle);
+ }
+}
+
+static void singleo_service_close_plugins()
+{
+ for (const auto &plugin_handle : _pluginHandles)
+ dlclose(plugin_handle);
+}
+
int singleo_service_create(const char *option, singleo_service_h *handle)
{
IService *service_handle = NULL;
- ServiceType service_type {};
bool async_mode { false };
Context *context = NULL;
+ ServiceConfigParser parser {};
- try {
- ServiceConfigParser parser;
+ singleo_service_open_plugins();
+ try {
parser.parseService(option);
async_mode = parser.getAsyncMode();
- if (ServiceType::AUTO_ZOOM == parser.getServiceType()) {
- service_handle = ServiceFactory::instance().create("AutoZoom");
- if (!service_handle)
- throw InvalidOperation("Failed to create AutoZoom service.");
+ service_handle = ServiceFactory::instance().create(parser.getServiceName());
+ if (!service_handle)
+ throw InvalidOperation("Failed to create service.");
- service_handle->configure(parser.getConfig(parser.getInputFeedType()));
-
- SINGLEO_LOGD("AutoZoom service has been created.");
- service_type = ServiceType::AUTO_ZOOM;
- } else {
- SINGLEO_LOGE("Invalid service type.");
- throw InvalidOperation("Invalid service type.");
- }
+ SINGLEO_LOGD("%s service has been created.", parser.getServiceName().c_str());
context = new Context();
+ service_handle->configure(parser.getConfig(parser.getInputFeedType()));
} catch (const BaseException &e) {
if (service_handle)
delete service_handle;
}
context->_service_handle = service_handle;
- context->_service_type = service_type;
context->_async_mode = async_mode;
*handle = static_cast<void *>(context);
{
auto context = static_cast<Context *>(handle);
- if (context->_service_type == ServiceType::AUTO_ZOOM)
- delete static_cast<IService *>(context->_service_handle);
-
+ delete static_cast<IService *>(context->_service_handle);
delete context;
+ singleo_service_close_plugins();
+
return SINGLEO_ERROR_NONE;
}
prefix=@PREFIX@
exec_prefix=/usr
libdir=@LIB_INSTALL_DIR@
-includedir=/usr/include/media
+includedir=/usr/include/media/singleo
Name: @PC_NAME@
Description: @PACKAGE_DESCRIPTION@
{
singleo_service_h handle;
- int ret = singleo_service_create("service=auto_zoom", &handle);
+ int ret = singleo_service_create("service=AutoZoom", &handle);
ASSERT_EQ(ret, SINGLEO_ERROR_NONE);
ret = singleo_service_add_input_image_file(handle, IMG_FACE);
{
singleo_service_h handle;
- int ret = singleo_service_create("service=auto_zoom, input_feed=camera, camera_id=0, fps=30, async=0", &handle);
+ int ret = singleo_service_create("service=AutoZoom, input_feed=camera, camera_id=0, fps=30, async=0", &handle);
ASSERT_EQ(ret, SINGLEO_ERROR_NONE);
const unsigned int max_iteration = 10;
{
singleo_service_h handle;
- int ret = singleo_service_create("service=auto_zoom, input_feed=camera, camera_id=0, fps=30, async=1", &handle);
+ int ret = singleo_service_create("service=AutoZoom, input_feed=camera, camera_id=0, fps=30, async=1", &handle);
ASSERT_EQ(ret, SINGLEO_ERROR_NONE);
ret = singleo_service_perform(handle);
{
Context context {};
- int ret = singleo_service_create("service=auto_zoom, input_feed=camera, camera_id=0, fps=30, async=1",
+ int ret = singleo_service_create("service=AutoZoom, input_feed=camera, camera_id=0, fps=30, async=1",
&context.handle);
ASSERT_EQ(ret, SINGLEO_ERROR_NONE);