Beispiel #1
0
        public void Defaults()
        {
            TestRuntime.AssertXcodeVersion(6, 0);
            TestRuntime.AssertSystemVersion(PlatformName.MacOSX, 10, 10, throwIfOtherPlatform: false);

            using (var obj = new AVMetadataFaceObject()) {
                Assert.AreEqual((nint)0, obj.FaceID, "FaceID");
                Assert.AreEqual(false, obj.HasRollAngle, "HasRollAngle");
                Assert.AreEqual(false, obj.HasYawAngle, "HasYawAngle");
#if !MONOMAC // No Type property for Mac
                Assert.AreEqual(AVMetadataObjectType.Face, obj.Type, "Type");
#endif
                Assert.AreEqual(AVMetadataObject.TypeFace, obj.WeakType, "WeakType");
            }

#if !MONOMAC // iOS only
            using (var obj = new AVMetadataMachineReadableCodeObject()) {
                Assert.IsNotNull(obj.Corners, "Corners");
                Assert.AreEqual(0, obj.Corners.Length, "Corners");
                Assert.IsNull(obj.StringValue, "StringValue");
                Assert.AreEqual(AVMetadataObjectType.None, obj.Type, "Type");
                Assert.IsNull(obj.WeakType, "WeakType");
            }
#endif
        }
Beispiel #2
0
            public override void DidOutputMetadataObjects(AVCaptureMetadataOutput captureOutput, AVMetadataObject[] metadataObjects, AVCaptureConnection connection)
            {
                string text = string.Empty;

                for (int i = 0; i < metadataObjects.Length; i++)
                {
                    AVMetadataObject aVMetadataObject = metadataObjects[i];
                    AVMetadataMachineReadableCodeObject aVMetadataMachineReadableCodeObject = aVMetadataObject as AVMetadataMachineReadableCodeObject;
                    if (aVMetadataMachineReadableCodeObject != null)
                    {
                        AVMetadataMachineReadableCodeObject aVMetadataMachineReadableCodeObject2 = aVMetadataMachineReadableCodeObject;
                        text = aVMetadataMachineReadableCodeObject2.StringValue;
                        text = this._view.ScannedBarcode(text);
                        if (!string.IsNullOrEmpty(text))
                        {
                            int num = this.Buffer.Add(text);
                            if (num > 0)
                            {
                                this._view.ScanOccurred(text);
                            }
                        }
                    }
                    else
                    {
                        iApp.Log.Info("Invalid AVMetadataObject type: " + aVMetadataObject.Type.ToString(), new object[0]);
                    }
                }
            }
        public void Defaults()
        {
            if (!TestRuntime.CheckSystemAndSDKVersion(8, 0))
            {
                Assert.Ignore("Test only works correctly in iOS 8+");
            }

            using (var obj = new AVMetadataFaceObject()) {
                Assert.AreEqual(0, obj.FaceID, "FaceID");
                Assert.AreEqual(false, obj.HasRollAngle, "HasRollAngle");
                Assert.AreEqual(false, obj.HasYawAngle, "HasYawAngle");
#if XAMCORE_2_0
#if !MONOMAC // No Type property for Mac
                Assert.AreEqual(AVMetadataObjectType.Face, obj.Type, "Type");
#endif
                Assert.AreEqual(AVMetadataObject.TypeFace, obj.WeakType, "WeakType");
#else
                Assert.AreEqual(AVMetadataObject.TypeFace, obj.Type, "Type");
#endif
            }

#if !MONOMAC // iOS only
            using (var obj = new AVMetadataMachineReadableCodeObject()) {
                Assert.IsNotNull(obj.Corners, "Corners");
                Assert.AreEqual(0, obj.Corners.Length, "Corners");
                Assert.IsNull(obj.StringValue, "StringValue");
#if XAMCORE_2_0
                Assert.AreEqual(AVMetadataObjectType.None, obj.Type, "Type");
                Assert.IsNull(obj.WeakType, "WeakType");
#else
                Assert.IsNull(obj.Type, "Type");
#endif
            }
#endif
        }
Beispiel #4
0
 public void DidOutputMetadataObjects(AVFoundation.AVCaptureMetadataOutput captureOutput, AVFoundation.AVMetadataObject[] metadataObjects, AVFoundation.AVCaptureConnection connection)
 {
     if (null != captureOutput && metadataObjects.Length > 0 && canReceiveData)
     {
         canReceiveData = false;
         AVMetadataMachineReadableCodeObject metadataObj = metadataObjects [0] as AVMetadataMachineReadableCodeObject;
         NSString result = new NSString();
         if (metadataObj.Type.Equals(AVMetadataObjectType.QRCode))
         {
             result = new NSString(metadataObj.StringValue);
         }
         else
         {
             result = new NSString("It's not a QRCode.");
         }
         this.PerformSelector(new ObjCRuntime.Selector("reportScanResult:"), NSThread.MainThread, result, false);
     }
 }
Beispiel #5
0
            public override void DidOutputMetadataObjects(AVCaptureMetadataOutput captureOutput, AVMetadataObject[] metadataObjects, AVCaptureConnection connection)
            {
                string barcode = string.Empty;

                DateTime start = DateTime.UtcNow;

                foreach (AVMetadataObject metadataObject in metadataObjects)
                {
                    var metaObject = metadataObject as AVMetadataMachineReadableCodeObject;

                    if (metaObject != null)
                    {
                        AVMetadataMachineReadableCodeObject readableObject = metaObject;
                        barcode = readableObject.StringValue;
                        iApp.Log.Info("Barcode scanned (Type: " + metadataObject.Type + ") = " + barcode);

                        if (_layer != null)
                        {
                            barcode = _layer.ScannedBarcode(barcode);
                        }

                        if (!string.IsNullOrEmpty(barcode))
                        {
                            int result = Buffer.Add(barcode);
                            if (result > 0)
                            {
                                // update the UI
                                _view.ScanOccurred(barcode, result);
                            }
                        }
                    }
                    else
                    {
                        iApp.Log.Info("Invalid AVMetadataObject type: " + metadataObject.Type.ToString());
                    }
                }
                iApp.Log.Debug("Total Barcodes scanned is: " + Buffer.CurrentBuffer.Length);
            }