static int __write_buffer_to_img(zint_symbol *symbol, const std::string &imageFileName, BarcodeImageFormat imageFormat,
const int imageWidth, const int imageHeight, Common::EngineConfig *engineCfg)
{
- if (imageWidth <= 0 || imageHeight <= 0) {
- LOGE("Barcode image size is invalid: %i x %i. Terminate write to "
- "the image operation",
- imageWidth, imageHeight);
- return BARCODE_ERROR_INVALID_DATA;
- }
-
/* find directory */
std::string prefix_imageFileName = imageFileName.substr(0, imageFileName.find_last_of('/'));
LOGD("prefix_path: %s", prefix_imageFileName.c_str());
static const char *feature_keys[] = { "http://tizen.org/feature/vision.barcode_generation" };
static const size_t num_keys = sizeof(feature_keys) / sizeof(char *);
-int mv_barcode_generate_source(mv_engine_config_h engine_cfg, const char *message, mv_barcode_type_e type,
- mv_barcode_qr_mode_e qr_enc_mode, mv_barcode_qr_ecc_e qr_ecc, int qr_version,
- mv_source_h image)
+int __check_barcode_param(const char *message, mv_barcode_type_e type, mv_barcode_qr_mode_e qr_enc_mode,
+ mv_barcode_qr_ecc_e qr_ecc, int qr_version)
{
- MEDIA_VISION_SUPPORT_CHECK(mv_check_feature_key(feature_keys, num_keys, false));
MEDIA_VISION_NULL_ARG_CHECK(message);
- MEDIA_VISION_INSTANCE_CHECK(image);
-
- MEDIA_VISION_FUNCTION_ENTER();
-
if (type < MV_BARCODE_QR || type >= MV_BARCODE_UNKNOWN || type == MV_BARCODE_UNDEFINED) {
LOGE("Not supported barcode type [%d]", type);
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
-
if (type == MV_BARCODE_QR) {
if (qr_enc_mode < MV_BARCODE_QR_MODE_NUMERIC || qr_enc_mode >= MV_BARCODE_QR_MODE_UNAVAILABLE) {
LOGE("Not supported QR encoding mode[%d]", qr_enc_mode);
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
-
if (qr_ecc < MV_BARCODE_QR_ECC_LOW || qr_ecc >= MV_BARCODE_QR_ECC_UNAVAILABLE) {
LOGE("Not supported QR ECC level [%d]", qr_ecc);
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
}
+ return MEDIA_VISION_ERROR_NONE;
+}
+
+int mv_barcode_generate_source(mv_engine_config_h engine_cfg, const char *message, mv_barcode_type_e type,
+ mv_barcode_qr_mode_e qr_enc_mode, mv_barcode_qr_ecc_e qr_ecc, int qr_version,
+ mv_source_h image)
+{
+ MEDIA_VISION_FUNCTION_ENTER();
+ MEDIA_VISION_SUPPORT_CHECK(mv_check_feature_key(feature_keys, num_keys, false));
+ MEDIA_VISION_INSTANCE_CHECK(image);
+ MEDIA_VISION_CHECK_ERR(__check_barcode_param(message, type, qr_enc_mode, qr_ecc, qr_version), "Invalid parameter");
/* Use open barcode generate functionality here. */
int ret = mv_barcode_generate_source_open(engine_cfg, message, type, qr_enc_mode, qr_ecc, qr_version, image);
mv_barcode_type_e type, mv_barcode_qr_mode_e qr_enc_mode, mv_barcode_qr_ecc_e qr_ecc,
int qr_version, const char *image_path, mv_barcode_image_format_e image_format)
{
- MEDIA_VISION_SUPPORT_CHECK(mv_check_feature_key(feature_keys, num_keys, false));
- MEDIA_VISION_NULL_ARG_CHECK(message);
-
MEDIA_VISION_FUNCTION_ENTER();
-
- if (image_path == NULL) {
- LOGE("image_path is NULL");
- return MEDIA_VISION_ERROR_INVALID_PATH;
- }
-
- if (type < MV_BARCODE_QR || type >= MV_BARCODE_UNKNOWN || type == MV_BARCODE_UNDEFINED) {
- LOGE("Not supported barcode type [%d]", type);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- if (type == MV_BARCODE_QR) {
- if (qr_enc_mode < MV_BARCODE_QR_MODE_NUMERIC || qr_enc_mode >= MV_BARCODE_QR_MODE_UNAVAILABLE) {
- LOGE("Not supported QR encoding mode[%d]", qr_enc_mode);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- if (qr_ecc < MV_BARCODE_QR_ECC_LOW || qr_ecc >= MV_BARCODE_QR_ECC_UNAVAILABLE) {
- LOGE("Not supported QR ECC level [%d]", qr_ecc);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
-
- if (qr_version < 1 || qr_version > 40) {
- LOGE("Not supported QR version [%d]", qr_version);
- return MEDIA_VISION_ERROR_INVALID_PARAMETER;
- }
- }
-
+ MEDIA_VISION_SUPPORT_CHECK(mv_check_feature_key(feature_keys, num_keys, false));
+ MEDIA_VISION_CHECK_ERR(__check_barcode_param(message, type, qr_enc_mode, qr_ecc, qr_version), "Invalid parameter");
+ MEDIA_VISION_NULL_ARG_CHECK(image_path);
if (image_format < MV_BARCODE_IMAGE_FORMAT_BMP || image_format >= MV_BARCODE_IMAGE_FORMAT_NUM) {
LOGE("Not supported image format [%d]", image_format);
return MEDIA_VISION_ERROR_INVALID_PARAMETER;
}
+ if (image_width <= 0 || image_height <= 0) {
+ LOGE("Barcode image size is invalid: %d x %d. Terminate write to the image operation", image_width,
+ image_height);
+ return MEDIA_VISION_ERROR_INVALID_PARAMETER;
+ }
/* Use open barcode generate functionality here. */
int ret = mv_barcode_generate_image_open(engine_cfg, message, image_width, image_height, type, qr_enc_mode, qr_ecc,
mv_barcode_qr_ecc_e qr_ecc, int qr_version, const char *image_path,
mv_barcode_image_format_e image_format)
{
- if (!image_path) {
- LOGE("Can't save barcode image to the path[%p]. The path has to be specified", image_path);
- return MEDIA_VISION_ERROR_INVALID_PATH;
- }
-
std::string messageStr;
int error = prepareMessageToGenerate(message, type, qr_enc_mode, messageStr);
if (error != MEDIA_VISION_ERROR_NONE) {
#define MEDIA_VISION_FUNCTION_LEAVE() LOGI("[%s] <LEAVE>", __FUNCTION__)
-#define MEDIA_VISION_ASSERT(function, msg) \
+#define MEDIA_VISION_CHECK_ERR(function, msg) \
do { \
int error_code = function; \
if (error_code != MEDIA_VISION_ERROR_NONE) { \
mv_colorspace_e colorspace = MEDIA_VISION_COLORSPACE_INVALID;
- MEDIA_VISION_ASSERT(mv_source_get_width(mvSource, &width), "Failed to get the width.");
- MEDIA_VISION_ASSERT(mv_source_get_height(mvSource, &height), "Failed to get the height.");
- MEDIA_VISION_ASSERT(mv_source_get_colorspace(mvSource, &colorspace), "Failed to get the colorspace.");
- MEDIA_VISION_ASSERT(mv_source_get_buffer(mvSource, &buffer, &bufferSize), "Failed to get the buffer size.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_width(mvSource, &width), "Failed to get the width.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_height(mvSource, &height), "Failed to get the height.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_colorspace(mvSource, &colorspace), "Failed to get the colorspace.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_buffer(mvSource, &buffer, &bufferSize), "Failed to get the buffer size.");
int conversionType;
switch (colorspace) {
MEDIA_VISION_NULL_ARG_CHECK(recognized_cb);
cv::Mat scene;
- MEDIA_VISION_ASSERT(MediaVision::Common::convertSourceMV2GrayCV(source, scene), "Failed to convert mv_source.");
+ MEDIA_VISION_CHECK_ERR(MediaVision::Common::convertSourceMV2GrayCV(source, scene), "Failed to convert mv_source.");
int ret = MEDIA_VISION_ERROR_NONE;
extractTrackingParams(engine_cfg, trackingParams);
cv::Mat frame;
- MEDIA_VISION_ASSERT(MediaVision::Common::convertSourceMV2GrayCV(source, frame), "Failed to convert mv_source.");
+ MEDIA_VISION_CHECK_ERR(MediaVision::Common::convertSourceMV2GrayCV(source, frame), "Failed to convert mv_source.");
MediaVision::Image::ImageTrackingModel *trackingModel =
(MediaVision::Image::ImageTrackingModel *) image_tracking_model;
MEDIA_VISION_INSTANCE_CHECK(source);
cv::Mat image;
- MEDIA_VISION_ASSERT(MediaVision::Common::convertSourceMV2GrayCV(source, image), "Failed to convert mv_source.");
+ MEDIA_VISION_CHECK_ERR(MediaVision::Common::convertSourceMV2GrayCV(source, image), "Failed to convert mv_source.");
std::vector<cv::Point2f> roi;
if (NULL != location) {
unsigned char *buffer = NULL;
mv_colorspace_e colorspace = MEDIA_VISION_COLORSPACE_INVALID;
- MEDIA_VISION_ASSERT(mv_source_get_width(source, &width), "Failed to get the width.");
- MEDIA_VISION_ASSERT(mv_source_get_height(source, &height), "Failed to get the height.");
- MEDIA_VISION_ASSERT(mv_source_get_colorspace(source, &colorspace), "Failed to get the colorspace.");
- MEDIA_VISION_ASSERT(mv_source_get_buffer(source, &buffer, &bufferSize), "Failed to get the buffer size.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_width(source, &width), "Failed to get the width.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_height(source, &height), "Failed to get the height.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_colorspace(source, &colorspace), "Failed to get the colorspace.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_buffer(source, &buffer, &bufferSize), "Failed to get the buffer size.");
LOGD(" w: %d, h: %d, c: %d", width, height, channels);
try {
unsigned int height = 0;
mv_colorspace_e colorspace = MEDIA_VISION_COLORSPACE_INVALID;
- MEDIA_VISION_ASSERT(mv_source_get_width(source, &width), "Failed to get the width.");
- MEDIA_VISION_ASSERT(mv_source_get_height(source, &height), "Failed to get the height.");
- MEDIA_VISION_ASSERT(mv_source_get_colorspace(source, &colorspace), "Failed to get the colorspace.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_width(source, &width), "Failed to get the width.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_height(source, &height), "Failed to get the height.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_colorspace(source, &colorspace), "Failed to get the colorspace.");
cv::Mat grayImage;
mv_colorspace_e colorspace = MEDIA_VISION_COLORSPACE_INVALID;
- MEDIA_VISION_ASSERT(mv_source_get_width(mvSource, &width), "Failed to get the width.");
- MEDIA_VISION_ASSERT(mv_source_get_height(mvSource, &height), "Failed to get the height.");
- MEDIA_VISION_ASSERT(mv_source_get_colorspace(mvSource, &colorspace), "Failed to get the colorspace.");
- MEDIA_VISION_ASSERT(mv_source_get_buffer(mvSource, &src, &bufferSize), "Failed to get the buffer size.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_width(mvSource, &width), "Failed to get the width.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_height(mvSource, &height), "Failed to get the height.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_colorspace(mvSource, &colorspace), "Failed to get the colorspace.");
+ MEDIA_VISION_CHECK_ERR(mv_source_get_buffer(mvSource, &src, &bufferSize), "Failed to get the buffer size.");
if (colorspace != MEDIA_VISION_COLORSPACE_RGB888) {
LOGE("Error: mv_source has unsupported colorspace.");