【问题标题】:Barcode using UWP C# windows 8.1使用 UWP C# windows 8.1 的条码
【发布时间】:2018-06-12 23:21:45
【问题描述】:

请问,如何使用我电脑的网络摄像头扫描条形码?我用的是ZXing Nugget,只能生成(写)二维码,不能读。 这些是我的 C# 代码

XAML

    <Page
        x:Class="Bembem_Samples.FrontScan"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:Bembem_Samples"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">

        <Grid Background ="CadetBlue">
            <StackPanel
                HorizontalAlignment="Center"
                VerticalAlignment="Center">
                <Button x:Name="testZxing" Click="testZxing_Click"/>
                <TextBlock
                    FontSize="18"
                    x:Name="txtStatus"/>
                <TextBlock
                    FontSize="18"
                    x:Name="txtResult"
                    Margin="0,4,0,0" />
            </StackPanel>
        </Grid>
    </Page>

C#代码

    using System;
    using System.Collections.Generic;
    using System.IO;
    using System.Linq;
    using System.Runtime.InteropServices.WindowsRuntime;
    using Windows.Foundation;
    using Windows.Foundation.Collections;
    using Windows.Media;
    using Windows.Media.Capture;
    using Windows.Storage;
    using Windows.Storage.Streams;
    using Windows.UI.Popups;
    using Windows.UI.Xaml;
    using Windows.UI.Xaml.Controls;
    using Windows.UI.Xaml.Controls.Primitives;
    using Windows.UI.Xaml.Data;
    using Windows.UI.Xaml.Input;
    using Windows.UI.Xaml.Media;
    using Windows.UI.Xaml.Media.Imaging;
    using Windows.UI.Xaml.Navigation;
    using ZXing;

    // The Blank Page item template is documented at http://go.microsoft.com/fwlink/?LinkId=234238

    namespace tinoTestField
    {
        /// <summary>
        /// An empty page that can be used on its own or navigated to within a Frame.
        /// </summary>
        public sealed partial class CamElement : Page
        {
            public FrontScan()
            {
                this.InitializeComponent();

            }
            private void testZxing_Click(){
                IBarcodeReader reader = new BarcodeReader();
                // load a bitmap - *Bitmap* is not recognised by the library
                var barcodeBitmap = (Bitmap)Image.LoadFrom("C:\\sample-barcode-image.png");
                // detect and decode the barcode inside the bitmap
                var result = reader.Decode(barcodeBitmap);
                // do something with the result
                if (result != null)
                {
                  txtDecoderType.Text = result.BarcodeFormat.ToString();
                  txtDecoderContent.Text = result.Text;
                }
          }
       }
    }

请问,如何使用我电脑的网络摄像头扫描条形码?我用的是ZXing Nugget,只能生成(写)二维码,不能读。

另外,如果有人知道我可以如何解决这个问题或关于如何使用 captureElement 打开网络摄像头的建议。

提前致谢。

【问题讨论】:

  • 您真的希望我们为您编写程序吗?自己做
  • 嗨@musefan,我只是在问路。自己做肯定会让我学得更好。你知道任何资源吗?

标签: c# uwp barcode zxing


【解决方案1】:

所以基本上你这里有一个单一的图像阅读器,如果你想从网络摄像头读取,你必须为此编写一个 lil 代码。

要遵循的步骤

  1. 获取可以流式传输网络摄像头数据的库(如AforgeAforge Example
  2. 从该流中获取图像。
  3. 处理该图像以查找条形码
  4. 重复

注意:这只是一个概述,说明在构建条形码阅读器时需要考虑很多事情。

更新:-

在对此进行研究时,我发现 Github Repo 这不是完整的解决方案,但会在您想要实现的目标上实现一个很好的飞跃

【讨论】:

  • 好的,@Mihir Dave。我将阅读这篇文章并恢复我的发现。谢谢。
  • 嗨@Mihir Dave。需要你的努力。我真的很感激。我的基本问题是在不启动相机的情况下在 UWP(桌面)上查看图像。我读过,但仍然很困惑。我使用了docs.microsoft.com/en-us/uwp/api/…,但它不起作用,我读过的许多其他东西也是如此。创建条形码作品。
  • 所以您在访问网络摄像头时遇到问题? “不启动相机”是什么意思?
  • 通常,我在 PC 上启动相机,将图像捕获为位图并保存(作为 base64 字符串)。我想在点击按钮捕捉之前在应用上查看图像。
  • 所以基本上你需要在你的应用中看到实时网络摄像头流,对吧?
猜你喜欢
  • 2016-07-24
  • 1970-01-01
  • 1970-01-01
  • 2019-10-25
  • 2017-11-04
  • 1970-01-01
  • 2017-11-10
  • 2016-08-19
  • 1970-01-01
相关资源
最近更新 更多