summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTae-Young Chung <ty83.chung@samsung.com>2015-09-08 15:02:57 +0900
committerTae-Young Chung <ty83.chung@samsung.com>2015-09-08 15:03:51 +0900
commit3ace8455345a99184523848d704a20ad6810619c (patch)
treea222689a602744d56ecb9a8ad6afd1db70b8234b
parentf9a7bf0d54a3c6d5369973613ce2d7b26fb4f98b (diff)
downloadmediavision-3ace8455345a99184523848d704a20ad6810619c.tar.gz
mediavision-3ace8455345a99184523848d704a20ad6810619c.tar.bz2
mediavision-3ace8455345a99184523848d704a20ad6810619c.zip
Change-Id: I7be7c55d9a92015bf99af7110c4d1ab3daf6fd2e Signed-off-by: Tae-Young Chung <ty83.chung@samsung.com>
-rw-r--r--include/mv_barcode_detect.h36
-rw-r--r--include/mv_barcode_generate.h36
-rw-r--r--include/mv_common.h4
-rw-r--r--media-vision-config.json7
-rw-r--r--mv_barcode/barcode_generator/include/BarcodeGenerator.h8
-rw-r--r--mv_barcode/barcode_generator/include/BarcodeOptions.h11
-rw-r--r--mv_barcode/barcode_generator/src/BarcodeGenerator.cpp35
-rw-r--r--mv_barcode/barcode_generator/src/mv_barcode_generate_open.cpp38
8 files changed, 129 insertions, 46 deletions
diff --git a/include/mv_barcode_detect.h b/include/mv_barcode_detect.h
index 77be2225..b3981b66 100644
--- a/include/mv_barcode_detect.h
+++ b/include/mv_barcode_detect.h
@@ -35,18 +35,7 @@ extern "C" {
*/
/**
- * @brief Define MV_BARCODE_DETECT_ATTR_MODE to set mode attribute of the engine
- * configuration.
- *
- * @since_tizen 2.4
- *
- * @see mv_barcode_detect_attr_mode_e
- */
-#define MV_BARCODE_DETECT_ATTR_MODE "MV_BARCODE_DETECT_ATTR_MODE" /**< Mode: 0-image, 1-video*/
-
-/**
- * @brief Define MV_BARCODE_DETECT_ATTR_TARGET to set target attribute of the
- * engine configuration.
+ * @brief Define MV_BARCODE_DETECT_ATTR_TARGET to set target attribute of the engine configuration
*
* @since_tizen 2.4
*
@@ -55,28 +44,17 @@ extern "C" {
#define MV_BARCODE_DETECT_ATTR_TARGET "MV_BARCODE_DETECT_ATTR_TARGET" /**< Target: 0-all, 1-1D, 2-2D*/
/**
- * @brief Enumeration to mode attribute.
+ * @brief Enumeration to target attribute
*
* @since_tizen 2.4
*/
-typedef enum
-{
- MV_BARCODE_DETECT_ATTR_MODE_IMAGE, /**< Still image */
- MV_BARCODE_DETECT_ATTR_MODE_VIDEO /**< Continuous video */
-} mv_barcode_detect_attr_mode_e;
-
-/**
- * @brief Enumeration to target attribute.
- *
- * @since_tizen 2.4
- */
-typedef enum
-{
- MV_BARCODE_DETECT_ATTR_TARGET_ALL, /**< 1D and 2D */
- MV_BARCODE_DETECT_ATTR_TARGET_1D_BARCODE, /**< 1D barcode only */
- MV_BARCODE_DETECT_ATTR_TARGET_2D_BARCODE, /**< 2D barcode only */
+typedef enum {
+ MV_BARCODE_DETECT_ATTR_TARGET_ALL, /**< 1D and 2D */
+ MV_BARCODE_DETECT_ATTR_TARGET_1D_BARCODE, /**< 1D barcode only */
+ MV_BARCODE_DETECT_ATTR_TARGET_2D_BARCODE, /**< 2D barcode only */
} mv_barcode_detect_attr_target_e;
+
/**
* @brief Called when barcode detection is completed.
* @details If no barcode is detected then the method will be called, barcodes
diff --git a/include/mv_barcode_generate.h b/include/mv_barcode_generate.h
index 6d82709c..1662525e 100644
--- a/include/mv_barcode_generate.h
+++ b/include/mv_barcode_generate.h
@@ -35,6 +35,30 @@ extern "C" {
*/
/**
+ * @brief Define MV_BARCODE_GENERATE_ATTR_TEXT to set text attribute
+ of the engine configuration
+ *
+ * @since_tizen 2.4
+ * @remarks This attribute is only available for 1D barcode generation
+ *
+ * @see mv_barcode_generate_attr_text_e
+ */
+#define MV_BARCODE_GENERATE_ATTR_TEXT "MV_BARCODE_GENERATE_ATTR_TEXT" /**< Text:
+ 0-invisible,
+ 1-visible */
+
+/**
+ * @brief Enumeration to text attribute
+ *
+ * @since_tizen 2.4
+ */
+typedef enum {
+ MV_BARCODE_GENERATE_ATTR_TEXT_INVISIBLE, /**< Invisible */
+ MV_BARCODE_GENERATE_ATTR_TEXT_VISIBLE, /**< Visible */
+} mv_barcode_generate_attr_text_e;
+
+
+/**
* @brief Generates @ref mv_source_h with barcode image.
* @details Pay attention that for EAN-8 and EAN-13 barcode types the barcode
* type may be selected automatically and this selection depends on the input
@@ -42,6 +66,11 @@ extern "C" {
* required to generate QR code with the input message length.
*
* @since_tizen 2.4
+ * @remarks If the text attribute of engine configuration is set to
+ * MV_BARCODE_GENERATE_ATTR_TEXT_VISIBLE,
+ * MEDIA_VISION_ERROR_INVALID_OPERATION will be return
+ * when @a type is MV_BARCODE_QR
+ *
* @param [in] engine_cfg The handle to the configuration of the engine
* @param [in] message The message to be encoded in the barcode
* @param [in] type Type of the barcode to be generated
@@ -62,6 +91,7 @@ extern "C" {
* @retval #MEDIA_VISION_ERROR_NOT_SUPPORTED Not supported
* @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid data
* @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
*
* @pre Create an engine configuration handle by calling
* @ref mv_create_engine_config(), otherwise use NULL
@@ -85,6 +115,11 @@ int mv_barcode_generate_source(
* required to generate QR code with the input message length.
*
* @since_tizen 2.4
+ * @remarks If the text attribute of engine configuration is set to
+ * MV_BARCODE_GENERATE_ATTR_TEXT_VISIBLE,
+ * MEDIA_VISION_ERROR_INVALID_OPERATION will be return
+ * when @a type is MV_BARCODE_QR
+ *
* @remarks The mediastorage privilege http://tizen.org/privilege/mediastorage is needed \n
if @a image_path is relevant to media storage.\n
The externalstorage privilege http://tizen.org/privilege/externalstorage is needed \n
@@ -113,6 +148,7 @@ int mv_barcode_generate_source(
* @retval #MEDIA_VISION_ERROR_INVALID_DATA Invalid data
* @retval #MEDIA_VISION_ERROR_INVALID_PATH Invalid path
* @retval #MEDIA_VISION_ERROR_INTERNAL Internal error
+ * @retval #MEDIA_VISION_ERROR_INVALID_OPERATION Invalid operation
*
* @pre Create an engine configuration handle by calling
* @ref mv_create_engine_config(), otherwise use NULL
diff --git a/include/mv_common.h b/include/mv_common.h
index ff3a5e5a..f8eb83e2 100644
--- a/include/mv_common.h
+++ b/include/mv_common.h
@@ -439,8 +439,8 @@ int mv_engine_config_set_double_attribute(
* @see mv_engine_config_set_double_attribute()
* @see mv_engine_config_set_bool_attribute()
* @see mv_engine_config_set_string_attribute()
- * @see mv_barcode_detect_attr_mode_e
* @see mv_barcode_detect_attr_target_e
+ * @see mv_barcode_generate_attr_text_e
*/
int mv_engine_config_set_int_attribute(
mv_engine_config_h engine_cfg,
@@ -547,8 +547,8 @@ int mv_engine_config_get_double_attribute(
* @see mv_engine_config_get_double_attribute()
* @see mv_engine_config_get_bool_attribute()
* @see mv_engine_config_get_string_attribute()
- * @see mv_barcode_detect_attr_mode_e
* @see mv_barcode_detect_attr_target_e
+ * @see mv_barcode_generate_attr_text_e
*/
int mv_engine_config_get_int_attribute(
mv_engine_config_h engine_cfg,
diff --git a/media-vision-config.json b/media-vision-config.json
index 902567e2..a3d6eeea 100644
--- a/media-vision-config.json
+++ b/media-vision-config.json
@@ -36,10 +36,9 @@
"type" : "integer",
"value" : -1,
},
- {
- "name" : "MV_BARCODE_DETECT_ATTR_MODE",
- "type" : "integer",
- "value" : 1,
+ { "name" : "MV_BARCODE_GENERATE_ATTR_TEXT",
+ "type" : "integer",
+ "value" : 0,
},
{
"name" : "MV_BARCODE_DETECT_ATTR_TARGET",
diff --git a/mv_barcode/barcode_generator/include/BarcodeGenerator.h b/mv_barcode/barcode_generator/include/BarcodeGenerator.h
index 8640683c..40659aea 100644
--- a/mv_barcode/barcode_generator/include/BarcodeGenerator.h
+++ b/mv_barcode/barcode_generator/include/BarcodeGenerator.h
@@ -54,6 +54,7 @@ public:
* @param [in] encodingMode Encoding mode (for QR codes only)
* @param [in] correctionLevel Error correction level (for QR codes only)
* @param [in] qrVersion QR code version (1 ~ 40, 0 for 1D barcodes)
+ * @param [in] showText Show text or not
* @return BARCODE_ERROR_NONE from BarcodeError which is 0 if success,
* BarcodeError value otherwise
*/
@@ -66,7 +67,8 @@ public:
BarcodeType type,
BarcodeQREncodingMode encodingMode = BARCODE_QR_MODE_UNAVAILABLE,
BarcodeQRErrorCorrectionLevel correctionLevel = BARCODE_QR_ECC_UNAVAILABLE,
- int qrVersion = 0);
+ int qrVersion = 0,
+ int showText = 0);
/**
* @brief This method generates Barcodes image buffer according to options.
@@ -81,6 +83,7 @@ public:
* @param [in] encodingMode Encoding mode (for QR codes only)
* @param [in] correctionLevel Error correction level (for QR codes only)
* @param [in] qrVersion QR code version (1 ~ 40, 0 for 1D barcodes)
+ * @param [in] showText Show text or not
* @return BARCODE_ERROR_NONE from BarcodeError which is 0 if success,
* BarcodeError value otherwise
*/
@@ -93,7 +96,8 @@ public:
BarcodeType type,
BarcodeQREncodingMode encodingMode = BARCODE_QR_MODE_UNAVAILABLE,
BarcodeQRErrorCorrectionLevel correctionLevel = BARCODE_QR_ECC_UNAVAILABLE,
- int qrVersion = 0);
+ int qrVersion = 0,
+ int showText = 0);
};
} /* Barcode */
diff --git a/mv_barcode/barcode_generator/include/BarcodeOptions.h b/mv_barcode/barcode_generator/include/BarcodeOptions.h
index 4da3b90d..c6435500 100644
--- a/mv_barcode/barcode_generator/include/BarcodeOptions.h
+++ b/mv_barcode/barcode_generator/include/BarcodeOptions.h
@@ -89,6 +89,17 @@ enum BarcodeImageFormat
};
/**
+ * @brief The Barcode generation text option enumeration.
+ *
+ * @since_tizen 2.4
+ */
+enum BarcodeGenTextOpt
+{
+ BARCODE_GEN_TEXT_INVISIBLE,
+ BARCODE_GEN_TEXT_VISIBLE
+};
+
+/**
* @brief The Barcode error enumeration.
*
* @since_tizen 2.4
diff --git a/mv_barcode/barcode_generator/src/BarcodeGenerator.cpp b/mv_barcode/barcode_generator/src/BarcodeGenerator.cpp
index 8e1d85dd..624a3f51 100644
--- a/mv_barcode/barcode_generator/src/BarcodeGenerator.cpp
+++ b/mv_barcode/barcode_generator/src/BarcodeGenerator.cpp
@@ -74,6 +74,7 @@ int createBarcode(
BarcodeQREncodingMode encodingMode,
BarcodeQRErrorCorrectionLevel correctionLevel,
int qrVersion,
+ int showText,
zint_symbol *symbol)
{
// set input values
@@ -82,14 +83,20 @@ int createBarcode(
symbol->option_1 = correctionLevel;
symbol->option_2 = qrVersion;
symbol->scale = 1;
+ symbol->show_hrt = showText;
// set default values
- std::strcpy(symbol->fgcolour, "000000");
- std::strcpy(symbol->bgcolour, "ffffff");
+ std::strncpy(symbol->fgcolour, "000000", 10);
+ std::strncpy(symbol->bgcolour, "ffffff", 10);
symbol->border_width = 1;
- symbol->whitespace_width = 0;
symbol->height = 50;
+ if (type == BARCODE_QR) {
+ symbol->whitespace_width = 0;
+ } else {
+ symbol->whitespace_width = 10;
+ }
+
// create barcode
const int rotationAngle = 0;
int error = ZBarcode_Encode_and_Buffer(
@@ -195,16 +202,25 @@ int BarcodeGenerator::generateBarcodeToImage(
BarcodeType type,
BarcodeQREncodingMode encodingMode,
BarcodeQRErrorCorrectionLevel correctionLevel,
- int qrVersion)
+ int qrVersion,
+ int showText)
{
zint_symbol *symbol = ZBarcode_Create();
+ if(symbol == NULL)
+ {
+ LOGE("ZBarcode creation failed");
+
+ return BARCODE_ERROR_ENCODING_PROBLEM;
+ }
+
int error = createBarcode(
message,
type,
encodingMode,
correctionLevel,
qrVersion,
+ showText,
symbol);
if (error != BARCODE_ERROR_NONE)
@@ -243,16 +259,25 @@ int BarcodeGenerator::generateBarcodeToBuffer(
BarcodeType type,
BarcodeQREncodingMode encodingMode,
BarcodeQRErrorCorrectionLevel correctionLevel,
- int qrVersion)
+ int qrVersion,
+ int showText)
{
zint_symbol *symbol = ZBarcode_Create();
+ if(symbol == NULL)
+ {
+ LOGE("ZBarcode creation failed");
+
+ return BARCODE_ERROR_ENCODING_PROBLEM;
+ }
+
int error = createBarcode(
message,
type,
encodingMode,
correctionLevel,
qrVersion,
+ showText,
symbol);
if (error != BARCODE_ERROR_NONE)
diff --git a/mv_barcode/barcode_generator/src/mv_barcode_generate_open.cpp b/mv_barcode/barcode_generator/src/mv_barcode_generate_open.cpp
index 1aa3034c..19657d3e 100644
--- a/mv_barcode/barcode_generator/src/mv_barcode_generate_open.cpp
+++ b/mv_barcode/barcode_generator/src/mv_barcode_generate_open.cpp
@@ -197,7 +197,7 @@ BarcodeImageFormat convertImageFormat(mv_barcode_image_format_e format)
} /* anonymous namespace */
int mv_barcode_generate_source_open(
- mv_engine_config_h /*engine_cfg*/,
+ mv_engine_config_h engine_cfg,
const char *message,
mv_barcode_type_e type,
mv_barcode_qr_mode_e qr_enc_mode,
@@ -231,6 +231,20 @@ int mv_barcode_generate_source_open(
unsigned int imageHeight = 0u;
unsigned int imageChannels = 0u;
+ int showText = 0;
+ error = mv_engine_config_get_int_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_TEXT", &showText);
+ if (error != MEDIA_VISION_ERROR_NONE)
+ {
+ LOGW("mv_engine_config_get_int_attribute failed");
+ return error;
+ }
+
+ if (showText == BARCODE_GEN_TEXT_VISIBLE && type == MV_BARCODE_QR)
+ {
+ LOGW("QR code generation with visible text is not supported");
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+
error = BarcodeGenerator::generateBarcodeToBuffer(
&imageBuffer,
&imageWidth,
@@ -240,7 +254,8 @@ int mv_barcode_generate_source_open(
convertBarcodeType(type),
convertEncodingMode(qr_enc_mode),
convertECC(qr_ecc),
- qr_version);
+ qr_version,
+ showText);
if (error != BARCODE_ERROR_NONE)
{
@@ -283,7 +298,7 @@ int mv_barcode_generate_source_open(
int mv_barcode_generate_image_open(
- mv_engine_config_h /*engine_cfg*/,
+ mv_engine_config_h engine_cfg,
const char *message,
int image_width,
int image_height,
@@ -321,6 +336,20 @@ int mv_barcode_generate_image_open(
}
}
+ int showText = 0;
+ error = mv_engine_config_get_int_attribute(engine_cfg, "MV_BARCODE_GENERATE_ATTR_TEXT", &showText);
+ if (error != MEDIA_VISION_ERROR_NONE)
+ {
+ LOGW("mv_engine_config_get_int_attribute failed");
+ return error;
+ }
+
+ if (showText == BARCODE_GEN_TEXT_VISIBLE && type == MV_BARCODE_QR)
+ {
+ LOGW("QR code generation with visible text is not supported");
+ return MEDIA_VISION_ERROR_INVALID_OPERATION;
+ }
+
error = BarcodeGenerator::generateBarcodeToImage(
std::string(image_path),
convertImageFormat(image_format),
@@ -330,7 +359,8 @@ int mv_barcode_generate_image_open(
convertBarcodeType(type),
convertEncodingMode(qr_enc_mode),
convertECC(qr_ecc),
- qr_version);
+ qr_version,
+ showText);
if (error != BARCODE_ERROR_NONE)
{