From b66ec4d7598b9654335ad377b8404b8632090922 Mon Sep 17 00:00:00 2001 From: Alex Soto Date: Wed, 9 Aug 2017 10:12:33 -0500 Subject: [PATCH] [Vision] Update to Xcode 9 Beta 5 (#2458) --- src/Vision/VNFaceLandmarkRegion2D.cs | 32 +++-- src/vision.cs | 173 +++++++++++++++++++------ tests/introspection/ApiCtorInitTest.cs | 4 + 3 files changed, 161 insertions(+), 48 deletions(-) diff --git a/src/Vision/VNFaceLandmarkRegion2D.cs b/src/Vision/VNFaceLandmarkRegion2D.cs index 386b9fde8e04..afff1bca0d5f 100644 --- a/src/Vision/VNFaceLandmarkRegion2D.cs +++ b/src/Vision/VNFaceLandmarkRegion2D.cs @@ -10,31 +10,45 @@ #if XAMCORE_2_0 using System; -using Vector2 = global::OpenTK.Vector2; +using XamCore.CoreGraphics; namespace XamCore.Vision { public partial class VNFaceLandmarkRegion2D { - public Vector2 this [nuint index] { - get { return GetPoint (index); } - } - - public virtual Vector2 [] Points { + public virtual CGPoint [] NormalizedPoints { get { - var ret = _GetPoints (); + var ret = _GetNormalizedPoints (); if (ret == IntPtr.Zero) return null; unsafe { var count = (int) PointCount; - var rv = new Vector2 [count]; - var ptr = (Vector2*) ret; + var rv = new CGPoint [count]; + var ptr = (CGPoint*) ret; for (int i = 0; i < count; i++) rv [i] = *ptr++; return rv; } } } + + public virtual CGPoint [] GetPointsInImage (CGSize imageSize) + { + // return the address of the array of pointCount points + // or NULL if the conversion could not take place. + var ret = _GetPointsInImage (imageSize); + if (ret == IntPtr.Zero) + return null; + + unsafe { + var count = (int) PointCount; + var rv = new CGPoint [count]; + var ptr = (CGPoint*) ret; + for (int i = 0; i < count; i++) + rv [i] = *ptr++; + return rv; + } + } } } #endif diff --git a/src/vision.cs b/src/vision.cs index 2c39f03045f5..c4f3a301d622 100644 --- a/src/vision.cs +++ b/src/vision.cs @@ -67,25 +67,25 @@ enum VNBarcodeSymbology { [Field ("VNBarcodeSymbologyAztec")] Aztec, - [Field ("VNBarcodeSymbologyCODE39")] + [Field ("VNBarcodeSymbologyCode39")] Code39, - [Field ("VNBarcodeSymbologyCODE39Checksum")] + [Field ("VNBarcodeSymbologyCode39Checksum")] Code39Checksum, - [Field ("VNBarcodeSymbologyCODE39FullASCII")] + [Field ("VNBarcodeSymbologyCode39FullASCII")] Code39FullAscii, - [Field ("VNBarcodeSymbologyCODE39FullASCIIChecksum")] + [Field ("VNBarcodeSymbologyCode39FullASCIIChecksum")] Code39FullAsciiChecksum, - [Field ("VNBarcodeSymbologyCODE93")] + [Field ("VNBarcodeSymbologyCode93")] Code93, - [Field ("VNBarcodeSymbologyCODE93i")] + [Field ("VNBarcodeSymbologyCode93i")] Code93i, - [Field ("VNBarcodeSymbologyCODE128")] + [Field ("VNBarcodeSymbologyCode128")] Code128, [Field ("VNBarcodeSymbologyDataMatrix")] @@ -97,10 +97,10 @@ enum VNBarcodeSymbology { [Field ("VNBarcodeSymbologyEAN13")] Ean13, - [Field ("VNBarcodeSymbologyI2OF5")] + [Field ("VNBarcodeSymbologyI2of5")] I2OF5, - [Field ("VNBarcodeSymbologyI2OF5Checksum")] + [Field ("VNBarcodeSymbologyI2of5Checksum")] I2OF5Checksum, [Field ("VNBarcodeSymbologyITF14")] @@ -264,12 +264,12 @@ interface VNFaceLandmarkRegion { interface VNFaceLandmarkRegion2D { [Internal] - [Export ("points")] - IntPtr _GetPoints (); + [Export ("normalizedPoints")] + IntPtr _GetNormalizedPoints (); - [Export ("pointAtIndex:")] - [MarshalDirective (NativePrefix = "xamarin_simd__", Library = "__Internal")] - Vector2 GetPoint (nuint index); + [Internal] + [Export ("pointsInImageOfSize:")] + IntPtr _GetPointsInImage (CGSize imageSize); } [TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] @@ -586,6 +586,9 @@ interface VNBarcodeObservation { [Static] [Export ("observationWithBoundingBox:")] VNBarcodeObservation FromBoundingBox (CGRect boundingBox); + + [NullAllowed, Export ("payloadStringValue")] + string PayloadStringValue { get; } } [TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] @@ -655,6 +658,9 @@ interface VNRequest : NSCopying { [NullAllowed, Export ("completionHandler", ArgumentSemantic.Copy)] VNRequestCompletionHandler CompletionHandler { get; } + + [Export ("usesCPUOnly")] + bool UsesCpuOnly { get; set; } } [TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] @@ -680,6 +686,9 @@ interface VNImageOptionKeys { [Field ("VNImageOptionCameraIntrinsics")] NSString CameraIntrinsicsKey { get; } + + [Field ("VNImageOptionCIContext")] + NSString CIContextKey { get; } } [TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] @@ -692,6 +701,7 @@ interface VNImageOptions { CoreGraphics.CGImageProperties Properties { get; set; } NSData CameraIntrinsics { get; set; } + CIContext CIContext { get; set; } } [TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] @@ -804,40 +814,125 @@ interface VNSequenceRequestHandler { [DisableDefaultCtor] interface VNTargetedImageRequest { - [Export ("initWithTargetedCVPixelBuffer:")] - IntPtr Constructor (CVPixelBuffer pixelBuffer); + [Export ("initWithTargetedCVPixelBuffer:options:")] + IntPtr Constructor (CVPixelBuffer pixelBuffer, NSDictionary optionsDict); - [Export ("initWithTargetedCVPixelBuffer:completionHandler:")] - [DesignatedInitializer] - IntPtr Constructor (CVPixelBuffer pixelBuffer, [NullAllowed] VNRequestCompletionHandler completionHandler); + [Wrap ("this (pixelBuffer, options?.Dictionary)")] + IntPtr Constructor (CVPixelBuffer pixelBuffer, VNImageOptions options); - [Export ("initWithTargetedCGImage:")] - IntPtr Constructor (CGImage image); + [Export ("initWithTargetedCVPixelBuffer:options:completionHandler:")] + IntPtr Constructor (CVPixelBuffer pixelBuffer, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); - [Export ("initWithTargetedCGImage:completionHandler:")] - [DesignatedInitializer] - IntPtr Constructor (CGImage image, [NullAllowed] VNRequestCompletionHandler completionHandler); + [Wrap ("this (pixelBuffer, options?.Dictionary, completionHandler)")] + IntPtr Constructor (CVPixelBuffer pixelBuffer, VNImageOptions options, VNRequestCompletionHandler completionHandler); - [Export ("initWithTargetedCIImage:")] - IntPtr Constructor (CIImage image); + [Export ("initWithTargetedCVPixelBuffer:orientation:options:")] + IntPtr Constructor (CVPixelBuffer pixelBuffer, CGImagePropertyOrientation orientation, NSDictionary optionsDict); - [Export ("initWithTargetedCIImage:completionHandler:")] - [DesignatedInitializer] - IntPtr Constructor (CIImage image, [NullAllowed] VNRequestCompletionHandler completionHandler); + [Wrap ("this (pixelBuffer, orientation, options?.Dictionary)")] + IntPtr Constructor (CVPixelBuffer pixelBuffer, CGImagePropertyOrientation orientation, VNImageOptions options); - [Export ("initWithTargetedImageURL:")] - IntPtr Constructor (NSUrl imageUrl); + [Export ("initWithTargetedCVPixelBuffer:orientation:options:completionHandler:")] + IntPtr Constructor (CVPixelBuffer pixelBuffer, CGImagePropertyOrientation orientation, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); - [Export ("initWithTargetedImageURL:completionHandler:")] - [DesignatedInitializer] - IntPtr Constructor (NSUrl imageUrl, [NullAllowed] VNRequestCompletionHandler completionHandler); + [Wrap ("this (pixelBuffer, orientation, options?.Dictionary, completionHandler)")] + IntPtr Constructor (CVPixelBuffer pixelBuffer, CGImagePropertyOrientation orientation, VNImageOptions options, VNRequestCompletionHandler completionHandler); - [Export ("initWithTargetedImageData:")] - IntPtr Constructor (NSData imageData); + [Export ("initWithTargetedCGImage:options:")] + IntPtr Constructor (CGImage cgImage, NSDictionary optionsDict); - [Export ("initWithTargetedImageData:completionHandler:")] - [DesignatedInitializer] - IntPtr Constructor (NSData imageData, [NullAllowed] VNRequestCompletionHandler completionHandler); + [Wrap ("this (cgImage, options?.Dictionary)")] + IntPtr Constructor (CGImage cgImage, VNImageOptions options); + + [Export ("initWithTargetedCGImage:options:completionHandler:")] + IntPtr Constructor (CGImage cgImage, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); + + [Wrap ("this (cgImage, options?.Dictionary, completionHandler)")] + IntPtr Constructor (CGImage cgImage, VNImageOptions options, VNRequestCompletionHandler completionHandler); + + [Export ("initWithTargetedCGImage:orientation:options:")] + IntPtr Constructor (CGImage cgImage, CGImagePropertyOrientation orientation, NSDictionary optionsDict); + + [Wrap ("this (cgImage, orientation, options?.Dictionary)")] + IntPtr Constructor (CGImage cgImage, CGImagePropertyOrientation orientation, VNImageOptions options); + + [Export ("initWithTargetedCGImage:orientation:options:completionHandler:")] + IntPtr Constructor (CGImage cgImage, CGImagePropertyOrientation orientation, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); + + [Wrap ("this (cgImage, orientation, options?.Dictionary, completionHandler)")] + IntPtr Constructor (CGImage cgImage, CGImagePropertyOrientation orientation, VNImageOptions options, VNRequestCompletionHandler completionHandler); + + [Export ("initWithTargetedCIImage:options:")] + IntPtr Constructor (CIImage ciImage, NSDictionary optionsDict); + + [Wrap ("this (ciImage, options?.Dictionary)")] + IntPtr Constructor (CIImage ciImage, VNImageOptions options); + + [Export ("initWithTargetedCIImage:options:completionHandler:")] + IntPtr Constructor (CIImage ciImage, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); + + [Wrap ("this (ciImage, options?.Dictionary, completionHandler)")] + IntPtr Constructor (CIImage ciImage, VNImageOptions options, VNRequestCompletionHandler completionHandler); + + [Export ("initWithTargetedCIImage:orientation:options:")] + IntPtr Constructor (CIImage ciImage, CGImagePropertyOrientation orientation, NSDictionary optionsDict); + + [Wrap ("this (ciImage, orientation, options?.Dictionary)")] + IntPtr Constructor (CIImage ciImage, CGImagePropertyOrientation orientation, VNImageOptions options); + + [Export ("initWithTargetedCIImage:orientation:options:completionHandler:")] + IntPtr Constructor (CIImage ciImage, CGImagePropertyOrientation orientation, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); + + [Wrap ("this (ciImage, orientation, options?.Dictionary, completionHandler)")] + IntPtr Constructor (CIImage ciImage, CGImagePropertyOrientation orientation, VNImageOptions options, VNRequestCompletionHandler completionHandler); + + [Export ("initWithTargetedImageURL:options:")] + IntPtr Constructor (NSUrl imageUrl, NSDictionary optionsDict); + + [Wrap ("this (imageUrl, options?.Dictionary)")] + IntPtr Constructor (NSUrl imageUrl, VNImageOptions options); + + [Export ("initWithTargetedImageURL:options:completionHandler:")] + IntPtr Constructor (NSUrl imageUrl, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); + + [Wrap ("this (imageUrl, options?.Dictionary, completionHandler)")] + IntPtr Constructor (NSUrl imageUrl, VNImageOptions options, VNRequestCompletionHandler completionHandler); + + [Export ("initWithTargetedImageURL:orientation:options:")] + IntPtr Constructor (NSUrl imageUrl, CGImagePropertyOrientation orientation, NSDictionary optionsDict); + + [Wrap ("this (imageUrl, orientation, options?.Dictionary)")] + IntPtr Constructor (NSUrl imageUrl, CGImagePropertyOrientation orientation, VNImageOptions options); + + [Export ("initWithTargetedImageURL:orientation:options:completionHandler:")] + IntPtr Constructor (NSUrl imageUrl, CGImagePropertyOrientation orientation, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); + + [Wrap ("this (imageUrl, orientation, options?.Dictionary, completionHandler)")] + IntPtr Constructor (NSUrl imageUrl, CGImagePropertyOrientation orientation, VNImageOptions options, VNRequestCompletionHandler completionHandler); + + [Export ("initWithTargetedImageData:options:")] + IntPtr Constructor (NSData imageData, NSDictionary optionsDict); + + [Wrap ("this (imageData, options?.Dictionary)")] + IntPtr Constructor (NSData imageData, VNImageOptions options); + + [Export ("initWithTargetedImageData:options:completionHandler:")] + IntPtr Constructor (NSData imageData, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); + + [Wrap ("this (imageData, options?.Dictionary, completionHandler)")] + IntPtr Constructor (NSData imageData, VNImageOptions options, VNRequestCompletionHandler completionHandler); + + [Export ("initWithTargetedImageData:orientation:options:")] + IntPtr Constructor (NSData imageData, CGImagePropertyOrientation orientation, NSDictionary optionsDict); + + [Wrap ("this (imageData, orientation, options?.Dictionary)")] + IntPtr Constructor (NSData imageData, CGImagePropertyOrientation orientation, VNImageOptions options); + + [Export ("initWithTargetedImageData:orientation:options:completionHandler:")] + IntPtr Constructor (NSData imageData, CGImagePropertyOrientation orientation, NSDictionary optionsDict, [NullAllowed] VNRequestCompletionHandler completionHandler); + + [Wrap ("this (imageData, orientation, options?.Dictionary, completionHandler)")] + IntPtr Constructor (NSData imageData, CGImagePropertyOrientation orientation, VNImageOptions options, VNRequestCompletionHandler completionHandler); } [TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)] diff --git a/tests/introspection/ApiCtorInitTest.cs b/tests/introspection/ApiCtorInitTest.cs index c44bd9968e2f..03fa80b7df17 100644 --- a/tests/introspection/ApiCtorInitTest.cs +++ b/tests/introspection/ApiCtorInitTest.cs @@ -358,6 +358,10 @@ protected virtual bool Match (ConstructorInfo ctor, Type type) #endif return true; break; + case "VNTargetedImageRequest": // Explicitly disabled + if (ctor.ToString () == "Void .ctor(VNRequestCompletionHandler)") + return true; + break; } var ep = ctor.GetParameters ();