Esempio n. 1
0
        public IEnumerable <Rectangle> ExtractLicensePlates()
        {
            ObjectsResponse ??= _client.Annotate(new AnnotateImageRequest()
            {
                Image    = _image,
                Features =
                {
                    new Feature {
                        Type = Feature.Types.Type.ObjectLocalization
                    }
                }
            });

            return(ObjectsResponse.LocalizedObjectAnnotations.Where(e => e.Name == "License plate")
                   .Select(e => GoogleVisionCoordinateTranslator.RelativePolyToRectangle(e.BoundingPoly, Width, Height)));
        }
Esempio n. 2
0
        public virtual IEnumerable <Rectangle> ExtractText()
        {
            TextResponse ??= _client.Annotate(new AnnotateImageRequest()
            {
                Image    = _image,
                Features =
                {
                    new Feature {
                        Type = Feature.Types.Type.TextDetection
                    }
                }
            });

            // filter text annotations that contains line breaks, this is probably the first one covering the whole image
            return(TextResponse.TextAnnotations.Where(t => !t.Description.Contains("\n"))
                   .Select(t => GoogleVisionCoordinateTranslator.AbsolutePolyToRectangle(t.BoundingPoly)));
        }
Esempio n. 3
0
        public virtual IEnumerable <Rectangle> ExtractFaces()
        {
            FacesResponse ??= _client.Annotate(new AnnotateImageRequest()
            {
                Image    = _image,
                Features =
                {
                    new Feature {
                        Type = Feature.Types.Type.FaceDetection
                    }
                }
            });

            return(FacesResponse.FaceAnnotations
                   .Select(f => GoogleVisionCoordinateTranslator.AbsolutePolyToRectangle(f.BoundingPoly))
                   .Select(f => GoogleVisionCoordinateTranslator.RotateRectangle(f, _rotationToApplyForFaceProcessing, Width, Height)));
        }