Add draw_logo check, comment
authorKwanghoon Son <k.son@samsung.com>
Wed, 10 Jul 2024 00:08:07 +0000 (09:08 +0900)
committerKwanghoon Son <k.son@samsung.com>
Fri, 26 Jul 2024 03:49:18 +0000 (12:49 +0900)
Change-Id: I1033ff296547ac6490ea4c4148d8de509ea79f70
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
mv_barcode/barcode_generator/src/BarcodeGenerator.cpp

index 0c0ee88845ed4db062d392833f3286d4cbcb676a..6cb608fb60280fb02763967eecc26606284a8edc 100644 (file)
@@ -307,8 +307,16 @@ static void __round_rect(cv::Mat &inOutImg, cv::Rect &rect, cv::Scalar &color)
        cv::circle(inOutImg, cv::Point(rect.x + 3 * gapW, rect.y + 3 * gapH), gapW, color, -1);
 }
 
-static int __draw_logo(cv::Mat &image, const BarcodeConfig &config)
+/*
+ * Use only for mv_barcode_generate_image because,
+ * QR code size is maximum 177x177, then logo will be (35x35).
+ * mv_barcode_generate_image support user-defined resize, so user can set size detail.
+ */
+static void __draw_logo(cv::Mat &image, const BarcodeConfig &config)
 {
+       if (config.logo_path.empty() || config.type != MV_BARCODE_QR)
+               return;
+
        auto logo = cv::imread(config.logo_path.c_str(), cv::IMREAD_COLOR);
 
        int color_decimal = strtol(config.bgcolor.c_str(), nullptr, 16);
@@ -349,8 +357,6 @@ static int __draw_logo(cv::Mat &image, const BarcodeConfig &config)
        cv::multiply(cv::Scalar::all(1.0) - maskMat, image, image);
        cv::multiply(maskMat / 255, logoMat, logoMat);
        cv::add(logoMat, image, image);
-
-       return MEDIA_VISION_ERROR_NONE;
 }
 
 int write_buffer_to_img(zint_symbol *symbol, const BarcodeConfig &config)
@@ -400,14 +406,7 @@ int write_buffer_to_img(zint_symbol *symbol, const BarcodeConfig &config)
 
        cv::Mat image(symbol->bitmap_height, symbol->bitmap_width, CV_8UC3, symbol->bitmap);
        cv::resize(image, image, cv::Size(config.image_width, config.image_height), 0, 0, cv::INTER_AREA);
-
-       if (!config.logo_path.empty()) {
-               error = __draw_logo(image, config);
-               if (error != MEDIA_VISION_ERROR_NONE) {
-                       LOGE("__draw_logo error code : %d", error);
-                       return error;
-               }
-       }
+       __draw_logo(image, config);
 
        error = cv::imwrite(resultFilePath, image, compressionParams) ? BARCODE_ERROR_NONE : BARCODE_ERROR_INVALID_DATA;