【发布时间】: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,我只是在问路。自己做肯定会让我学得更好。你知道任何资源吗?