예제 #1
0
        public void VNSupportedRevisionsTwoTest()
        {
            // Tests '*RequestRevision.Two' given to APIs.
            var rect = new CGRect(0, 0, 10, 10);

            Assert.DoesNotThrow(() => {
                var detectedObjectObservation = VNDetectedObjectObservation.FromBoundingBox(VNDetectedObjectObservationRequestRevision.Two, rect);
                Assert.NotNull(detectedObjectObservation, "detectedObjectObservation is null");
                Assert.That(detectedObjectObservation.BoundingBox, Is.EqualTo(rect));

                var faceObservation = VNFaceObservation.FromBoundingBox(VNFaceObservationRequestRevision.Two, rect);
                Assert.NotNull(faceObservation, "faceObservation is null");
                Assert.That(faceObservation.BoundingBox, Is.EqualTo(rect));

                var recognizedObjectObservation = VNRecognizedObjectObservation.FromBoundingBox(VNRecognizedObjectObservationRequestRevision.Two, rect);
                Assert.NotNull(recognizedObjectObservation, "recognizedObjectObservation is null");
                Assert.That(recognizedObjectObservation.BoundingBox, Is.EqualTo(rect));

                var rectangleObservation = VNRectangleObservation.FromBoundingBox(VNRectangleObservationRequestRevision.Two, rect);
                Assert.NotNull(rectangleObservation, "rectangleObservation is null");
                Assert.That(rectangleObservation.BoundingBox, Is.EqualTo(rect));

                var textObservation = VNTextObservation.FromBoundingBox(VNTextObservationRequestRevision.Two, rect);
                Assert.NotNull(textObservation, "textObservation is null");
                Assert.That(textObservation.BoundingBox, Is.EqualTo(rect));

                var barcodeObservation = VNBarcodeObservation.FromBoundingBox(VNBarcodeObservationRequestRevision.Two, rect);
                Assert.NotNull(barcodeObservation, "barcodeObservation is null");
                Assert.That(barcodeObservation.BoundingBox, Is.EqualTo(rect));
            }, "*RequestRevision.Two throw");
        }
예제 #2
0
        public void VNSupportedRevisionsTwoTest()
        {
            // Tests '*RequestRevision.Two' given to APIs.
            var rect = new CGRect(0, 0, 10, 10);
            {
                var detectedObjectObservation = VNDetectedObjectObservation.FromBoundingBox(VNDetectedObjectObservationRequestRevision.Two, rect);
                Assert.NotNull(detectedObjectObservation, "detectedObjectObservation is null");
                Assert.That(detectedObjectObservation.BoundingBox, Is.EqualTo(rect));

                var faceObservation = VNFaceObservation.FromBoundingBox(VNFaceObservationRequestRevision.Two, rect);
                Assert.NotNull(faceObservation, "faceObservation is null");
                Assert.That(faceObservation.BoundingBox, Is.EqualTo(rect));

                var recognizedObjectObservation = VNRecognizedObjectObservation.FromBoundingBox(VNRecognizedObjectObservationRequestRevision.Two, rect);
                if (TestRuntime.CheckXcodeVersion(11, 0) && !TestRuntime.CheckXcodeVersion(12, 0))
                {
                    Assert.Null(recognizedObjectObservation, "recognizedObjectObservation is null");
                }
                else
                {
                    Assert.NotNull(recognizedObjectObservation, "recognizedObjectObservation is null");
                    Assert.That(recognizedObjectObservation.BoundingBox, Is.EqualTo(rect));
                }

                var rectangleObservation = VNRectangleObservation.FromBoundingBox(VNRectangleObservationRequestRevision.Two, rect);
                Assert.NotNull(rectangleObservation, "rectangleObservation is null");
                Assert.That(rectangleObservation.BoundingBox, Is.EqualTo(rect));

                var textObservation = VNTextObservation.FromBoundingBox(VNTextObservationRequestRevision.Two, rect);
                Assert.NotNull(textObservation, "textObservation is null");
                Assert.That(textObservation.BoundingBox, Is.EqualTo(rect));

                var barcodeObservation = VNBarcodeObservation.FromBoundingBox(VNBarcodeObservationRequestRevision.Two, rect);
                Assert.NotNull(barcodeObservation, "barcodeObservation is null");
                Assert.That(barcodeObservation.BoundingBox, Is.EqualTo(rect));
            }
        }
예제 #3
0
        public void VNSupportedRevisionsUnsupportedTest()
        {
            var allSupported = new List <(string type, IEnumerable revs)> {
                (nameof(VNCoreMLRequest), VNCoreMLRequest.SupportedRevisions),
                (nameof(VNDetectBarcodesRequest), VNDetectBarcodesRequest.SupportedRevisions),
                (nameof(VNDetectFaceLandmarksRequest), VNDetectFaceLandmarksRequest.SupportedRevisions),
                (nameof(VNDetectFaceRectanglesRequest), VNDetectFaceRectanglesRequest.SupportedRevisions),
                (nameof(VNDetectHorizonRequest), VNDetectHorizonRequest.SupportedRevisions),
                (nameof(VNDetectRectanglesRequest), VNDetectRectanglesRequest.SupportedRevisions),
                (nameof(VNDetectTextRectanglesRequest), VNDetectTextRectanglesRequest.SupportedRevisions),
                (nameof(VNTranslationalImageRegistrationRequest), VNTranslationalImageRegistrationRequest.SupportedRevisions),
                (nameof(VNHomographicImageRegistrationRequest), VNHomographicImageRegistrationRequest.SupportedRevisions),
                (nameof(VNTrackObjectRequest), VNTrackObjectRequest.SupportedRevisions),
                (nameof(VNTrackRectangleRequest), VNTrackRectangleRequest.SupportedRevisions),
            };

            foreach (var revisions in allSupported)
            {
                var type = revisions.type;
                foreach (object rev in revisions.revs)
                {
                    Assert.That(Convert.ChangeType(rev, Enum.GetUnderlyingType(rev.GetType())), Is.Not.EqualTo(0), $"SupportedRevisions Unspecified found: {type}");
                }
            }

            var allDefault = new List <(string type, object rev)> {
                (nameof(VNCoreMLRequest), VNCoreMLRequest.DefaultRevision),
                (nameof(VNDetectBarcodesRequest), VNDetectBarcodesRequest.DefaultRevision),
                (nameof(VNDetectFaceLandmarksRequest), VNDetectFaceLandmarksRequest.DefaultRevision),
                (nameof(VNDetectFaceRectanglesRequest), VNDetectFaceRectanglesRequest.DefaultRevision),
                (nameof(VNDetectHorizonRequest), VNDetectHorizonRequest.DefaultRevision),
                (nameof(VNDetectRectanglesRequest), VNDetectRectanglesRequest.DefaultRevision),
                (nameof(VNDetectTextRectanglesRequest), VNDetectTextRectanglesRequest.DefaultRevision),
                (nameof(VNTranslationalImageRegistrationRequest), VNTranslationalImageRegistrationRequest.DefaultRevision),
                (nameof(VNHomographicImageRegistrationRequest), VNHomographicImageRegistrationRequest.DefaultRevision),
                (nameof(VNTrackObjectRequest), VNTrackObjectRequest.DefaultRevision),
                (nameof(VNTrackRectangleRequest), VNTrackRectangleRequest.DefaultRevision),
            };

            foreach (var defrev in allDefault)
            {
                Assert.That(Convert.ChangeType(defrev.rev, Enum.GetUnderlyingType(defrev.rev.GetType())), Is.Not.EqualTo(0), $"DefaultRevision Unspecified found: {defrev.type}");
            }

            var allCurrent = new List <(string type, object rev)> {
                (nameof(VNCoreMLRequest), VNCoreMLRequest.CurrentRevision),
                (nameof(VNDetectBarcodesRequest), VNDetectBarcodesRequest.CurrentRevision),
                (nameof(VNDetectFaceLandmarksRequest), VNDetectFaceLandmarksRequest.CurrentRevision),
                (nameof(VNDetectFaceRectanglesRequest), VNDetectFaceRectanglesRequest.CurrentRevision),
                (nameof(VNDetectHorizonRequest), VNDetectHorizonRequest.CurrentRevision),
                (nameof(VNDetectRectanglesRequest), VNDetectRectanglesRequest.CurrentRevision),
                (nameof(VNDetectTextRectanglesRequest), VNDetectTextRectanglesRequest.CurrentRevision),
                (nameof(VNTranslationalImageRegistrationRequest), VNTranslationalImageRegistrationRequest.CurrentRevision),
                (nameof(VNHomographicImageRegistrationRequest), VNHomographicImageRegistrationRequest.CurrentRevision),
                (nameof(VNTrackObjectRequest), VNTrackObjectRequest.CurrentRevision),
                (nameof(VNTrackRectangleRequest), VNTrackRectangleRequest.CurrentRevision),
            };

            foreach (var currev in allCurrent)
            {
                Assert.That(Convert.ChangeType(currev.rev, Enum.GetUnderlyingType(currev.rev.GetType())), Is.Not.EqualTo(0), $"CurrentRevision Unspecified found: {currev.type}");
            }

            // Tests 'VNRequestRevision.Unspecified' given to APIs.
            var rect = new CGRect(0, 0, 10, 10);
            {
                var detectedObjectObservation = VNDetectedObjectObservation.FromBoundingBox(VNDetectedObjectObservationRequestRevision.Unspecified, rect);
                Assert.NotNull(detectedObjectObservation, "detectedObjectObservation is null");
                Assert.That(detectedObjectObservation.BoundingBox, Is.EqualTo(rect));

                var faceObservation = VNFaceObservation.FromBoundingBox(VNFaceObservationRequestRevision.Unspecified, rect);
                Assert.NotNull(faceObservation, "faceObservation is null");
                Assert.That(faceObservation.BoundingBox, Is.EqualTo(rect));

                var recognizedObjectObservation = VNRecognizedObjectObservation.FromBoundingBox(VNRecognizedObjectObservationRequestRevision.Unspecified, rect);
                if (TestRuntime.CheckXcodeVersion(11, 0) && !TestRuntime.CheckXcodeVersion(12, 0))
                {
                    Assert.IsNull(recognizedObjectObservation, "recognizedObjectObservation is null");
                }
                else
                {
                    Assert.NotNull(recognizedObjectObservation, "recognizedObjectObservation is null");
                    Assert.That(recognizedObjectObservation.BoundingBox, Is.EqualTo(rect));
                }

                var rectangleObservation = VNRectangleObservation.FromBoundingBox(VNRectangleObservationRequestRevision.Unspecified, rect);
                Assert.NotNull(rectangleObservation, "rectangleObservation is null");
                Assert.That(rectangleObservation.BoundingBox, Is.EqualTo(rect));

                var textObservation = VNTextObservation.FromBoundingBox(VNTextObservationRequestRevision.Unspecified, rect);
                Assert.NotNull(textObservation, "textObservation is null");
                Assert.That(textObservation.BoundingBox, Is.EqualTo(rect));

                var barcodeObservation = VNBarcodeObservation.FromBoundingBox(VNBarcodeObservationRequestRevision.Unspecified, rect);
                Assert.NotNull(barcodeObservation, "barcodeObservation is null");
                Assert.That(barcodeObservation.BoundingBox, Is.EqualTo(rect));
            }

            // Tests random request revision
            {
                var detectedObjectObservation = VNDetectedObjectObservation.FromBoundingBox((VNDetectedObjectObservationRequestRevision)5000, rect);
                Assert.NotNull(detectedObjectObservation, "randomRevision detectedObjectObservation is null");
                Assert.That(detectedObjectObservation.BoundingBox, Is.EqualTo(rect));

                var faceObservation = VNFaceObservation.FromBoundingBox((VNFaceObservationRequestRevision)5000, rect);
                Assert.NotNull(faceObservation, "randomRevision faceObservation is null");
                Assert.That(faceObservation.BoundingBox, Is.EqualTo(rect));

                var recognizedObjectObservation = VNRecognizedObjectObservation.FromBoundingBox((VNRecognizedObjectObservationRequestRevision)5000, rect);
                if (TestRuntime.CheckXcodeVersion(11, 0) && !TestRuntime.CheckXcodeVersion(12, 0))
                {
                    Assert.IsNull(recognizedObjectObservation, "randomRevision recognizedObjectObservation is null");
                }
                else
                {
                    Assert.NotNull(recognizedObjectObservation, "randomRevision recognizedObjectObservation is null");
                    Assert.That(recognizedObjectObservation.BoundingBox, Is.EqualTo(rect));
                }

                var rectangleObservation = VNRectangleObservation.FromBoundingBox((VNRectangleObservationRequestRevision)5000, rect);
                Assert.NotNull(rectangleObservation, "randomRevision rectangleObservation is null");
                Assert.That(rectangleObservation.BoundingBox, Is.EqualTo(rect));

                var textObservation = VNTextObservation.FromBoundingBox((VNTextObservationRequestRevision)5000, rect);
                Assert.NotNull(textObservation, "randomRevision textObservation is null");
                Assert.That(textObservation.BoundingBox, Is.EqualTo(rect));

                var barcodeObservation = VNBarcodeObservation.FromBoundingBox((VNBarcodeObservationRequestRevision)5000, rect);
                Assert.NotNull(barcodeObservation, "randomRevision barcodeObservation is null");
                Assert.That(barcodeObservation.BoundingBox, Is.EqualTo(rect));
            }
        }