public async void Sample1Jpg()
        {
            await _api.Init("eng");

            using (var stream = LoadSample("sample1.jpg")) {
                var result = await _api.SetImage(stream);

                Assert.IsTrue(result);
                Assert.AreEqual("The quick brown fox\njumped over the 5\nlazy dogs!\n\n", _api.Text);
                var data = _api.Results(PageIteratorLevel.Block).ToList();
                Assert.AreEqual(1, data.Count);
                Assert.AreEqual("The quick brown fox\njumped over the 5\nlazy dogs!\n\n", data [0].Text);
                data = _api.Results(PageIteratorLevel.Paragraph).ToList();
                Assert.AreEqual(1, data.Count);
                Assert.AreEqual("The quick brown fox\njumped over the 5\nlazy dogs!\n\n", data [0].Text);
                data = _api.Results(PageIteratorLevel.Symbol).ToList();
                Assert.AreEqual(39, data.Count);
                data = _api.Results(PageIteratorLevel.Textline).ToList();
                Assert.AreEqual(3, data.Count);
                Assert.AreEqual("The quick brown fox\n", data [0].Text);
                Assert.AreEqual("jumped over the 5\n", data [1].Text);
                Assert.AreEqual("lazy dogs!\n\n", data [2].Text);
                Assert.AreEqual(new Rectangle(37, 233, 415, 89), data [2].Box);
                data = _api.Results(PageIteratorLevel.Word).ToList();
                Assert.AreEqual(10, data.Count);
            }
        }
Exemplo n.º 2
0
        public async void OnPreviewFrame(byte[] data, Android.Hardware.Camera camera)
        {
            if (syncObj)
            {
                return;
            }
            if (!_api.Initialized)
            {
                return;
            }
            syncObj = true;
            await _api.SetImage(ConvertYuvToJpeg (data, camera));

            var results = _api.Results(PageIteratorLevel.Block);

            foreach (var result in results)
            {
                Log.Debug("TextureViewActivity", "Word: \"{0}\", confidence: {1}", result.Text, result.Confidence);
            }
            syncObj = false;
        }