使用webforms asp.net显示相机输出

时间:2019-03-18 01:41:00

标签: c# asp.net webforms

一个正在开发的Webform应用程序,可扫描特定时间的QR /条形码,并根据读取的信息执行结果。我正在使用AForge.net和ZXing.net访问摄像机。相机点亮,并继续将BMP帧发送到ZXing库以检测QR码。一切正常,QR码被检测到。

还要求显示从相机读取的视频流,以便用户可以将QR码放在正确的位置。在winforms上,有大量的帮助来帮助您实现这一切,但找不到Webforms的正确方向。 Google搜索主要以Windows窗体和不是 网络窗体的形式显示。

我们非常感谢您的帮助。我知道我不能使用在android / iOS中无法处理的不赞成使用的javascript处理程序(Flash播放器)(如果我错了,请纠正我)。

已附上AForge.net在阅读QR代码时提供的代码段。我需要做的就是创建一个播放器并传递bmp帧。任何对文档或示例代码的建议都将受到高度赞赏。

代码段:

    protected void video_NewFrame(object sender, NewFrameEventArgs eventArgs)
    {
        // get new frame
        Bitmap bitmap = eventArgs.Frame;

        // process the frame
        var barcodeReader = new BarcodeReader();

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

        if (barcodeResult != null && barcodeResult.Text.Length != 0)
        {
            // signal to stop when you no longer need capturing
            videoSource.SignalToStop();
            Response.Redirect("Home.aspx?Id=" + barcodeResult.Text, false);
        }
    }

1 个答案:

答案 0 :(得分:0)

看起来我必须使用从aspx调用的html和javascript,并且ZXing.net库已经支持。无需做任何服务器端的东西。剥离所有不必要的控件后,就可以达到最终结果。感谢您重定向。 :)

https://github.com/zxing-js/library/blob/master/docs/examples/qr-camera/index.html