private void _button_Click(object sender, EventArgs e)
        {
            TextRecognizer textRecogniser = new TextRecognizer.Builder(ApplicationContext).Build();

            if (!textRecogniser.IsOperational)
            {
                Log.Error("error", "detecotor dependencies are not yet available");
            }
            else
            {
                try
                {
                    Frame         frame      = new Frame.Builder().SetBitmap(_bitmap).Build();
                    SparseArray   items      = textRecogniser.Detect(frame);
                    StringBuilder strBuilder = new StringBuilder();

                    var size = items.Size();
                    for (int i = 0; i <= items.Size(); ++i)
                    {
                        TextBlock item = (TextBlock)items.ValueAt(i);
                        if (item != null)
                        {
                            strBuilder.Append(item.Value);
                        }
                    }


                    _textViewLabel.Text = strBuilder.ToString();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.StackTrace);
                }
            }
        }
            public void ReceiveDetections(Detector.Detections detections)
            {
                SparseArray qrcodes = detections.DetectedItems;

                if (qrcodes.Size() != 0)
                {
                    if (isScanning)
                    {
                        isScanning = false;
                        Vibrator vib = (Vibrator)_context.GetSystemService(Context.VibratorService);
                        vib.Vibrate(200);
                        List <BarcodeResult> barcodeResults = new List <BarcodeResult>();
                        for (int i = 0; i < qrcodes.Size(); i++)
                        {
                            Barcode barcode = qrcodes.ValueAt(i) as Barcode;
                            var     type    = Methods.ConvertBarcodeResultTypes(barcode.ValueFormat);
                            var     value   = barcode.DisplayValue;
                            barcodeResults.Add(new BarcodeResult
                            {
                                BarcodeType  = type,
                                DisplayValue = value
                            });
                        }
                        OnDetected?.Invoke(barcodeResults);
                    }
                }
            }
            public void TransactResult(MLAnalyzer.Result result)
            {
                if (!liveObjectAnalyseActivity.mlsNeedToDetect)
                {
                    return;
                }
                this.liveObjectAnalyseActivity.mOverlay.Clear();
                SparseArray objectSparseArray = result.AnalyseList;

                for (int i = 0; i < objectSparseArray.Size(); i++)
                {
                    MLObjectGraphic graphic = new MLObjectGraphic(liveObjectAnalyseActivity.mOverlay, ((MLObject)(objectSparseArray.ValueAt(i))));
                    liveObjectAnalyseActivity.mOverlay.Add(graphic);
                }
                // When you need to implement a scene that stops after recognizing specific content
                // and continues to recognize after finishing processing, refer to this code
                for (int i = 0; i < objectSparseArray.Size(); i++)
                {
                    if (((MLObject)(objectSparseArray.ValueAt(i))).TypeIdentity == MLObject.TypeFood)
                    {
                        liveObjectAnalyseActivity.mlsNeedToDetect = true;
                        liveObjectAnalyseActivity.mHandler.SendEmptyMessage(LiveObjectAnalyseActivity.StopPreview);
                    }
                }
            }
Example #4
0
        public void ReceiveDetections(Detections detections)
        {
            SparseArray detectedfaces = detections.DetectedItems;

            //PictureCallback pictureCallback = new PictureCallback();


            if (detectedfaces.Size() != 0)
            {
                for (int i = 0; i < detectedfaces.Size(); i++)
                {
                    Face face = (Face)detectedfaces.ValueAt(i);

                    //ShowToast(" Blinked ", true);
                    txt.Post(() => {
                        txt.Text = face.IsLeftEyeOpenProbability.ToString() + "   " + face.IsRightEyeOpenProbability.ToString();
                    });
                    if ((face.IsLeftEyeOpenProbability + face.IsRightEyeOpenProbability) / 2.0f < 0.3 && face.IsLeftEyeOpenProbability > 0 && face.IsRightEyeOpenProbability > 0)
                    {
                        closed_eyes = true;
                    }
                    if (closed_eyes)
                    {
                        if ((face.IsLeftEyeOpenProbability + face.IsRightEyeOpenProbability) / 2.0f >= 0.6 && face.IsLeftEyeOpenProbability > 0 && face.IsRightEyeOpenProbability > 0)
                        {
                            if (captured)
                            {
                                cameraSource.TakePicture(null, this);
                                captured = false;
                            }
                        }
                    }
                }
            }
        }
Example #5
0
 public void ReceiveDetections(Detections detections)
 {
     try
     {
         if (_isBusy)
         {
             return;
         }
         SparseArray items = detections.DetectedItems;
         if (items.Size() != 0)
         {
             tv.Post(() =>
             {
                 StringBuilder bulder = new StringBuilder();
                 for (int i = 0; i < items.Size(); i++)
                 {
                     string det = ((TextBlock)items.ValueAt(i)).Value;
                     Log.Debug("......ReceiveDetections.....", det);
                     GetNumber(det);
                     bulder.Append(det);
                     bulder.Append("\n");
                 }
                 tv.Text = bulder.ToString();
             });
         }
     }
     catch (Exception ex)
     {
         Log.Error("Detector", ex.Message);
     }
 }
Example #6
0
        private void ProcessCameraPicture()
        {
            Bitmap bitmap = DecodeBitmapUri(this, imageUri);

            if (detector.IsOperational && bitmap != null)
            {
                editedBitmap = Bitmap.CreateBitmap(bitmap.Width, bitmap
                                                   .Height, bitmap.GetConfig());
                float scale = Resources.DisplayMetrics.Density;
                Paint paint = new Paint(PaintFlags.AntiAlias);
                paint.Color    = Color.Green;
                paint.TextSize = (int)(16 * scale);
                paint.SetShadowLayer(1f, 0f, 1f, Color.White);
                paint.SetStyle(Paint.Style.Stroke);
                paint.StrokeWidth = 6f;
                Canvas canvas = new Canvas(editedBitmap);
                canvas.DrawBitmap(bitmap, 0, 0, paint);
                Frame       frame = new Frame.Builder().SetBitmap(editedBitmap).Build();
                SparseArray faces = detector.Detect(frame);
                string      text  = "";
                for (int index = 0; index < faces.Size(); ++index)
                {
                    Face face = faces.ValueAt(index) as Face;
                    canvas.DrawRect(
                        face.Position.X,
                        face.Position.Y,
                        face.Position.X + face.Width,
                        face.Position.Y + face.Height, paint);             //CREA EL RECUADRO
                    text += "Cara " + (index + 1) + "\n";
                    text += "Probilidad de una sonrisa:" + " " + face.IsSmilingProbability * 100 + "\n";
                    text += "Probilidad que el ojo izquierdo este abierto : " + " " + face.IsLeftEyeOpenProbability * 100 + "\n";
                    text += "Probilidad que el ojo derecho este abierto: " + " " + face.IsRightEyeOpenProbability * 100 + "\n";
                    foreach (Landmark landmark in face.Landmarks)
                    {
                        int cx = (int)(landmark.Position.X);
                        int cy = (int)(landmark.Position.Y);
                        canvas.DrawCircle(cx, cy, 8, paint); // CREA EL CIRCULO
                    }
                }
                if (faces.Size() == 0)
                {
                    txtDescription.Text = "Scaneo fallido";
                }
                else
                {
                    _imageView.SetImageBitmap(editedBitmap);
                    text += "\n\n" + "Numero de caras detectadas: " + " " + faces.Size().ToString() + "\n\n";
                }
                txtDescription.Text = text;
            }
            else
            {
                txtDescription.Text = "No se pudo configurar el detector!";
            }
        }
Example #7
0
        public override void onReceiveData(int id, int requestCode, Bundle data, Type fromCls, int fromId)
        {
            switch (requestCode)
            {
            case APP_SELECTOR_CODE:
                if (APP_SELECTOR_ID == id)
                {
                    // app selector receives data
                    Window window2 = show(APP_SELECTOR_ID);
                    window2.data.PutInt("fromId", fromId);
                }
                break;

            case APP_SELECTOR_FINISHED_CODE:
                //JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
                //ORIGINAL LINE: final Android.Content.pm.ActivityInfo app = data.getParcelable("app");
                ActivityInfo app = (ActivityInfo)data.GetParcelable("app");
                Log.Debug("FloatingFolder", "Received app: " + app);

                Window window = getWindow(id);
                if (window == null)
                {
                    return;
                }

                ViewGroup flow = (ViewGroup)window.FindViewById(Resource.Id.flow);

                AddAppToFolder(id, app, flow);

                OnUserAddApp(id, app);
                break;

            case STARTUP_CODE:
                LoadAllFolders();
                if (MFolders.Size() == 0)
                {
                    MFolders.Put(DEFAULT_ID, new FolderModel());
                    show(DEFAULT_ID);
                }
                else
                {
                    for (int i = 0; i < MFolders.Size(); i++)
                    {
                        FolderModel folder = MFolders.Get(MFolders.KeyAt(i));
                        if (folder.Shown)
                        {
                            show(folder.Id);
                        }
                    }
                }
                break;
            }
        }
Example #8
0
        public static async Task <List <BarcodeResult> > ScanFromImage(byte[] imageArray)
        {
            BarcodeDetector detector = new BarcodeDetector.Builder(Android.App.Application.Context)
                                       .SetBarcodeFormats(Configuration.BarcodeFormats)
                                       .Build();
            Bitmap bitmap = BitmapFactory.DecodeByteArray(imageArray, 0, imageArray.Length);

            Android.Gms.Vision.Frame frame      = new Android.Gms.Vision.Frame.Builder().SetBitmap(bitmap).Build();
            SparseArray          qrcodes        = detector.Detect(frame);
            List <BarcodeResult> barcodeResults = new List <BarcodeResult>();

            for (int i = 0; i < qrcodes.Size(); i++)
            {
                Barcode barcode  = qrcodes.ValueAt(i) as Barcode;
                var     type     = Methods.ConvertBarcodeResultTypes(barcode.ValueFormat);
                var     value    = barcode.DisplayValue;
                var     rawValue = barcode.RawValue;
                barcodeResults.Add(new BarcodeResult
                {
                    BarcodeType  = type,
                    DisplayValue = value,
                    RawValue     = rawValue
                });
            }
            return(barcodeResults);
        }
Example #9
0
        public void ReceiveDetections(Detections detections)
        {
            if (this.ViewModel.State == RegisterDeviceViewModel.RegistrationState.New)
            {
                SparseArray qrcodes = detections.DetectedItems;
                if (qrcodes.Size() != 0)
                {
                    try
                    {
                        Vibrator vibrator = (Vibrator)GetSystemService(Context.VibratorService);
                        vibrator.Vibrate(VibrationEffect.CreateOneShot(1000, 1));
                    }
                    catch { }
                    var value = ((Barcode)qrcodes.ValueAt(0)).RawValue;

                    string networkSSID = value;

                    if (!string.IsNullOrEmpty(networkSSID))
                    {
                        Task.Run(async() => await this.ViewModel.ProvisionDevice(new Common.WiFi.WifiNetwork()
                        {
                            SSID = networkSSID
                        }));
                    }
                }
            }
        }
Example #10
0
        public void ReceiveDetections(Detections detections)
        {
            SparseArray qrcodes = detections.DetectedItems;

            //cameraSource.Stop();
            string[] spstring, spstring2, spstring3;

            if (qrcodes.Size() != 0)
            {
                spstring = ((Barcode)qrcodes.ValueAt(0)).RawValue.Split("\r\n");

                if (spstring.Count <string>() > 1)    //VCARD
                {
                    if (spstring[0].Contains("VCARD"))
                    {
                        spstring2 = spstring[3].Split(':');
                        tempname  = spstring2[1];
                        //txtresult.Text += " ";
                        spstring3  = spstring[5].Split(';');
                        spstring2  = spstring3[2].Split(':');
                        tempnumber = spstring2[1];
                        //txtresult.Text = spstring[3];
                        //insertContacts(tempname, tempnumber);
                        checkdetect = true;
                    }
                }
                else if (spstring.Count <string>() == 1)
                {
                    spstring2 = spstring[0].Split(';');
                    if (spstring2[0].Contains("MECARD:")) //MECARD
                    {
                        spstring3  = spstring2[0].Split(':');
                        tempname   = spstring3[2];
                        spstring3  = spstring2[1].Split(':');
                        tempnumber = spstring3[1];
                        //insertContacts(tempname, tempnumber);
                        checkdetect = true;
                    }
                    else if (spstring2[0].Contains("{\"name\""))   //App
                    {
                        Newtonsoft.Json.Linq.JObject jo = Newtonsoft.Json.Linq.JObject.Parse(spstring2[0]);
                        tempname   = jo["name"].ToString();
                        tempnumber = jo["number"].ToString();
                        //insertContacts(tempname, tempnumber);
                        checkdetect = true;
                    }
                }

                /*
                 * txtresult.Post(() => {
                 *  //Vibrator vibrator = (Vibrator)GetSystemService(Context.VibratorService);
                 *  //vibrator.Vibrate(1000);
                 *  //txtresult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue;
                 * }
                 *
                 * ); */
                Finish();
            }
            //throw new NotImplementedException();
        }
        public string ReadTextFromImage(string file_path)
        {
            var text   = string.Empty;
            var bitMap = BitmapFactory.DecodeFile(file_path);

            var textRecognizer = new TextRecognizer.Builder(Application.Context).Build();

            if (!textRecognizer.IsOperational)
            {
                return(text);
            }

            Frame         frame      = new Frame.Builder().SetBitmap(bitMap).Build();
            SparseArray   items      = textRecognizer.Detect(frame);
            StringBuilder strBuilder = new StringBuilder();

            for (int i = 0; i < items.Size(); i++)
            {
                TextBlock item = (TextBlock)items.ValueAt(i);
                strBuilder.Append(item.Value);
                strBuilder.Append(" ");
            }
            text = strBuilder.ToString();

            return(text);
        }
Example #12
0
        /// <summary>
        /// Analyse the scan result to find device information
        /// </summary>
        /// <param name="iScanResult">Scan result</param>
        /// <returns>Device information class</returns>
        private static DeviceInfo InterpretScanResult(ScanResult iScanResult)
        {
            Guid guid = MacAddressUtils.GuidFromMacAddress(iScanResult.Device.Address);

            DeviceInfo device = new DeviceInfo(iScanResult.ScanRecord.DeviceName, guid)
            {
                Rssi = iScanResult.Rssi
            };

            // Add in manufacturer specific data
            Dictionary <int, byte[]> manf        = new Dictionary <int, byte[]>();
            SparseArray manufacturerSpecificData = iScanResult.ScanRecord.ManufacturerSpecificData;

            if (manufacturerSpecificData != null)
            {
                for (int i = 0; i < manufacturerSpecificData.Size(); i++)
                {
                    int    companyId = iScanResult.ScanRecord.ManufacturerSpecificData.KeyAt(i);
                    byte[] data      = (byte[])iScanResult.ScanRecord.ManufacturerSpecificData.ValueAt(i);
                    manf.Add(companyId, data);
                }
            }
            device.ManufacturerSpecificData = manf;

            // Add in services
            List <Guid> services = new List <Guid>();

            foreach (ParcelUuid uuid in iScanResult.ScanRecord.ServiceUuids ?? new List <ParcelUuid>())
            {
                services.Add(new Guid(uuid.Uuid.ToString()));
            }
            device.Services = services;
            return(device);
        }
Example #13
0
        public static List <IItem> ValidateItems(SparseArray items)
        {
            List <IText> lineList = new List <IText>();


            for (int i = 0; i < items.Size(); i++)
            {
                lineList.AddRange(((TextBlock)items.ValueAt(i)).Components);
            }
            topRightPrice    = FindTopPrice(lineList);
            bottomRightPrice = FindBottomPrice(lineList);
            if (topRightPrice == null || bottomRightPrice == null)
            {
                return(itemList);
            }
            var priceList = FindPriceList(lineList);

            foreach (var line in lineList.ToList())
            {
                if (topRightPrice.BoundingBox.CenterY() < line.BoundingBox.CenterY() &&
                    bottomRightPrice.BoundingBox.CenterY() > line.BoundingBox.CenterY())
                {
                    if (FindBelongingItem(line, priceList, itemList))
                    {
                        lineList.Remove(line);
                    }
                }
            }

            foreach (var line in lineList.ToList())
            {
            }

            return(itemList);
        }
Example #14
0
        /// <summary>
        /// Given a list of text blocks, orders them by line, and
        /// from left to right within each line. The lines themselves are
        /// in no particular order.
        /// </summary>
        /// <param name="textBlocks"></param>
        /// <returns></returns>
        private static List <string> OrderTextBlocks(SparseArray textBlocks)
        {
            List <TextBlock> blocks = new List <TextBlock>();

            for (int i = 0; i < textBlocks.Size(); ++i)
            {
                TextBlock text = (TextBlock)textBlocks.ValueAt(i);
                blocks.Add(text);
            }

            List <string> results = new List <string>();

            while (blocks.Any())
            {
                TextBlock blockToExamine = blocks.First();
                // get items in this line
                List <TextBlock> allInThisLine = GetAllInLine(blocks, blockToExamine);
                // order from left to right
                List <TextBlock> orderedInLine = allInThisLine.OrderBy(block => block.BoundingBox.Left).ToList();
                foreach (TextBlock block in orderedInLine)
                {
                    results.Add(block.Value);
                    results.Add(" ");
                }
                results.Add(System.Environment.NewLine);
                // remove items in this line before we check the next line
                blocks.RemoveAll((text) => allInThisLine.Contains(text));
            }

            return(results);
        }
Example #15
0
        protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
        {
            string result = string.Empty;

            try
            {
                if (requestCode == 100 && resultCode == Result.Ok)
                {
                    if (data != null && data.Extras != null)
                    {
                        Bitmap         imageBitmap    = (Bitmap)data.Extras.Get("data");
                        TextRecognizer textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build();
                        Frame          frame          = new Frame.Builder().SetBitmap(imageBitmap).Build();
                        SparseArray    items          = textRecognizer.Detect(frame);
                        StringBuilder  builder        = new StringBuilder();

                        for (int i = 0; i < items.Size(); i++)
                        {
                            TextBlock item = (TextBlock)items.ValueAt(i);
                            builder.Append(item.Value);
                            builder.Append(" ");
                        }

                        result = builder.ToString();
                    }
                }
            }
            catch (System.Exception e)
            {
                Toast.MakeText(this, e.Message, ToastLength.Long).Show();
            }

            TextData.LastText = result;
            Finish();
        }
        protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data)
        {
            base.OnActivityResult(requestCode, resultCode, data);

            if (requestCode == PickImageID && resultCode == Result.Ok && data != null)
            {
                Android.Net.Uri uri = data.Data;
                cameraSource.Stop();
                surfaceView.Visibility   = ViewStates.Gone;
                selectedimage.Visibility = ViewStates.Visible;
                mainLayout.Visibility    = ViewStates.Gone;
                captureLayout.Visibility = ViewStates.Visible;
                selectedimage.SetImageURI(uri);

                Bitmap currentImage = MediaStore.Images.Media.GetBitmap(this.ContentResolver, uri);
                selectedimage.SetImageBitmap(currentImage);
                Frame         frame         = new Frame.Builder().SetBitmap(currentImage).Build();
                SparseArray   items         = textRecognizer.Detect(frame);
                StringBuilder stringBuilder = new StringBuilder();
                for (int i = 0; i < items.Size(); i++)
                {
                    stringBuilder.Append(((TextBlock)items.ValueAt(i)).Value);
                    stringBuilder.Append(" ");
                }
                textView.Text = stringBuilder.ToString();
            }
        }
Example #17
0
        public void ReceiveDetections(Detections detections)
        {
            SparseArray qrcodes = detections.DetectedItems;

            if (qrcodes.Size() != 0)
            {
                _txtResult.Post(() => {
                    _txtResult.Text            = ((Barcode)qrcodes.ValueAt(0)).RawValue;
                    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
                    AlertDialog alert          = dialog.Create();
                    alert.SetTitle("Código de Barras");
                    alert.SetMessage(((Barcode)qrcodes.ValueAt(0)).RawValue);
                    alert.SetIcon(Resource.Drawable.logo);
                    alert.SetButton("Volver", (c, ev) =>
                    {
                        // Para actualizar una actividad desde dentro de sí mismo
                        Finish(); StartActivity(Intent);

                        GC.Collect();
                    });

                    alert.Show();
                });
            }
        }
        public override void OnProvideAutofillVirtualStructure(ViewStructure structure, AutofillFlags flags)
        {
            // Build a ViewStructure that will get passed to the AutofillService by the framework
            // when it is time to find autofill suggestions.
            structure.SetClassName(Class.Name);
            var childrenSize = VirtualViews.Size();

            Log.Debug(LogTag, "onProvideAutofillVirtualStructure(): flags = " + flags + ", items = "
                      + childrenSize + ", extras: " + CommonUtil.BundleToString(structure.Extras));
            var index = structure.AddChildCount(childrenSize);

            // Traverse through the view hierarchy, including virtual child views. For each view, we
            // need to set the relevant autofill metadata and add it to the ViewStructure.
            for (int i = 0; i < childrenSize; i++)
            {
                Item item = VirtualViews.ValueAt(i);
                Log.Debug(LogTag, "Adding new child at index " + index + ": " + item);
                var child = structure.NewChild(index);
                child.SetAutofillId(structure.AutofillId, item.Id);
                child.SetAutofillHints(item.Hints);
                child.SetAutofillType(item.Type);
                child.SetDataIsSensitive(!item.Sanitized);
                child.Text = item.Text;
                child.SetAutofillValue(AutofillValue.ForText(item.Text));
                child.SetFocused(item.Focused);
                child.SetId(item.Id, Context.PackageName, null, item.Line.IdEntry);
                child.SetClassName(item.getClassName());
                index++;
            }
        }
Example #19
0
 /**
  * Resets the value of all items in the partition.
  */
 public void Reset()
 {
     for (int i = 0; i < mLines.Size(); i++)
     {
         mLines.ValueAt(i).Reset();
     }
 }
Example #20
0
        public void ReceiveDetections(Detector.Detections detections)
        {
            SparseArray items = detections.DetectedItems;



            if (items.Size() != 0)
            {
                textView.Post(() =>
                {
                    var sb = new StringBuilder();

                    sb.Append("Cash Register Number: " + LotteryTextValidation.CashRegisterNumber + "\n");

                    sb.Append("Date: " + LotteryTextValidation.ReceiptDate + "\n");
                    sb.Append("Receipt Number: " + LotteryTextValidation.ReceiptNumber + "\n");

                    textView.Text = sb.ToString();
                    if (LotteryTextValidation.ValidateLotteryReceipt(items))
                    {
                        dictionary = LotteryTextValidation.OnValidationComplete();
                        var intent = new Intent(this, typeof(MainActivity)).SetFlags(ActivityFlags.ReorderToFront);
                        SetResult(Result.Ok, intent);
                        Finish();
                    }
                });
            }
        }
 public override void Autofill(SparseArray values)
 {
     // User has just selected a Dataset from the list of autofill suggestions.
     // The Dataset is comprised of a list of AutofillValues, with each AutofillValue meant
     // to fill a specific autofillable view. Now we have to update the UI based on the
     // AutofillValues in the list.
     Log.Debug(LogTag, "autoFill(): " + values);
     for (int i = 0; i < values.Size(); i++)
     {
         var  id    = values.KeyAt(i);
         var  value = (AutofillValue)values.ValueAt(i);
         Item item  = VirtualViews.Get(id);
         if (item != null && item.Editable)
         {
             // Set the item's text to the text wrapped in the AutofillValue.
             item.Text = value.TextValue;
         }
         else if (item == null)
         {
             Log.Warn(LogTag, "No item for id " + id);
         }
         else
         {
             Log.Warn(LogTag, "Item for id " + id + " is not editable: " + item);
         }
     }
     PostInvalidate();
 }
        public View GetView(int position)
        {
            var nativeRecyclerViews = new List <View>();

            var size = _mScrap.Size();

            for (int i = 0; i < size; i++)
            {
                nativeRecyclerViews.Add(_mScrap.Get(i) as View);
            }

            // The spinner creates temporary view when measuring its size.
            // This item is not placed in the recycler so we can find it this way.
            var view = _views
                       .Except(nativeRecyclerViews)
                       .Where(v => !v.HasParent())
                       .FirstOrDefault();

            if (view != null)
            {
                if (this.Log().IsEnabled(Microsoft.Extensions.Logging.LogLevel.Debug))
                {
                    this.Log().DebugFormat("Reusing unassigned view {0}", view);
                }
            }

            return(view);
        }
Example #23
0
        /// <summary>
        /// Text OCR 기능
        /// </summary>
        /// <param name="bitmap"></param>
        public void TextOCRFunction(Bitmap bitmap)
        {
            TextRecognizer textRecognizer = new TextRecognizer.Builder(ApplicationContext).Build();

            if (!textRecognizer.IsOperational)
            {
                Log.Error("ERROR", "Detector dependencies are not yet available");
            }
            else
            {
                Frame         frame      = new Frame.Builder().SetBitmap(bitmap).Build();
                SparseArray   items      = textRecognizer.Detect(frame);
                StringBuilder strBuilder = new StringBuilder();
                for (int i = 0; i < items.Size(); ++i)
                {
                    TextBlock item = (TextBlock)items.ValueAt(i);
                    strBuilder.Append(item.Value);
                    strBuilder.Append("\n  ");
                }
                if (strBuilder.ToString() != "")
                {
                    tvResult.Text = "  " + strBuilder.ToString();
                    Speak(tvResult.Text);
                }
                else
                {
                    tvResult.Text = "  인식할 수 없습니다.";
                    Speak(tvResult.Text);
                }
            }
        }
Example #24
0
        public void ReceiveDetections(Detections detections)
        {
            SparseArray items = detections.DetectedItems;

            if (items.Size() != 0)
            {
                textView.Post(() => {
                    StringBuilder strBuilder = new StringBuilder();
                    for (int i = 0; i < items.Size(); ++i)
                    {
                        strBuilder.Append((TextBlock)items.ValueAt(i));
                        strBuilder.Append("\n");
                    }
                    textView.Text = strBuilder.ToString();
                });
            }
        }
 private void DetectedResponse(Bitmap bitmap, SparseArray faces)
 {
     if (faces.Size() < 1)
     {
         OnboardingActivity.CloseProgressDialog();
         OnboardingActivity.ShowErrorDialog("No face in photo");
     }
     else if (faces.Size() == 1)
     {
         SaveImage();
     }
     else if (faces.Size() > 1)
     {
         OnboardingActivity.CloseProgressDialog();
         OnboardingActivity.ShowErrorDialog("More than one face detected");
     }
 }
 public void OnBarcodesReceived(SparseArray barcodes)
 {
     for (var i = 0; i < barcodes.Size(); i++)
     {
         var barcode      = barcodes.ValueAt(i) as Android.Gms.Vision.Barcodes.Barcode;
         var resultString = "Barcode Result: " + barcode.DisplayValue;
         _activityReference.NativeBarcodeResultTextView.Text = resultString;
     }
 }
Example #27
0
        public void ReceiveDetections(Detector.Detections detections)
        {
            //var canvas = _transparentView.Holder.LockCanvas();
            //canvas.DrawColor(Color.Transparent, PorterDuff.Mode.Clear);
            // _transparentView.Holder.UnlockCanvasAndPost(canvas);

            SparseArray items = detections.DetectedItems;

            if (items.Size() != 0)
            {
                _textView.Post(() =>
                {
                    try
                    {
                        //var tuple = ReceiptTextValidation.ValidateItems(items);
                        ItemList = ReceiptValidator.ValidateItems(items);
                        //ItemList = tuple.Item1;
                        StringBuilder sb = new StringBuilder();
                        _textView.SetTextColor(Android.Graphics.Color.Red);
                        foreach (var item in ItemList)
                        {
                            sb.Append("name: " + item.Name + "price" + item.Price + "\n");
                        }
                        //sb.Append(tuple.Item2);
                        _textView.Text = sb.ToString();

                        // test if item list size doesnt change between scanning frames threshold times
                        if (ItemList.Count == _prevCount && _prevCount != 0)
                        {
                            _numerator++;
                        }
                        else
                        {
                            _prevCount = ItemList.Count;
                            _numerator = 0;
                        }

                        if (_numerator >= _threshold)
                        {
                            _textView.SetTextColor(Android.Graphics.Color.White);
                            _textView.Text = sb.ToString();


                            Intent intent = new Intent(this, typeof(MainActivity))
                                            .SetFlags(ActivityFlags.ReorderToFront);
                            SetResult(Result.Ok, intent);
                            Finish();
                        }
                    }
                    catch (System.Exception e)
                    {
                        _textView.Text = e.ToString();
                    }
                });
            }
        }
Example #28
0
        public virtual void ShowAllHiddenColumns()
        {
            for (int i = 0; i < mHideColumnList.Size(); i++)
            {
                int column = mHideColumnList.KeyAt(i);
                ShowColumn(column, false);
            }

            ClearHideColumnList();
        }
Example #29
0
        public virtual void ShowAllHiddenRows()
        {
            for (int i = 0; i < mHideRowList.Size(); i++)
            {
                int row = mHideRowList.KeyAt(i);
                ShowRow(row, false);
            }

            ClearHideRowList();
        }
Example #30
0
        public void ReceiveDetections(Detections detections)
        {
            SparseArray qrcodes = detections.DetectedItems;

            if (qrcodes.Size() != 0)
            {
                _txtResult.Post(() => {
                    _txtResult.Text = ((Barcode)qrcodes.ValueAt(0)).RawValue;
                });
            }
        }