使用网络摄像头进行条形码扫描

时间:2018-10-27 17:29:00

标签: c# zxing

我需要构建使用Windows机器附带的网络摄像头扫描二维条形码的应用程序。我想ZXing库将帮助我从图像中提取条形码。

static void Main(string[] args)
{
    // create a barcode reader instance
    var barcodeReader = new BarcodeReader();

    // create an in memory bitmap
    var barcodeBitmap = (Bitmap)Bitmap.FromFile(@"C:\Users\jeremy\Desktop\qrimage.bmp");

    // decode the barcode from the in memory bitmap
    var barcodeResult = barcodeReader.Decode(barcodeBitmap);

    // output results to console
    Console.WriteLine($"Decoded barcode text: {barcodeResult?.Text}");
    Console.WriteLine($"Barcode format: {barcodeResult?.BarcodeFormat}");
}

但是如何构造整个扫描算法?我是否应该以某种方式从相机中抓取照片并将其传递给ZXing,以检测相机是否聚焦于条形码?

0 个答案:

没有答案
相关问题