I want to detect bar codes using the new Vision API of iOS 11 with C# / Xamarin.
However, the VNDetectBarcodesRequest class of xamarin is abstract. Other request types, for example VNDetectRectanglesRequest are not. Is this part of the framework not implemented in Xamarin or am I missing something here?
Basically I want to adapt the rectangle detection sample (https://developer.xamarin.com/samples/monotouch/ios11/VisionRectangles/) to detect QR codes.
Thank you very much!
That is a bug in the Xamarin generated bindings as it is correctly bound except for the incorrectly applied [Abstract] attribute.
Note: I created a Github issue: xamarin-macios/issues/3140
Since the binding otherwise is correct, you can work around by creating your own VNDetectBarcodesRequest subclass.
public class FixVNDetectBarcodesRequest : VNDetectBarcodesRequest
{
public FixVNDetectBarcodesRequest(NSObjectFlag t) : base(t) { }
public FixVNDetectBarcodesRequest(IntPtr handle) : base(handle) { }
public FixVNDetectBarcodesRequest(VNRequestCompletionHandler completionHandler) : base(completionHandler) { }
}
Usage:
var detectBarcodesRequest = new FixVNDetectBarcodesRequest((request, error) =>
{
//
});
VNDetectBarcodesRequest binding:[TV (11,0), Mac (10,13, onlyOn64: true), iOS (11,0)]
[Abstract]
[DisableDefaultCtor]
[BaseType (typeof (VNImageBasedRequest))]
interface VNDetectBarcodesRequest {
[Export ("initWithCompletionHandler:")]
[DesignatedInitializer]
IntPtr Constructor ([NullAllowed] VNRequestCompletionHandler completionHandler);
[Static]
[Protected]
[Export ("supportedSymbologies", ArgumentSemantic.Copy)]
NSString [] WeakSupportedSymbologies { get; }
[Static]
[Wrap ("VNBarcodeSymbologyExtensions.GetValues (WeakSupportedSymbologies)")]
VNBarcodeSymbology [] SupportedSymbologies { get; }
[Protected]
[Export ("symbologies", ArgumentSemantic.Copy)]
NSString [] WeakSymbologies { get; set; }
}
re: vision.cs#L156
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With