Exemplo n.º 1
0
        public void Create()
        {
            Assert.True(File.Exists(modelArch), $"modelArch '{modelArch}' not found");
            Assert.True(File.Exists(modelWeights), $"modelWeights '{modelWeights}' not found");
            Assert.True(new FileInfo(modelWeights).Length > 10_000_000);

            using (var detector = TextDetectorCNN.Create(modelArch, modelWeights))
            {
                GC.KeepAlive(detector);
            }
        }
Exemplo n.º 2
0
        public void Create()
        {
            Assert.True(File.Exists(ModelArch), $"modelArch '{ModelArch}' not found");
            Assert.True(File.Exists(ModelWeights), $"modelWeights '{ModelWeights}' not found");

            var modelWeightsFileInfo = new FileInfo(ModelWeights);

            Assert.True(modelWeightsFileInfo.Length > 10_000_000, $"{Path.GetFullPath(ModelWeights)}: {modelWeightsFileInfo.Length} bytes");

            using (var detector = TextDetectorCNN.Create(ModelArch, ModelWeights))
            {
                GC.KeepAlive(detector);
            }
        }
Exemplo n.º 3
0
        public void Detect()
        {
            using var detector = TextDetectorCNN.Create(ModelArch, ModelWeights);
            using var image    = Image("imageTextR.png", ImreadModes.Color);
            detector.Detect(image, out var boxes, out var confidences);

            Assert.NotEmpty(boxes);
            Assert.NotEmpty(confidences);
            Assert.Equal(boxes.Length, confidences.Length);

            if (Debugger.IsAttached)
            {
                foreach (var box in boxes)
                {
                    image.Rectangle(box, Scalar.Red, 2);
                }
                Window.ShowImages(image);
            }
        }