#include "BarcodeOptions.h"
#include <EngineConfig.h>
+#include <mv_barcode_generate.h>
#include <mv_barcode_type.h>
#include <opencv2/core/mat.hpp>
#include <string>
{
namespace Barcode
{
+struct BarcodeConfig {
+ int update(mv_engine_config_h engine_cfg);
+
+ std::string message {};
+ mv_barcode_type_e type { MV_BARCODE_UNKNOWN };
+ mv_barcode_qr_mode_e qr_enc_mode { MV_BARCODE_QR_MODE_UNAVAILABLE };
+ mv_barcode_qr_ecc_e qr_ecc { MV_BARCODE_QR_ECC_UNAVAILABLE };
+ int qr_version {};
+ std::string image_path {};
+ int image_width {};
+ int image_height {};
+ mv_barcode_image_format_e image_format { MV_BARCODE_IMAGE_FORMAT_UNAVAILABLE };
+
+ //Engine config
+ int text_opt {};
+ std::string fgcolor { "000000" };
+ std::string bgcolor { "ffffff" };
+ mv_barcode_generate_attr_shape_e data_shape { MV_BARCODE_GENERATE_ATTR_SHAPE_RECT };
+ mv_barcode_generate_attr_shape_e finder_shape { MV_BARCODE_GENERATE_ATTR_SHAPE_RECT };
+};
+
int createBarcode(const std::string &message, BarcodeType type, BarcodeQREncodingMode encodingMode,
BarcodeQRErrorCorrectionLevel correctionLevel, int qrVersion, int showText, char *fgcolour,
char *bgcolour, zint_symbol *symbol, Common::EngineConfig *engineCfg);
BarcodeImageFormat convertImageFormat(mv_barcode_image_format_e format);
+void swapBR(uint16_t *color);
+
} /* Barcode */
} /* MediaVision */
return error;
}
+
+/*
+The input colorspace is RGB but the generators' is BGR.
+Replace the value of R with that of B
+*/
+void swapBR(uint16_t *color)
+{
+ std::swap(color[0], color[2]);
+}
+
+int BarcodeConfig::update(mv_engine_config_h engine_cfg)
+{
+ if (!engine_cfg)
+ return MEDIA_VISION_ERROR_NONE;
+
+ int showText;
+ int error = mv_engine_config_get_int_attribute(engine_cfg, MV_BARCODE_GENERATE_ATTR_TEXT, &showText);
+ if (error != MEDIA_VISION_ERROR_NONE) {
+ LOGE("mv_engine_config_get_int_attribute failed");
+ return error;
+ }
+
+ /* get color value */
+ char *fgcolor;
+ error = mv_engine_config_get_string_attribute(engine_cfg, MV_BARCODE_GENERATE_ATTR_COLOR_FRONT, &fgcolor);
+ if (error != MEDIA_VISION_ERROR_NONE) {
+ LOGE("mv_engine_config_get_string_attribute failed");
+ return error;
+ }
+ char *bgcolor;
+ error = mv_engine_config_get_string_attribute(engine_cfg, MV_BARCODE_GENERATE_ATTR_COLOR_BACK, &bgcolor);
+ if (error != MEDIA_VISION_ERROR_NONE) {
+ free(fgcolor);
+ LOGE("mv_engine_config_get_string_attribute failed");
+ return error;
+ }
+
+ swapBR((uint16_t *) fgcolor);
+ swapBR((uint16_t *) bgcolor);
+
+ text_opt = showText;
+ this->fgcolor = fgcolor;
+ this->bgcolor = bgcolor;
+
+ free(fgcolor);
+ free(bgcolor);
+
+ return MEDIA_VISION_ERROR_NONE;
+}
+
} /* Barcode */
} /* MediaVision */
#include "mv_barcode_generate_open.h"
using namespace std;
+using namespace MediaVision::Barcode;
+
/**
* @file mv_barcode_generate.c
* @brief This file contains the porting layer for Media Vision barcode module.
MEDIA_VISION_INSTANCE_CHECK(image);
MEDIA_VISION_CHECK_ERR(__check_barcode_param(message, type, qr_enc_mode, qr_ecc, qr_version), "Invalid parameter");
+ BarcodeConfig config { message, type, qr_enc_mode, qr_ecc, qr_version };
+
+ int ret = config.update(engine_cfg);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ return ret;
+ }
+
zint_symbol *symbol = ZBarcode_Create();
if (symbol == NULL) {
LOGE("ZBarcode creation failed");
return MEDIA_VISION_ERROR_INTERNAL;
}
- int ret = mv_barcode_generate_symbol(engine_cfg, message, type, qr_enc_mode, qr_ecc, qr_version, symbol);
+ ret = mv_barcode_generate_symbol(engine_cfg, message, type, qr_enc_mode, qr_ecc, qr_version, symbol);
if (ret != MEDIA_VISION_ERROR_NONE) {
ZBarcode_Delete(symbol);
return ret;
return MEDIA_VISION_ERROR_INVALID_DATA;
}
+ BarcodeConfig config { message, type, qr_enc_mode, qr_ecc, qr_version, image_path, image_height, image_format };
+
+ int ret = config.update(engine_cfg);
+ if (ret != MEDIA_VISION_ERROR_NONE) {
+ return ret;
+ }
+
zint_symbol *symbol = ZBarcode_Create();
if (symbol == NULL) {
LOGE("ZBarcode creation failed");
return MEDIA_VISION_ERROR_INTERNAL;
}
- int ret = mv_barcode_generate_symbol(engine_cfg, message, type, qr_enc_mode, qr_ecc, qr_version, symbol);
+ ret = mv_barcode_generate_symbol(engine_cfg, message, type, qr_enc_mode, qr_ecc, qr_version, symbol);
if (ret != MEDIA_VISION_ERROR_NONE) {
ZBarcode_Delete(symbol);
return ret;
return MEDIA_VISION_ERROR_NONE;
}
-/*
-The input colorspace is RGB but the generators' is BGR.
-Replace the value of R with that of B
-*/
-static void swapBR(uint16_t *color)
-{
- std::swap(color[0], color[2]);
-}
-
static int getColorFromEngine(mv_engine_config_h engine_cfg, mv_barcode_type_e type, int &showText, char **fgcolour,
char **bgcolour)
{