예제 #1
0
        public MainPage()
        {
            InitializeComponent();

            g_tss = Resolver.Resolve <ITesseractApi>();
            g_tss.Init("eng", OcrEngineMode.TesseractOnly);
        }
예제 #2
0
 public MainPage()
 {
     InitializeComponent();
     BindingContext = this;
     _tesseractApi  = Resolver.Resolve <ITesseractApi>();
     _device        = Resolver.Resolve <IDevice>();
     initialize();
 }
예제 #3
0
        public HomePage()
        {
            _tesseractApi = Resolver.Resolve <ITesseractApi>();
            _device       = Resolver.Resolve <IDevice>();

            BuildUi();

            WireEvents();
        }
        public MainPage()
        {
            InitializeComponent();

            _tesseractApi = Resolver.Resolve <ITesseractApi>();
            _device       = Resolver.Resolve <IDevice>();

            BuildUi();
            WireEvents();
        }
예제 #5
0
        async Task <string> Ocr()
        {
            ITesseractApi api = DependencyService.Get <ITesseractService>().Init();
            await api.Init("spa");

            string file = "/storage/emulated/0/Android/data/mydata/textSpaCrop.png";
            await api.SetImage(file);

            return(api.Text);
        }
        public ScanViewModel()
        {
            _tesseract            = DependencyService.Get <ITesseract>().TesseractApi;
            _openCVService        = DependencyService.Get <IOpenCVService>();
            ReturnNavCommand      = new Command(async() => await ExecuteReturnNavCommand());
            OpenCameraCommand     = new Command(async() => await ExecuteOpenCameraCommand());
            ConfirmReadingCommand = new Command(async() => await ExecuteConfirmReadingCommand());

            MessagingCenter.Subscribe <CameraResultMessage>(this, CameraResultMessage.Key, async(sender) => await HandleResult(sender));
        }
예제 #7
0
파일: HomePage.cs 프로젝트: fferegrino/xocr
        public HomePage()
        {
			if (Device.OS == TargetPlatform.iOS)
				Padding = new Thickness (0, 25, 0, 0);

            _tesseractApi = Resolver.Resolve<ITesseractApi>();
            _device = Resolver.Resolve<IDevice>();

            BuildUi();

            WireEvents();
        }
예제 #8
0
        public OcrAppPage()
        {
            InitializeComponent();

            if (Device.OS == TargetPlatform.iOS)
            {
                Padding = new Thickness(0, 25, 0, 0);
            }

            tesseractApi = Resolver.Resolve <ITesseractApi>();
            device       = Resolver.Resolve <IDevice>();
        }
예제 #9
0
        //private string _path = "img/1.png";

        public MainPage()
        {
            InitializeComponent();

            _tesseract = NinjectIoC.Container.Get <ITesseractApi>();

            _processAssert = NinjectIoC.Container.Get <IProcessAssert>();

            //img.Source = ImageSource.FromStream(() => { return _processAssert.GetStreamByPath(_path); });

            btn_submit.Clicked += Click;
        }
예제 #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            tesseract = new TesseractApi(Application.Context, AssetsDeployment.OncePerVersion);

            mTextureView = new TextureView(this)
            {
                SurfaceTextureListener = this
            };

            SetContentView(mTextureView);
        }
예제 #11
0
        public HomePage()
        {
            if (Device.OS == TargetPlatform.iOS)
            {
                Padding = new Thickness(0, 25, 0, 0);
            }

            _tesseractApi = Resolver.Resolve <ITesseractApi>();
            _device       = Resolver.Resolve <IDevice>();

            BuildUi();

            WireEvents();
        }
 public void Setup ()
 {
     _api = new TesseractApi ();
 }
예제 #13
0
 public MainPage()
 {
     InitializeComponent();
     _mediaPicker = Resolver.Resolve <IMediaPicker>();
     _tesseract   = Resolver.Resolve <ITesseractApi>();
 }
예제 #14
0
 public Tesseract()
 {
     TesseractApi = new TesseractApi();
 }
 public void Setup ()
 {
     _api = new TesseractApi (Android.App.Application.Context);
 }
 public void Tear ()
 {
     _api.Dispose ();
     _api = null;
 }
예제 #17
0
 public MainPage ()
 {
     InitializeComponent ();
     _mediaPicker = Resolver.Resolve<IMediaPicker> ();
     _tesseract = Resolver.Resolve<ITesseractApi> ();
 }
예제 #18
0
        public MainPage()
        {
            InitializeComponent();
            api = DependencyService.Get <ITesseractApi>();

            /*CameraButton.Clicked += async (sender, args) =>
             * {
             *
             *  await CrossMedia.Current.Initialize();
             *
             *  var file = await CrossMedia.Current.TakePhotoAsync(new StoreCameraMediaOptions
             *  {
             *      Directory = "MedSticker",
             *      Name = "sticker.jpg"
             *  });
             *
             *  if (file == null)
             *      return;
             *  System.IO.Stream photoStream = file.GetStream();
             *
             *
             *  //photo.Source = ImageSource.FromStream(() =>
             *  // {
             *  //     var stream = file.GetStream();
             *  //file.Dispose();
             *  //     return stream;
             *  // });
             *
             *  NameEntry.Text  = "1";
             *  //Photo.Source = ImageSource.FromStream(file.GetStream); //debug code
             *  Bitmap bitmap = new Bitmap(photoStream);
             *  Stream stream2 = RaiseContrast(bitmap);
             *  //Photo.Source = ImageSource.FromStream(() => stream2);
             *  bool initialised = await api.Init("eng");
             *  NameEntry.Text += "2";
             *  api.SetWhitelist("0123456789:-,#'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz");
             *  bool success = await api.SetImage(stream2);
             *  NameEntry.Text += "3";
             *  if (success)
             *  {
             *      //List<Result> lines = api.Results(PageIteratorLevel.Textline);
             *      //List<Result> words = api.Results(PageIteratorLevel.Word);
             *      List<Result> results = api.Results(PageIteratorLevel.Symbol).ToList();
             *      //List<Result> blocks = api.Results(PageIteratorLevel.Block);
             *
             *      //List<Result> results = api.Res    ults(PageIteratorLevel.Paragraph).ToList();
             *      var res = " ";
             *      var conf = " ";
             *      foreach(Result r in results)
             *      {
             *          if (r.Confidence > 85f)
             *          {
             *              res += r.Text.ToUpper();
             *              conf += r.Confidence.ToString() + " ";
             *          }
             *
             *      }
             *      SexEntry.Text = api.Text;
             *      MREntry.Text = conf;
             *      //SexLabel.Text = res;
             *
             *
             *  }
             *  else
             *  {
             *
             *      NameEntry.Text = "Image Recognition Failed";
             *  }
             *
             * }; */
        }
 public void Tear()
 {
     _api.Dispose();
     _api = null;
 }
 public void Setup()
 {
     _api = new TesseractApi();
 }
 public async void Sample3AllModes ()
 {
     using (_api = new TesseractApi (Android.App.Application.Context, AssetsDeployment.OncePerInitialization)) {
         foreach (var engineMode in Enum.GetValues(typeof(OcrEngineMode))) {
             Console.WriteLine ("Engine mode: {0}", engineMode);
             await _api.Init ("eng", (OcrEngineMode)engineMode);
             foreach (var segmentationMode in Enum.GetValues(typeof(PageSegmentationMode))) {
                 _api.SetPageSegmentationMode ((PageSegmentationMode)segmentationMode);
                 using (var stream = LoadSample ("sample3.png")) {
                     var result = await _api.SetImage (stream);
                     Assert.IsTrue (result);
                     Console.WriteLine ("Segmentation mode: {0}, result: \"{1}\"", segmentationMode, _api.Text.Replace ("\n", " "));
                 }
             }
         }
     }
 }
 public MeterReaderSettings(ITesseractApi tesseractApi)
 {
     TesseractApi = tesseractApi;
 }
예제 #23
0
 public Tesseract()
 {
     TesseractApi = new TesseractApi(Android.App.Application.Context, AssetsDeployment.OncePerInitialization);
 }
 public void Setup ()
 {
     _api = new TesseractApi (Android.App.Application.Context, AssetsDeployment.OncePerInitialization);
 }
예제 #25
0
        public CalKnightsViewModel()
        {
            _tesseractApi = Resolver.Resolve <ITesseractApi>();
            _device       = Resolver.Resolve <IDevice>();
            _dicts        = new Dictionary <string, string>
            {
                { "vanguard", "test" }
            };

            PickImageCommand = new Command(
                execute: async() =>
            {
                ImageWaiting = false;

                if (!_tesseractApi.Initialized)
                {
                    await _tesseractApi.Init("kor", OcrEngineMode.TesseractOnly);
                    _tesseractApi.SetPageSegmentationMode(PageSegmentationMode.SparseText);
                }

                var imageFile = await TakePic();
                if (imageFile != null)
                {
                    //var imgStream = imageFile.GetStream();
                    //int imgLen = (int)imgStream.Length;
                    //var bytes = new byte[imgLen];

                    //imgStream.Position = 0;
                    //imgStream.Read(bytes, 0, imgLen);
                    //for (int i = 0; i < imgLen; i++)
                    //    bytes[i] = (byte)(0xFF ^ bytes[i]);

                    //var memoryStream = new MemoryStream();
                    //await mediaFile.GetStream().CopyToAsync(memoryStream);
                    //byte[] imageAsByte = memoryStream.ToArray();
                    byte[] bytes;

                    using (Stream stream = imageFile.GetStream())
                    {
                        //await stream.CopyToAsync(memStream);
                        //memStream.Seek(0, SeekOrigin.Begin);
                        var bitmap = SKBitmap.Decode(stream);

                        var img    = SKImage.FromBitmap(bitmap);
                        int height = img.Height;
                        int width  = img.Width;

                        var subset = SKRectI.Create(
                            (int)(width * 0.2f), (int)(height * 0.4f),
                            (int)(width * 0.5f), (int)(height * 0.3f));
                        var placeholder  = SKRectI.Empty;
                        var placeholder2 = SKPointI.Empty;

                        var img2 = img.ApplyImageFilter(
                            SKImageFilter.CreateColorFilter(_greyFilter),
                            subset, subset, out placeholder, out placeholder2);
                        if (img2 == null)
                        {
                            Debug.WriteLine("ISNULL");
                        }
                        img = img.Subset(subset);

                        bytes          = img.Encode().ToArray();
                        OCRImageSource = ImageSource.FromStream(() =>
                        {
                            return(new MemoryStream(bytes));
                        });
                    }

                    // ImageSource.FromStream(() => { return imageFile.GetStream(); });
                    var tessResult = await _tesseractApi.SetImage(bytes);

                    if (tessResult)
                    {
                        Debug.WriteLine("read");
                        Debug.WriteLine(_tesseractApi.Text);
                    }
                    else
                    {
                        Debug.WriteLine("unavaliable");
                    }
                }
                ImageWaiting = true;
            });

            FoldSelectorCommand = new Command <string>(
                execute: (string selector) =>
            {
                int i = 0;
                switch (selector)
                {
                case "filter": i = 0; break;

                case "tag": i = 1; break;

                case "sort": i = 2; break;
                }
                _isFrameVisible[i] = !_isFrameVisible[i];
                OnPropertyChanged("IsFrameVisible");
            });
        }
 public OCRCameraView()
 {
     tesseract = new TesseractApi();
 }
 public ImageStringExtractor(ITesseractApi tesseractApi)
 {
     _tesseractEngine = tesseractApi;
 }
예제 #28
0
        public Camera()
        {
            InitializeComponent();

            takePhoto.Clicked += async(sender, args) =>
            {
                if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported)
                {
                    DisplayAlert("No Camera", "No camera avaialble.", "OK");
                    return;
                }

                var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions
                {
                    Directory          = "Test",
                    SaveToAlbum        = true,
                    CompressionQuality = 75,
                    CustomPhotoSize    = 50,
                    PhotoSize          = PhotoSize.MaxWidthHeight,
                    MaxWidthHeight     = 2000,
                    DefaultCamera      = CameraDevice.Front
                });

                ITesseractApi api = DependencyService.Get <ITesseractService>().Init();
                await api.Init("spa");

                //string path = "/storage/emulated/0/Android/data/mydata/textSpaCrop.png";
                string path = file.Path;
                await api.SetImage(path);

                if (file == null)
                {
                    return;
                }

                DisplayAlert("File Location", file.Path, "OK");

                image.Source = ImageSource.FromStream(() =>
                {
                    var stream = file.GetStream();
                    file.Dispose();
                    return(stream);
                });
            };

            pickPhoto.Clicked += async(sender, args) =>
            {
                if (!CrossMedia.Current.IsPickPhotoSupported)
                {
                    DisplayAlert("Photos Not Supported", ":( Permission not granted to photos.", "OK");
                    return;
                }
                var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions
                {
                    PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium,
                });

                if (file == null)
                {
                    return;
                }

                image.Source = ImageSource.FromStream(() =>
                {
                    var stream = file.GetStream();
                    file.Dispose();
                    return(stream);
                });
            };

            takeVideo.Clicked += async(sender, args) =>
            {
                if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakeVideoSupported)
                {
                    DisplayAlert("No Camera", ":( No camera avaialble.", "OK");
                    return;
                }

                var file = await CrossMedia.Current.TakeVideoAsync(new Plugin.Media.Abstractions.StoreVideoOptions
                {
                    Name      = "video.mp4",
                    Directory = "DefaultVideos",
                });

                if (file == null)
                {
                    return;
                }

                DisplayAlert("Video Recorded", "Location: " + file.Path, "OK");

                file.Dispose();
            };

            pickVideo.Clicked += async(sender, args) =>
            {
                if (!CrossMedia.Current.IsPickVideoSupported)
                {
                    DisplayAlert("Videos Not Supported", ":( Permission not granted to videos.", "OK");
                    return;
                }
                var file = await CrossMedia.Current.PickVideoAsync();

                if (file == null)
                {
                    return;
                }

                DisplayAlert("Video Selected", "Location: " + file.Path, "OK");
                file.Dispose();
            };
        }
예제 #29
0
 public MainPage(ITesseractApi tesseractApi, IMedia media)
 {
     _tesseractApi = tesseractApi;
     _media        = media;
     InitializeComponent();
 }