public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { var face = item as Face; mOverlay.Add(mFaceGraphic); mFaceGraphic.UpdateFace(face); }
public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { if (_mainActivity.IsAdvertViewVisible) { return; } if (_fetchingInProgress) { return; } var detectedItem = item as Barcode; if (detectedItem != null) { var value = Guid.Empty; if (Guid.TryParse(detectedItem.DisplayValue, out value)) { _fetchingInProgress = true; DisplayMessage("Retrieving product details..."); ThreadPool.QueueUserWorkItem(async o => await GetAdvert(detectedItem.DisplayValue)); } else { DisplayMessage("Not a product QR code"); } } }
public void ReceiveDetections(Detector.Detections detections) { var qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { if (Configuration.IsScanning) { Configuration.IsScanning = false; if (_vibrationOnDetected) { 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; if (barcode == null) { continue; } var type = Methods.ConvertBarcodeResultTypes(barcode.ValueFormat); var value = barcode.DisplayValue; barcodeResults.Add(new BarcodeResult { BarcodeType = type, DisplayValue = value, Points = barcode.CornerPoints.Select(p => (p.X / (double)detections.FrameMetadata.Width, p.Y / (double)detections.FrameMetadata.Height)).ToList() });
/** * Update the position/characteristics of the face within the overlay. */ public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { const string barcodeMibikeNo = "http://download.jimicloud.com/webDown/mibike?no=7551008104"; var barcode = item.JavaCast <Barcode>(); var stringValue = barcode.DisplayValue; if (_parent.PreviouslyScanned) { return; } MessagingCenter.Send <GraphicBarcodeTracker, string>(this, "Barcode Scanned", stringValue); MessagingCenter.Send(this, "Close Scanner"); _parent.PreviouslyScanned = true; //.Make(parent.MainLayout, "To start ride click Unlock. You are on PAYG", Snackbar.LengthLong) //.SetAction("Unlock", // v => { }) //.Show(); //if (videoDisplayVal.Equals(stringValue) && !_previouslyScanned) //{ // //MessagingCenter.Send(this, "Close Scanner"); // //AView layout = FindViewById(Android.Resource.Id.Content); // Snackbar // .Make(parent.MainLayout, "To start ride click Unlock. You are on PAYG", Snackbar.LengthLong) // .SetAction("Unlock", // v => { }) // .Show(); //} }
/** * Hide the graphic when the corresponding face was not detected. This can happen for * intermediate frames temporarily (e.g., if the face was momentarily blocked from * view). */ public override void OnMissing(Detector.Detections detections) { if (mBarcodeGraphic != null) { mOverlay.Remove(mBarcodeGraphic); } }
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 void ReceiveDetections(Detector.Detections detections) { var qrcodes = detections.DetectedItems; if (qrcodes.Size() != 0) { if (Configuration.IsScanning) { Configuration.IsScanning = false; if (_vibrationOnDetected) { 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; if (barcode == null) { continue; } var type = Methods.ConvertBarcodeResultTypes(barcode.ValueFormat); var value = barcode.DisplayValue; barcodeResults.Add(new BarcodeResult { BarcodeType = type, DisplayValue = value }); } OnDetected?.Invoke(barcodeResults); } } }
public void ReceiveDetections(Detector.Detections detections) { var detectedItems = detections.DetectedItems as SparseArray <Barcode>; if (detectedItems.Size() > 0) { _barcodeText.Post(() => _barcodeText.SetText(detectedItems.ValueAt(0).DisplayValue, TextView.BufferType.Normal)); } }
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(); } }); } }
public override void OnMissing(Detector.Detections detections) { mOverlay.Remove(mFaceGraphic); if (detections.DetectedItems.Size() == 0) { if (ArduinoConnection != null) { ArduinoConnection.Off(); } } }
public void ReceiveDetections(Detector.Detections detections) { Android.Util.SparseArray barcodes = detections.DetectedItems; for (int i = 0; i < barcodes.Size(); i++) { Barcode barcode = barcodes.ValueAt(i) as Barcode; string value = barcode.DisplayValue; try { Uri appId = Uri.Parse(value); if (!appId.Scheme.Equals("layer")) { throw new Java.Lang.IllegalArgumentException("URI is not an App ID"); } if (!appId.Authority.Equals("")) { throw new Java.Lang.IllegalArgumentException("URI is not an App ID"); } IList <string> segments = appId.PathSegments; if (segments.Count != 3) { throw new Java.Lang.IllegalArgumentException("URI is not an App ID"); } if (!segments[0].Equals("apps")) { throw new Java.Lang.IllegalArgumentException("URI is not an App ID"); } if (!segments[1].Equals("staging") && !segments[1].Equals("production")) { throw new Java.Lang.IllegalArgumentException("URI is not an App ID"); } UUID uuid = UUID.FromString(segments[2]); if (Util.Log.IsLoggable(Util.Log.VERBOSE)) { Util.Log.v("Captured Layer App ID: " + appId + ", UUID: " + uuid); } if (_appIdScanner.mAppIdCallback == null) { return; } _appIdScanner.mAppIdCallback.OnLayerAppIdScanned(_appIdScanner, appId.ToString()); } catch (System.Exception e) { // Not this barcode... if (Util.Log.IsLoggable(Util.Log.ERROR)) { Util.Log.e("Barcode does not contain an App ID URI: " + value, e); } } } }
public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { var face = item as Face; mOverlay.Add(mFaceGraphic); mFaceGraphic.UpdateFace(face); if (detections.DetectedItems.Size() != 0) { if (ArduinoConnection != null && ArduinoConnection.State != true) { ArduinoConnection.On(); } } }
public void ReceiveDetections(Detector.Detections detections) { try { items = detections.DetectedItems; if (items.Size() != 0) { mTextView.Post(this); } } catch (Exception ex) { } }
/** * Update the position/characteristics of the face within the overlay. */ public override async void OnUpdate(Detector.Detections detections, Object item) { var face = item as Face; this.overlay.Add(this.faceGraphic); this.faceGraphic.UpdateFace(face); //if face was not detected on add (due tue bad image), retry to detect a face if (this.faceGraphic.IsFaceRecognitionEnabled && this.faceGraphic.RecognizeTries < 2 && !this.faceGraphic.IsRecognized) { await this.DetectFace(face); } }
public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { var face = item as Face; mOverlay.Add(mFaceGraphic); mFaceGraphic.UpdateFace(face); try { if (mCameraSource != null && !isProcessing)// && face.Width > 250 && face.Height > 250 && face.Position.X > 50 && face.Position.Y > 150 && face.Position.X < 200 && face.Position.Y < 300) { mCameraSource.TakePicture(null, this); } } catch { } }
public void ReceiveDetections(Detector.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)).Value); strBuilder.Append("\n"); } textView.Text = strBuilder.ToString(); }); } }
/** * Update the position/characteristics of the face within the overlay. * 바코드 Result부분 */ public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { //2개이상 바코드를 스캔해서 경고창이 발생할 경우 화면이 Freeze된다. //if (detections.DetectedItems.Size() != 1) //{ // return; //} Rect rect = ((BarcodeScannerActivity)_activity).mPreview.mSurfaceView._clipBounds; float left; float right; float top; float bottom; //IList<Point> point = (item as Barcode).CornerPoints; if (!Settings.ScanMode.Equals("FULL")) { left = (rect.Left * (float)((BarcodeScannerActivity)_activity).mCameraSource.PreviewSize.Height) / (float)((BarcodeScannerActivity)_activity).mPreview.mSurfaceView.scaleNominatorX; right = (rect.Right * (float)((BarcodeScannerActivity)_activity).mCameraSource.PreviewSize.Height) / (float)((BarcodeScannerActivity)_activity).mPreview.mSurfaceView.scaleNominatorX; top = (rect.Top * (float)((BarcodeScannerActivity)_activity).mCameraSource.PreviewSize.Width) / (float)((BarcodeScannerActivity)_activity).mPreview.mSurfaceView.scaleNominatorY; bottom = (rect.Bottom * (float)((BarcodeScannerActivity)_activity).mCameraSource.PreviewSize.Width) / (float)((BarcodeScannerActivity)_activity).mPreview.mSurfaceView.scaleNominatorY; //관심영여과 스캔한 바코드가 교차영역이 없으면 skip한다. //카메라와 PreView 좌표가 넘어온다. Layout 크기와 Preview 카메라 크기가 다르면 아래 코드는 작동하지 않는다. //if (!(item as Barcode).BoundingBox.Intersect(((BarcodeScannerActivity)_activity).mPreview.mSurfaceView.GetAreaOfInterestCamera())) if (!(item as Barcode).BoundingBox.Intersect(new Rect((int)left, (int)top, (int)right, (int)bottom))) { return; } } //화면 표시 mOverlay.Add(mBarcodeGraphic); //1. 단일/연속 구분 //연속 스캔 if (((BarcodeScannerActivity)_activity).IsContinue) { //고정(스캔 해야할 대상이 정해져 있음) if (((BarcodeScannerActivity)_activity).IsFixed) { if (((BarcodeScannerActivity)_activity).AllScanBarcode.Contains(item.JavaCast <Barcode>().DisplayValue)) { //1. 저장 했는지? if (((BarcodeScannerActivity)_activity).SaveCompletedBarcode.Contains(item.JavaCast <Barcode>().DisplayValue)) { //CameraStop(); mBarcodeGraphic.UpdateBarcode(item.JavaCast <Barcode>(), "저장 완료", 3); //long[] pattern = { 0, 100, 1000 }; Warning(); //Task.Run(() => //{ // ((BarcodeScannerActivity)_activity).StartCameraSource(); //}); } //2. Scan완료 했는지? else if (((BarcodeScannerActivity)_activity).ScanCompletedBarcode.Contains(item.JavaCast <Barcode>().DisplayValue)) { //CameraStop(); mBarcodeGraphic.UpdateBarcode(item.JavaCast <Barcode>(), "스캔 완료", 1); //long[] pattern = { 0, 100, 1000 }; Warning(); //Task.Run(() => //{ // ((BarcodeScannerActivity)_activity).StartCameraSource(); //}); } else { //------------ //정상처리 작업 //------------ mBarcodeGraphic.UpdateBarcode(item.JavaCast <Barcode>(), string.Empty, 0); OnScanCompleted?.Invoke(item.JavaCast <Barcode>()); ((BarcodeScannerActivity)_activity)._playerBeep.Start(); if (((BarcodeScannerActivity)_activity).vibrator != null) { try { ((BarcodeScannerActivity)_activity).vibrator.Vibrate(300); } catch (Exception e) { Console.WriteLine(e.Message); } } if (!((BarcodeScannerActivity)_activity).ScanCompletedBarcode.Contains(item.JavaCast <Barcode>().DisplayValue)) { ((BarcodeScannerActivity)_activity).ScanCompletedBarcode.Add(item.JavaCast <Barcode>().DisplayValue); } if ( ((BarcodeScannerActivity)_activity).AllScanBarcode.Count == ((BarcodeScannerActivity)_activity).SaveCompletedBarcode.Count + ((BarcodeScannerActivity)_activity).ScanCompletedBarcode.Count ) { CameraStop(); Barcode barcode = new Barcode { DisplayValue = "EXIT" }; OnScanCompleted?.Invoke(barcode); //Task.Delay(200).Wait(); Thread.Sleep(300); ((BarcodeScannerActivity)_activity).Finish(); //Finsh해야 스캔 화면 종료됨. } else { //연속스캔 사이의 간격 지정 //Task.Delay(1000).Wait(); Thread.Sleep(1000); } } } else { mBarcodeGraphic.UpdateBarcode(item.JavaCast <Barcode>(), "스캔 대상X", 2); Warning(); } } //비고정(스캔 대상이 없음) else { //현재로서는 biz로직이 없음 //mBarcodeGraphic.UpdateBarcode(item.JavaCast<Barcode>(), 0, ((BarcodeScannerActivity)_activity).rowPosition++); //OnScanCompleted(item.JavaCast<Barcode>()); //if (!((BarcodeScannerActivity)_activity).ScanCompletedBarcode.Contains(item.JavaCast<Barcode>().DisplayValue)) //{ // ((BarcodeScannerActivity)_activity).ScanCompletedBarcode.Add(item.JavaCast<Barcode>().DisplayValue); //} //Task.Delay(700).Wait(); } } //단일 스캔 else { CameraStop(); mBarcodeGraphic.UpdateBarcode(item.JavaCast <Barcode>(), string.Empty, 1); OnScanCompleted?.Invoke(item.JavaCast <Barcode>()); ((BarcodeScannerActivity)_activity)._playerBeep.Start(); if (((BarcodeScannerActivity)_activity).vibrator != null) { try { #pragma warning disable CS0618 // Type or member is obsolete ((BarcodeScannerActivity)_activity).vibrator.Vibrate(300); #pragma warning restore CS0618 // Type or member is obsolete } catch (Exception e) { Console.WriteLine(e.Message); } } //Task.Delay(200).Wait(); Thread.Sleep(300); ((BarcodeScannerActivity)_activity).Finish(); //Finsh해야 스캔 화면 종료됨. } if (mBarcodeGraphic != null) { mOverlay.Remove(mBarcodeGraphic); } }
public override void OnMissing(Detector.Detections detections) { this.overlay.Remove(this.faceGraphic); }
public override void OnUpdate(Detector.Detections detections, JObject item) { setBarcode(item); }
/** * Update the position/characteristics of the face within the overlay. */ public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { mOverlay.Add(mBarcodeGraphic); mBarcodeGraphic.UpdateBarcode(item.JavaCast <Barcode> ()); }
public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { _overlay.Add(_faceGraphic); _faceGraphic.UpdateFace((Face)item); }
void Detector.IProcessor.ReceiveDetections(Detector.Detections detections) { Rectangle formsBounds; Rectangle scanRectangle; Rectangle barcodeRectangle; if (detections.DetectedItems.Size() < 1 || !this.isScanning) { return; } try { this.isScanning = false; List <BarcodeResult> barcodeResults = new List <BarcodeResult>(); for (int i = 0; i < detections.DetectedItems.Size(); i++) { Android.Gms.Vision.Barcodes.Barcode barcode = (detections.DetectedItems.ValueAt(i) as Android.Gms.Vision.Barcodes.Barcode); formsBounds = Xamarin.Forms.Application.Current.MainPage.Bounds; //10~90; //30~60; //barcode.BoundingBox.Width() * 0.1; X //barcode.BoundingBox.Width() * 0.8; Width //barcode.BoundingBox.Height() * 0.3; Y //barcode.BoundingBox.Height() * 0.3; Height //int a = this.cameraSource.PreviewSize.Width; //int b = this.cameraSource.PreviewSize.Height; if (formsBounds.Height > formsBounds.Width) { scanRectangle = new Rectangle(this.cameraSource.PreviewSize.Height * 0.1, this.cameraSource.PreviewSize.Width * 0.3 , this.cameraSource.PreviewSize.Height * 0.8, this.cameraSource.PreviewSize.Width * 0.3); } else { scanRectangle = new Rectangle(this.cameraSource.PreviewSize.Width * 0.1, this.cameraSource.PreviewSize.Height * 0.3 , this.cameraSource.PreviewSize.Width * 0.8, this.cameraSource.PreviewSize.Height * 0.3); } barcodeRectangle = new Rectangle(barcode.BoundingBox.Left, barcode.BoundingBox.Top, barcode.BoundingBox.Width(), barcode.BoundingBox.Height()); if (scanRectangle.Contains(barcodeRectangle)) { barcodeResults.Add(this.BarcodeResultConvert(barcode)); } } if (barcodeResults.Count > 0) { OnDetected?.Invoke(barcodeResults); vibrator.Vibrate(1000); Thread.Sleep(3000); } } catch (Exception ex) { Console.WriteLine("BarCodeDetectorProcessor Exception : {0}", ex.ToString()); } finally { this.isScanning = true; } }
/** * Update the position/characteristics of the barcode within the overlay. */ public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { _overlay.Add(_barcodeGraphic); _barcodeGraphic.UpdateBarcode(item.JavaCast <Android.Gms.Vision.Barcodes.Barcode>()); }
/** * Facial position update */ public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { graphicOverlay.Remove(faceGraphic); graphicOverlay.Add(faceGraphic); faceGraphic.UaktualnijTwarz(item.JavaCast <Face>()); }
/** * Hide the graphic when the corresponding barcode was not detected. This can happen for * intermediate frames temporarily (e.g., if the barcode was momentarily blocked from * view). */ public override void OnMissing(Detector.Detections detections) { _overlay.Remove(_barcodeGraphic); }
public override void OnMissing(Detector.Detections detections) { mOverlay.Remove(mFaceGraphic); }
/** * Update the position/characteristics of the face within the overlay. */ public override void OnUpdate(Detector.Detections detections, Java.Lang.Object item) { mOverlay.Add(mFaceGraphic); mFaceGraphic.UpdateFace(item.JavaCast <Face>()); }