使用IronQR扫描直播视频流

This article was translated from English: Does it need improvement?
Translated
View the article in English

您希望从手机的摄像头实时读取二维码,但IronQR没有内置方法用于实时视频流扫描。 解决方法是从摄像头逐个读取单独的帧。

解决方案

IronQR专注于高精度静态二维码识别。 实时视频解码是类似OpenCV框架或平台原生摄像头SDK的领域。 要达到实时扫描的效果,需自己捕获帧,并将每个帧解码为静态图像。

1. 访问设备的摄像头画面

通过平台原生API打开摄像头:Xamarin.Essentials、MAUI Camera或直接使用Android/iOS SDK。

2. 连续抓取框架

以短间隔抓取帧,例如每100毫秒,并将其转换为位图。

3. 将每个框架传递给读取器

将捕获的位图包装在QrReader.Read()

// Load the asset into QrImageInput
QrImageInput imageInput = new QrImageInput(capturedBitmap);
// Create a QR Reader object
QrReader reader = new QrReader();
// Read the Input an get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);
// Load the asset into QrImageInput
QrImageInput imageInput = new QrImageInput(capturedBitmap);
// Create a QR Reader object
QrReader reader = new QrReader();
// Read the Input an get all embedded QR Codes
IEnumerable<QrResult> results = reader.Read(imageInput);
' Load the asset into QrImageInput
Dim imageInput As New QrImageInput(capturedBitmap)
' Create a QR Reader object
Dim reader As New QrReader()
' Read the Input and get all embedded QR Codes
Dim results As IEnumerable(Of QrResult) = reader.Read(imageInput)
$vbLabelText   $csharpLabel

每次调用分析一个静态帧。 连续解码它们并且摄像头似乎实时扫描,尽管IronQR只看到单个图像。

请注意箱式视频流扫描默认不支持。 实时扫描目前必须在应用程序层面实现。

Curtis Chau
技术作家

Curtis Chau 拥有卡尔顿大学的计算机科学学士学位,专注于前端开发,精通 Node.js、TypeScript、JavaScript 和 React。他热衷于打造直观且美观的用户界面,喜欢使用现代框架并创建结构良好、视觉吸引力强的手册。

除了开发之外,Curtis 对物联网 (IoT) 有浓厚的兴趣,探索将硬件和软件集成的新方法。在空闲时间,他喜欢玩游戏和构建 Discord 机器人,将他对技术的热爱与创造力相结合。

准备开始了吗?
Nuget 下载 70,398 | 版本: 2026.7 刚刚发布
Still Scrolling Icon

还在滚动吗?

想快速获得证据? PM > Install-Package IronQR
运行示例 观看您的 URL 变成 QR 代码。