예제 #1
0
        //Text aus Bild
        public static async Task <string> getText(Bitmap img)
        {
            if (api != null)
            {
                string textResult = "";


                byte[] greyByte = ImageOp.getBytesFromBitmap(img);

                bool success = await api.SetImage(greyByte);

                if (success)
                {
                    textResult = api.Text;
                }
                return(textResult);
            }
            else
            {
                System.Console.WriteLine("Error API not Set");
            }
            return(null);
        }
예제 #2
0
 public InvertImage(ImageOp innerOp)
     : base(innerOp)
 {
 }
예제 #3
0
 public BaseImageOp(ImageOp innerOp)
 {
     _innerOp = innerOp;
 }
예제 #4
0
 public AddImageInfo(ImageOp innerOp)
     : base(innerOp)
 {
 }
예제 #5
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            //Set View
            SetContentView(Resource.Layout.TestArea);


            //Open CV
            mOpenCvCameraView            = FindViewById <CameraBridgeViewBase>(Resource.Id.TestGreyView);
            mOpenCvCameraView.Visibility = ViewStates.Visible;
            mOpenCvCameraView.SetCvCameraViewListener2(this);
            mLoaderCallback = new Callback(this, mOpenCvCameraView);

            //Textview
            textseekThresh = FindViewById <TextView>(Resource.Id.TestAreaTextSeek1);
            textseekBlur   = FindViewById <TextView>(Resource.Id.TestAreaTextSeek2);
            textseekSize   = FindViewById <TextView>(Resource.Id.TestAreaTextSeek3);
            textResult     = FindViewById <TextView>(Resource.Id.TestAreaResultText);

            //Get Buttons
            buttonDetectText         = FindViewById <Button>(Resource.Id.TestAreaButtonDetectText);
            buttonSelectImageGallery = FindViewById <Button>(Resource.Id.TestAreaSelectImageGallery);
            buttonExtractText        = FindViewById <Button>(Resource.Id.TestAreaButtonExtractText);
            buttonGrey = FindViewById <Button>(Resource.Id.TestAreaButtonGrey);
            buttonSize = FindViewById <Button>(Resource.Id.TestAreaButtonSize);

            //ImageView
            imgInput  = FindViewById <ImageView>(Resource.Id.TestAreaImageView);
            imgResult = FindViewById <ImageView>(Resource.Id.TestAreaImageResultGrey);

            //Event Listeners


            buttonGrey.Click += delegate
            {
                Bitmap img    = ((BitmapDrawable)imgInput.Drawable).Bitmap;
                double thresh = Convert.ToDouble(textseekThresh.Text.ToString());
                double blur   = Convert.ToDouble(textseekBlur.Text.ToString());
                Bitmap result = ImageOp.greyImg(img, thresh, blur);

                imgResult.SetImageBitmap(result);
            };

            buttonDetectText.Click += delegate
            {
                Bitmap img = ((BitmapDrawable)imgResult.Drawable).Bitmap;

                Bitmap result = ImageOp.detectTextRect(img);

                imgResult.SetImageBitmap(result);
            };


            buttonExtractText.Click += async delegate
            {
                Bitmap img = ((BitmapDrawable)imgResult.Drawable).Bitmap;

                string result = await ImageOp.detectAndExtractText(img);

                textResult.Text = result;
            };

            buttonSize.Click += delegate
            {
                Bitmap img  = ((BitmapDrawable)imgInput.Drawable).Bitmap;
                double size = Convert.ToDouble(textseekSize.Text.ToString());
                size = size / 100;
                Bitmap imgTemp = ImageOp.resizeImage(img, size, size);
                double thresh  = Convert.ToDouble(textseekThresh.Text.ToString());
                double blur    = Convert.ToDouble(textseekBlur.Text.ToString());
                Bitmap result  = ImageOp.greyImg(imgTemp, thresh, blur);

                imgResult.SetImageBitmap(result);
            };



            buttonSelectImageGallery.Click += delegate
            {
                var imageIntent = new Intent();
                imageIntent.SetType("image/*");
                imageIntent.SetAction(Intent.ActionGetContent);
                StartActivityForResult(Intent.CreateChooser(imageIntent, "Select photo"), 0);
            };


            //Slider
            seekThresh = FindViewById <SeekBar>(Resource.Id.TestAreaSeekBar1);
            seekBlur   = FindViewById <SeekBar>(Resource.Id.TestAreaSeekBar2);
            seekSize   = FindViewById <SeekBar>(Resource.Id.TestAreaSeekBar3);

            //Slider Listener
            seekThresh.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) =>
            {
                if (e.FromUser)
                {
                    textseekThresh.Text = string.Format("" + e.Progress);
                }
            };

            seekBlur.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) =>
            {
                if (e.FromUser)
                {
                    textseekBlur.Text = string.Format("" + e.Progress);
                }
            };

            seekSize.ProgressChanged += (object sender, SeekBar.ProgressChangedEventArgs e) =>
            {
                if (e.FromUser)
                {
                    textseekSize.Text = string.Format("" + e.Progress);
                }
            };

            // Tesseract Api einmal bei start erzeugen
            api = new TesseractApi(this, AssetsDeployment.OncePerVersion);
            bool check = await OCR.initTes(api);
        }
예제 #6
0
        public static void ImageOps()
        {
            Console.WriteLine("\n===> FileOp.ImageInfo");
            ImageInfoRet infoRet = ImageOp.ImageInfo("http://" + DEMO_DOMAIN + "/" + key);

            PrintRet(infoRet);
            if (infoRet.OK)
            {
                Console.WriteLine("Format: " + infoRet.Format);
                Console.WriteLine("Width: " + infoRet.Width);
                Console.WriteLine("Heigth: " + infoRet.Height);
                Console.WriteLine("ColorModel: " + infoRet.ColorModel);
            }
            else
            {
                Console.WriteLine("Failed to ImageInfo");
            }

            Console.WriteLine("\n===> FileOp.ImageExif");
            CallRet exifRet = ImageOp.ImageExif("http://" + DEMO_DOMAIN + "/" + key);

            PrintRet(exifRet);
            if (!exifRet.OK)
            {
                Console.WriteLine("Failed to ImageExif");
            }

            Console.WriteLine("\n===> FileOp.ImageViewUrl");
            ImageViewSpec viewSpec = new ImageViewSpec {
                Mode = 0, Width = 200, Height = 200
            };
            string viewUrl = ImageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);

            Console.WriteLine("ImageViewUrl 1:" + viewUrl);
            viewSpec.Quality = 1;
            viewSpec.Format  = "gif";
            viewUrl          = ImageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
            Console.WriteLine("ImageViewUrl 2:" + viewUrl);
            viewSpec.Quality = 90;
            viewSpec.Sharpen = 10;
            viewSpec.Format  = "png";
            viewUrl          = ImageOp.ImageViewUrl("http://" + DEMO_DOMAIN + "/" + key, viewSpec);
            Console.WriteLine("ImageViewUrl 3:" + viewUrl);

            Console.WriteLine("\n===> FileOp.ImageMogrifyUrl");
            ImageMogrifySpec mogrSpec = new ImageMogrifySpec {
                Thumbnail = "!50x50r", Gravity = "center", Rotate = 90,
                Crop      = "!50x50", Quality = 80, AutoOrient = true
            };
            string mogrUrl = ImageOp.ImageMogrifyUrl("http://" + DEMO_DOMAIN + "/" + key, mogrSpec);

            Console.WriteLine("ImageMogrifyUrl:" + mogrUrl);

            Console.WriteLine("\n===> Get");
            GetRet getRet = rs.Get(key, "save-as");

            PrintRet(getRet);
            if (getRet.OK)
            {
                Console.WriteLine("Hash: " + getRet.Hash);
                Console.WriteLine("FileSize: " + getRet.FileSize);
                Console.WriteLine("MimeType: " + getRet.MimeType);
                Console.WriteLine("Url: " + getRet.Url);
            }
            else
            {
                Console.WriteLine("Failed to Get");
            }
            Console.WriteLine("\n===> FileOp.ImageMogrifySaveAs");
            PutFileRet saveAsRet = rs.ImageMogrifySaveAs(getRet.Url, mogrSpec, key + ".mogr-save-as");

            PrintRet(saveAsRet);
            if (saveAsRet.OK)
            {
                Console.WriteLine("Hash: " + saveAsRet.Hash);
            }
            else
            {
                Console.WriteLine("Failed to ImageMogrifySaveAs");
            }
            Console.WriteLine("\n===> Get");
            getRet = rs.Get(key + ".mogr-save-as", "mogr-save-as.jpg");
            PrintRet(getRet);
            if (getRet.OK)
            {
                Console.WriteLine("Hash: " + getRet.Hash);
                Console.WriteLine("FileSize: " + getRet.FileSize);
                Console.WriteLine("MimeType: " + getRet.MimeType);
                Console.WriteLine("Url: " + getRet.Url);
            }
            else
            {
                Console.WriteLine("Failed to Get");
            }
        }