使用IronQR掃描即時視頻流
Curtis Chau
已更新: 2026年6月24日
你想從手機的相機實時讀取QR碼,但IronQR沒有內建的方法來進行即時視頻流掃描。 解決方法是從相機中逐個幀地輸入讀取器。
解決方案
IronQR專注於高精度的靜態QR碼識別。 實時視頻解碼是像OpenCV或平台原生相機SDK的計算機視覺框架的領域。 要想達到即時掃描的效果,自己捕捉幀,並將每個幀解碼為靜止影像。
1. 訪問設備的攝像頭畫面
通過平台原生API打開相機:Xamarin.Essentials、MAUI Camera或者直接使用Android/iOS SDK。
2. 連續獲取幀
每隔一段短間隔(例如每100毫秒)抓取一個幀,並將其轉換為位圖。
3. 將每個幀傳遞給讀取器
將捕獲的位圖包裝在QrImageInput中並交給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
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)' 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)每次調用分析一個靜止的幀。 一個接一個地解碼它們,儘管IronQR只會看到單個圖像,但相機看起來像是在實時掃描。
請注意: 即時影片串流掃描預設不支援。 目前需要在應用層面實現即時掃描。
Curtis Chau 擁有卡爾頓大學計算機科學學士學位,專注於前端開發,擅長於 Node.js、TypeScript、JavaScript 和 React。Curtis 熱衷於創建直觀且美觀的用戶界面,喜歡使用現代框架並打造結構良好、視覺吸引人的手冊。