【问题标题】:iOS Barcode detection with Xamarin / Vision framework使用 Xamarin / Vision 框架进行 iOS 条码检测
【发布时间】:2018-06-08 19:32:43
【问题描述】:

我想使用带有 C#/Xamarin 的 iOS 11 的新 Vision API 来检测条形码。

但是,xamarin 的 VNDetectBarcodesRequest 类是抽象的。其他请求类型,例如 VNDetectRectanglesRequest 不是。框架的这一部分是否未在 Xamarin 中实现,或者我在这里遗漏了什么?

基本上我想调整矩形检测样本(https://developer.xamarin.com/samples/monotouch/ios11/VisionRectangles/)来检测二维码。

非常感谢!

【问题讨论】:

    标签: c# xamarin xamarin.ios


    【解决方案1】:

    更新:此错误已修复,请查看xamarin-macios/issues/3140

    这是 Xamarin 生成的绑定中的一个 错误,因为它已正确绑定 except 用于错误应用的 [Abstract] 属性。

    注意:我创建了一个 Github 问题:xamarin-macios/issues/3140

    由于绑定是正确的,您可以通过创建自己的 VNDetectBarcodesRequest 子类来解决。

    VNDetectBarcodesRequest 解决方法

    public class FixVNDetectBarcodesRequest : VNDetectBarcodesRequest
    {
        public FixVNDetectBarcodesRequest(NSObjectFlag t) : base(t) { }
    
        public FixVNDetectBarcodesRequest(IntPtr handle) : base(handle) { }
    
        public FixVNDetectBarcodesRequest(VNRequestCompletionHandler completionHandler) : base(completionHandler) { }
    }
    

    用法:

    var detectBarcodesRequest = new FixVNDetectBarcodesRequest((request, error) =>
    {
        //
    });
    

    VNDetectBarcodesRequest 绑定不正确:

    [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; }
    }
    

    回复:vision.cs#L156

    【讨论】:

      猜你喜欢
      • 2017-06-30
      • 1970-01-01
      • 2021-10-21
      • 1970-01-01
      • 2021-11-21
      • 2018-01-26
      • 2016-07-20
      • 2020-06-19
      • 2017-11-09
      相关资源
      最近更新 更多