static string ReadQR(IBarcodeApi api, string fileName)
        {
            using (FileStream imageStream = File.OpenRead(fileName))
            {
                BarcodeResponseList recognized = api.PostBarcodeRecognizeFromUrlOrContent(
                    new PostBarcodeRecognizeFromUrlOrContentRequest(image: imageStream)
                    );

                return(recognized.Barcodes[0].BarcodeValue);
            }
        }
Exemplo n.º 2
0
        public void PostBarcodeRecognizeFromUrlOrContentTest()
        {
            // Arrange
            using Stream image = GetTestImage("1.png");

            // Act
            BarcodeResponseList response = _api.PostBarcodeRecognizeFromUrlOrContent(
                new PostBarcodeRecognizeFromUrlOrContentRequest(
                    image: image,
                    checksumValidation: ChecksumValidation.Off.ToString(),
                    preset: PresetType.HighPerformance.ToString()
                    )
                );

            // Assert
            Assert.AreEqual(1, response.Barcodes.Count);
            Assert.AreEqual(DecodeBarcodeType.Code11.ToString(), response.Barcodes[0].Type);
            Assert.AreEqual("1234567812", response.Barcodes[0].BarcodeValue);
        }
Exemplo n.º 3
0
        public void RecognizeQrTest()
        {
            // Arrange
            using Stream image = GetTestImage("Test_PostGenerateMultiple.png");

            // Act
            BarcodeResponseList response = _api.PostBarcodeRecognizeFromUrlOrContent(
                new PostBarcodeRecognizeFromUrlOrContentRequest(
                    image: image,
                    preset: PresetType.HighPerformance.ToString(),
                    type: DecodeBarcodeType.QR.ToString()
                    )
                );

            // Assert
            Assert.AreEqual(1, response.Barcodes.Count);
            Assert.AreEqual(DecodeBarcodeType.QR.ToString(), response.Barcodes[0].Type);
            Assert.AreEqual("Hello world!", response.Barcodes[0].BarcodeValue);
        }
Exemplo n.º 4
0
        public void GenerateAndThenRecognizeTest()
        {
            Stream generated = _api.GetBarcodeGenerate(new GetBarcodeGenerateRequest(
                                                           EncodeBarcodeType.QR.ToString(), "Test"));

            BarcodeResponseList recognized = _api.PostBarcodeRecognizeFromUrlOrContent(
                new PostBarcodeRecognizeFromUrlOrContentRequest(
                    image: generated
                    ));

            Assert.AreEqual(1, recognized.Barcodes.Count);
            Assert.AreEqual(DecodeBarcodeType.QR.ToString(), recognized.Barcodes.First().Type);
            Assert.AreEqual("Test", recognized.Barcodes.First().BarcodeValue);
            Assert.AreEqual(
                "{\"barcodes\":[{" +
                "\"barcodeValue\":\"Test\"," +
                "\"type\":\"QR\"," +
                "\"region\":[{\"x\":7,\"y\":7},{\"x\":49,\"y\":7},{\"x\":49,\"y\":49},{\"x\":7,\"y\":49}]," +
                "\"checksum\":null}]}",
                recognized.ToString()
                );
        }