首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >为什么在.net毛伊岛显示黑色屏幕?

为什么在.net毛伊岛显示黑色屏幕?
EN

Stack Overflow用户
提问于 2022-10-16 19:13:12
回答 2查看 321关注 0票数 0

我正在尝试使用来自https://github.com/Redth/ZXing.Net.Maui的条形码扫描https://github.com/Redth/ZXing.Net.Maui

我将扫描仪添加到页面中,如下所示:

代码语言:javascript
复制
    <?xml version="1.0" encoding="utf-8" ?>
    <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
                 xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
                 x:Class="myapp.Pages.ControleDesBillets"
                 x:DataType="viewmodel:StandardPageVM"
                 xmlns:viewmodel="clr-namespace:myapp.ViewModels"
                 xmlns:Controls="clr-namespace:myapp.Resources.Controls"             
                 xmlns:zxing="clr-namespace:ZXing.Net.Maui.Controls;assembly=ZXing.Net.MAUI">

        <Grid RowDefinitions="*" ColumnDefinitions="*">
            <zxing:CameraBarcodeReaderView x:Name="cameraBarcodeReaderView" Grid.Column="0" Grid.Row="0" HeightRequest="200" WidthRequest="200"/>
        </Grid>

    </ContentPage>

当应用程序运行时,它会提示进入摄像头,这是允许的,然后它会显示一个黑色的屏幕,没有其他任何东西。

在应用程序的启动过程中,扫描仪被初始化:

代码语言:javascript
复制
    public static MauiApp CreateMauiApp()
    {
        var builder = MauiApp.CreateBuilder();

        builder.UseMauiApp<App>().UseMauiCommunityToolkit();
        builder.UseBarcodeReader();  // << here
        return builder.Build();
    }       

我在用物理设备测试。这是我的输出:

代码语言:javascript
复制
    Loaded assembly: /data/data/com.companyname.myapp/files/.__override__/Xamarin.Google.Guava.ListenableFuture.dll [External]
    [CameraManagerGlobal] Connecting to camera service
    [CameraManagerGlobal] [soar.cts] ignore the status update of camera: 2
    [CameraManagerGlobal] [soar.cts] ignore the status update of camera: 3
    [CameraManagerGlobal] [soar.cts] ignore the status update of camera: 4
    [CameraManagerGlobal] [soar.cts] ignore the status update of camera: 5
    [CameraManagerGlobal] ignore the torch status update of camera: 3
    [CameraManagerGlobal] ignore the torch status update of camera: 4
    [CameraMetadataJV] setAppNameAndSensorId all [com.antutu:0,ssize,12032x9024,0,false]
    [CameraMetadataJV] setAppNameAndSensorId all [com.antutu:1,ssize,5184x3880,0,false]
    [CameraRepository] Added camera: 0
    [Camera2CameraInfo] Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_3
    [CameraRepository] Added camera: 1
    [Camera2CameraInfo] Device Level: INFO_SUPPORTED_HARDWARE_LEVEL_3
    [CameraValidator] Verifying camera lens facing on rain, lensFacingInteger: null
    Thread finished: <Thread Pool> #2
    Thread finished: <Thread Pool> #4
    Le thread 0x2 s'est arrêté avec le code 0 (0x0).
    Le thread 0x4 s'est arrêté avec le code 0 (0x0).
    [CompatibilityChangeReporter] Compat change id reported: 150939131; UID 10378; state: ENABLED

有人知道我做错了什么吗?

谢谢。干杯,

EN

回答 2

Stack Overflow用户

发布于 2022-10-16 19:21:42

这是一个众所周知的问题:https://github.com/Redth/ZXing.Net.Maui/issues/7

无论是XF还是毛伊岛,都一直是垃圾。它要么速度慢,性能差,要么存在随机问题,而且几乎没有好的特性。

还有一个基于BarcodeScanner的MLKit,这与我前面提到的截然相反。

这里的安装步骤:https://github.com/JimmyPun610/BarcodeScanner.Mobile/wiki/3.-Installation-for-Maui

一旦您安装了它并准备好了基本的设置,您所要做的就是如下所示:

代码语言:javascript
复制
 <ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
             xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
             x:Class="SampleApp.Maui.Page1"
             xmlns:gv="clr-namespace:BarcodeScanner.Mobile.Maui;assembly=BarcodeScanner.Mobile.Maui"
             Title="Page1">
   <ContentPage.Content>
     <!--VirbationOnDetected: Indicate the device will vibrate or not when detected barcode, default is True
         TorchOn: Indicate the torch will on or not when the view appear, default is False
         IsScanning : Indicate whether the device will start scanning after it is opened, default is True
         RequestedFPS: Affect Android only, remove it if you want a default value (https://developers.google.com/android/reference/com/google/android/gms/vision/CameraSource.Builder.html#public-camerasource.builder-setrequestedfps-float-fps)
         ScanInterval: Scan interval for iOS, default is 500ms and the minimum is 100ms, please be reminded that double scanning may be occurred if it is too small
         -->
          <gv:CameraView HorizontalOptions="FillAndExpand" VerticalOptions="FillAndExpand" OnDetected="CameraView_OnDetected" Grid.Row="1"
                           TorchOn="False" VibrationOnDetected="False" ScanInterval="50" x:Name="Camera"/>

   </ContentPage.Content>
</ContentPage>

你就完蛋了。希望这能有所帮助!

票数 1
EN

Stack Overflow用户

发布于 2022-10-18 01:47:43

当我按下带有摄像头视图的页面,用NavigationPage包起来,它就会结冰。

代码语言:javascript
复制
await Shell.Current.Navigation.PushModalAsync(new NavigaionPage(new ScannerPage), false);

但是推送页面本身就很好,没有问题。

代码语言:javascript
复制
await Shell.Current.Navigation.PushModalAsync(new ScannerPage(), false);
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74090026

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档