Add design QR finder shape
authorKwanghoon Son <k.son@samsung.com>
Fri, 3 Feb 2023 02:33:35 +0000 (11:33 +0900)
committerKwanghoon Son <k.son@samsung.com>
Mon, 13 Feb 2023 02:31:48 +0000 (11:31 +0900)
Change-Id: I9641480cbc213cc9862694d9c57614445a8d7a51
Signed-off-by: Kwanghoon Son <k.son@samsung.com>
media-vision-config.json
mv_barcode/barcode_generator/src/BarcodeGenerator.cpp
test/testsuites/barcode/test_barcode.cpp

index 1ae22ad..4f4f4e4 100644 (file)
             "name" : "MV_BARCODE_GENERATE_ATTR_DATA_SHAPE",
             "type"  : "integer",
             "value" : 0
+        },
+        {
+            "name" : "MV_BARCODE_GENERATE_ATTR_FINDER_SHAPE",
+            "type"  : "integer",
+            "value" : 0
         }
     ]
 }
index 92d2353..9b1e757 100644 (file)
@@ -117,6 +117,22 @@ int createBarcode(const std::string &message, BarcodeType type, BarcodeQREncodin
                                break;
                        }
                }
+
+               ret = engineCfg->getIntegerAttribute(MV_BARCODE_GENERATE_ATTR_FINDER_SHAPE, &value);
+
+               if (ret == MEDIA_VISION_ERROR_NONE) {
+                       switch (value) {
+                       case MV_BARCODE_GENERATE_ATTR_SHAPE_ROUND_RECT:
+                               symbol->output_options |= BARCODE_FINDER_ROUNDRECT;
+                               break;
+                       case MV_BARCODE_GENERATE_ATTR_SHAPE_CIRCLE:
+                               symbol->output_options |= BARCODE_FINDER_CIRCLE;
+                               break;
+
+                       default:
+                               break;
+                       }
+               }
        }
 
        if (type == BARCODE_QR) {
index beaf2eb..1068111 100644 (file)
@@ -158,4 +158,32 @@ TEST_F(TestBarcodeGen, DataCirclePositiveQR)
                                                                                qr_version, test_file.c_str(), image_format),
                          MEDIA_VISION_ERROR_NONE);
        ASSERT_EQ(mv_destroy_engine_config(engine_cfg), MEDIA_VISION_ERROR_NONE);
+}
+
+TEST_F(TestBarcodeGen, FinderCirclePositiveQR)
+{
+       ASSERT_EQ(mv_create_engine_config(&engine_cfg), MEDIA_VISION_ERROR_NONE);
+       ASSERT_EQ(mv_engine_config_set_string_attribute(engine_cfg, MV_BARCODE_GENERATE_ATTR_COLOR_FRONT, "3366ff"),
+                         MEDIA_VISION_ERROR_NONE);
+       ASSERT_EQ(mv_engine_config_set_int_attribute(engine_cfg, MV_BARCODE_GENERATE_ATTR_FINDER_SHAPE,
+                                                                                                MV_BARCODE_GENERATE_ATTR_SHAPE_CIRCLE),
+                         MEDIA_VISION_ERROR_NONE);
+       ASSERT_EQ(mv_barcode_generate_image(engine_cfg, "https://samsung.com/", 512, 512, type, qr_enc_mode, qr_ecc,
+                                                                               qr_version, test_file.c_str(), image_format),
+                         MEDIA_VISION_ERROR_NONE);
+       ASSERT_EQ(mv_destroy_engine_config(engine_cfg), MEDIA_VISION_ERROR_NONE);
+}
+
+TEST_F(TestBarcodeGen, FinderRoundRectPositiveQR)
+{
+       ASSERT_EQ(mv_create_engine_config(&engine_cfg), MEDIA_VISION_ERROR_NONE);
+       ASSERT_EQ(mv_engine_config_set_string_attribute(engine_cfg, MV_BARCODE_GENERATE_ATTR_COLOR_FRONT, "3366ff"),
+                         MEDIA_VISION_ERROR_NONE);
+       ASSERT_EQ(mv_engine_config_set_int_attribute(engine_cfg, MV_BARCODE_GENERATE_ATTR_FINDER_SHAPE,
+                                                                                                MV_BARCODE_GENERATE_ATTR_SHAPE_ROUND_RECT),
+                         MEDIA_VISION_ERROR_NONE);
+       ASSERT_EQ(mv_barcode_generate_image(engine_cfg, "https://samsung.com/", 512, 512, type, qr_enc_mode, qr_ecc,
+                                                                               qr_version, test_file.c_str(), image_format),
+                         MEDIA_VISION_ERROR_NONE);
+       ASSERT_EQ(mv_destroy_engine_config(engine_cfg), MEDIA_VISION_ERROR_NONE);
 }
\ No newline at end of file