* @brief Creates a handle for a given service.
* @details Use this function to create a new singleo service with given option.
* Options include:
- * - "service:": specifies one service name among below list
+ * - "service": specifies one service name among below list
* "auto_zoom"
- * - "input:": specifies one input feeding type among below list
+ * - "input": specifies one input feeding type among below list
* "camera" : Image data captured by camera device though a given camera backend will be used as input image.
* "screen_capture" : Image data captured by screen capture module through a given screen capture backend will be used as input image.
- * - "camera_backend:": specifies one backend type among below list. This key is valid only input=camera case.
- * "camera-api" : Tizen camera API will be used as a backend.
- * "vision-source" : Vision source for Mediavision framework will be used as a backend.
- * - "fps:": specifies frame per second to capture image from the given input backend. This key is valid only input=camera or input=screen_capture
- * - "async:": specifies whether service request should be performed in async way or sync one.
+ * - "camera_id": specifies camera id which indicates what camera device you want to use. This key is valid only input=camera case.
+ * To be updated.
+ * - "fps": specifies frame per second to capture image from the given input backend. This key is valid only input=camera or input=screen_capture
+ * - "async": specifies whether service request should be performed in async way or sync one.
* "0": service request will be performed in sync way. It means that user can get the result as soon as the request is completed.
* "1": service request will be performed in async way. It mean that user is needed to create a new thread to get the result
* because it will be returned as soon as the service request is done so user has to wait for the result within its own thread context.
- * Examples: singleo_service_create("service=auto_zoom, input=camera, camera_backend=camera-api, fbs=30, async=0")
+ * Examples: singleo_service_create("service=auto_zoom, input=camera, camera_id=0, fbs=30, async=0")
*
* @since_tizen 9.0
*
* @remarks With this function, user can add input image data to the the service before invoking the service.
*
* @param[in] handle The handle to the service.
+ * @param[in] option The option string which speicifies pixel format type to a given image data.
+ * The option includes:
+ * - "format": one of below lists can be set
+ * "YUV420" : Y(1byte), Cb(1/4 byte), Cr(1/4 byte)
+ * "RGB888" : R(1byte), G(1byte), B(1byte))
* @param[in] buffer A buffer pointer pointing to raw image data.
* @param[in] width A number of horizontal pixels in the image.
* @param[in] height A number of vertical pixels in the image.
*
* @pre Create a source handle by calling singleo_service_create()
*/
-int singleo_service_add_input_rgb_data(singleo_service_h handle, const unsigned char *buffer, unsigned int width,
- unsigned int height, unsigned long byte_per_pixel);
+int singleo_service_add_input_image_data(singleo_service_h handle, const char *option, const unsigned char *buffer,
+ unsigned int width, unsigned int height, unsigned long bytes_per_pixel);
/**
* @internal
* @remarks With this function, user can add input raw data to the the service before invoking the service.
*
* @param[in] handle The handle to the service.
+ * @param[in] option The option string which speicifies data type to a raw data.
+ * The option includes:
+ * - To be updated.
* @param[in] buffer A buffer pointer pointing to raw data.
* @param[in] buffer_size_in_bytes Buffer size to a given buffer in bytes.
*
*
* @pre Create a source handle by calling singleo_service_create()
*/
-int singleo_service_add_input_raw_data(singleo_service_h handle, const unsigned char *buffer,
+int singleo_service_add_input_raw_data(singleo_service_h handle, const char *option, const unsigned char *buffer,
unsigned long buffer_size_in_bytes);
/**
enum class DataType { NONE, FILE, IMAGE, RAW };
+enum class ImagePixelFormat { NONE, YUV420, RGB888 };
+
struct BaseDataType {
DataType _data_type { DataType::NONE };
BaseDataType(DataType data_type) : _data_type(data_type)
unsigned int width {};
unsigned int height {};
unsigned int byte_per_pixel {};
+ ImagePixelFormat pixel_format { ImagePixelFormat::NONE };
};
struct RawDataType : public BaseDataType {
std::map<std::string, std::string> _params;
ServiceType _service_type { ServiceType::NONE };
InputFeedType _input_feed_type { InputFeedType::NONE };
+ ImagePixelFormat _image_pixel_format { ImagePixelFormat::NONE };
unsigned int _fps {};
bool _async_mode {};
input::InputConfigBase _default_config;
bool isValidPair(const std::string &key, const std::string &value);
void trim(std::string &str);
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 setInputFeedType(std::string key);
void setCameraDeviceId(std::string key);
void setFps(std::string key);
void setAsyncMode(std::string key);
+ void setInputFormat(std::string key);
public:
- explicit ServiceConfigParser() = default;
- ServiceConfigParser(std::string option);
+ ServiceConfigParser() = default;
virtual ~ServiceConfigParser() = default;
- void parse(std::string option);
+ void parseService(std::string option);
+ void parseInput(std::string option);
ServiceType getServiceType();
InputFeedType getInputFeedType();
+ ImagePixelFormat getImagePixelFormat();
CameraBackendType getCameraBackendType();
unsigned int getFps();
bool getAsyncMode();
{
namespace services
{
-ServiceConfigParser::ServiceConfigParser(string option)
-{
- parse(option);
-}
bool ServiceConfigParser::isValidPair(const string &key, const string &value)
{
_async_mode = async_mode;
}
+void ServiceConfigParser::setInputFormat(string key)
+{
+ static map<string, ImagePixelFormat> valid_services = {
+ { "YUV420", ImagePixelFormat::YUV420 },
+ { "RGB888", ImagePixelFormat::RGB888 }
+ };
+
+ auto it = valid_services.find(key);
+ if (it == valid_services.end())
+ throw InvalidParameter("Invalid image pixel format.");
+
+ _image_pixel_format = it->second;
+}
+
ServiceType ServiceConfigParser::getServiceType()
{
return _service_type;
return _input_feed_type;
}
+ImagePixelFormat ServiceConfigParser::getImagePixelFormat()
+{
+ return _image_pixel_format;
+}
+
bool ServiceConfigParser::getAsyncMode()
{
return _async_mode;
str.erase(str.find_last_not_of(" \n\r\t") + 1);
}
-void ServiceConfigParser::parse(string option)
+void ServiceConfigParser::parse(map<string, bool> &valid_keys, string option)
{
- map<string, bool> valid_keys = {
- { "SERVICE", false }, { "INPUT_FEED", false }, { "CAMERA_ID", false }, { "FPS", false }, { "ASYNC", false }
- };
istringstream iss(option);
string token;
update();
}
+void ServiceConfigParser::parseService(string option)
+{
+ map<string, bool> valid_keys = {
+ { "SERVICE", false }, { "INPUT_FEED", false }, { "CAMERA_ID", false }, { "FPS", false }, { "ASYNC", false }
+ };
+
+ parse(valid_keys, option);
+}
+
+void ServiceConfigParser::parseInput(std::string option)
+{
+ map<string, bool> valid_keys = {
+ { "FORMAT", false }
+ };
+
+ parse(valid_keys, option);
+}
+
void ServiceConfigParser::update()
{
using setParamCallback = void (ServiceConfigParser::*)(std::string);
setParam("CAMERA_ID", &ServiceConfigParser::setCameraDeviceId);
setParam("FPS", &ServiceConfigParser::setFps);
setParam("ASYNC", &ServiceConfigParser::setAsyncMode);
+ setParam("FORMAT", &ServiceConfigParser::setInputFormat);
}
InputConfigBase &ServiceConfigParser::getConfig(InputFeedType input_feed_type)
Context *context = NULL;
try {
- ServiceConfigParser parser(option);
+ ServiceConfigParser parser;
+ parser.parseService(option);
async_mode = parser.getAsyncMode();
if (ServiceType::AUTO_ZOOM == parser.getServiceType()) {
return SINGLEO_ERROR_NONE;
}
-int singleo_service_add_input_rgb_data(singleo_service_h handle, const unsigned char *buffer, unsigned int width,
+int singleo_service_add_input_image_data(singleo_service_h handle, const char *option, const unsigned char *buffer, unsigned int width,
unsigned int height, unsigned long byte_per_pixel)
{
try {
auto context = static_cast<Context *>(handle);
+ ServiceConfigParser parser;
+
+ parser.parseInput(option);
+
ImageDataType input_data;
+ input_data.pixel_format = parser.getImagePixelFormat();
input_data.ptr = const_cast<unsigned char *>(buffer);
input_data.width = width;
input_data.height = height;
return SINGLEO_ERROR_NONE;
}
-int singleo_service_add_input_raw_data(singleo_service_h handle, const unsigned char *buffer,
+int singleo_service_add_input_raw_data(singleo_service_h handle, const char *option, const unsigned char *buffer,
unsigned long buffer_size_in_bytes)
{
try {