Flutter Text Detect Area 是一個專為在影像特定區域中精確辨識文字而設計的 Flutter 套件。透過允許使用者拖曳、移動或平移選擇器覆蓋影像,可將選定區域的文字隔離並偵測。適用於需要聚焦 OCR 的應用,例如文件掃描或從影像中提取資料,此套件利用機器學習與電腦視覺技術。該套件支援 Android 與 iOS 平台,使其可在各種行動裝置上使用。它可透過 pub.dev 隨意整合至 Flutter 專案中。
適用情境
文件掃描
基於圖像的數據提取
選擇性文本識別
移動OCR應用
圖像中的即時文字檢測
主要特色
拖曳並平移區域選擇
精確的基於區域的文本檢測
跨平台支援(Android 與 iOS)
與 Flutter 的輕鬆整合
即時OCR處理
適合對象
開發 OCR 功能的開發者
需要選擇性文本提取的應用
具有影像分析的行動應用程式
帶有圖像識別的教育工具
欄位資料採集應用
使用建議
需要相機或圖像輸入
性能取決於設備功能
準確度隨圖像品質而變化
限制在選定區域內的文字
可能需要對低品質圖像進行額外預處理
原始 README
以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。
Flutter Text Detect Area
A Flutter plugin that enables text detection from specific areas of an image or live camera preview. Just drag/select the area you want to scan, and let it extract the text using ML Kit.
Perfect for scanning:
🧾 Receipts image
📄 Documents image
📘 PDFs image
🧠 Custom fields in images
🚀 Features
📸 Supports both live camera and gallery image input
✍️ Manual area selection (drag, resize, pan, freeze)
final pickedFile = awaitImagePicker().pickImage(source: ImageSource.gallery);
✨ Example Usage
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) => SelectImageAreaTextDetect(
detectOnce: true, // Set to false for continuous scan
enableImageInteractions: true,
imagePath: pickedFile?.path ?? '',
onDetectText: (value) {
if (value isString) {
print("Detected: $value");
} elseif (value isList<String>) {
for (int i = 0; i < value.length; i++) {
print("${i + 1}. ${value[i]}");
}
}
},
onDetectError: (error) {
if (error isPlatformException &&
(error.message?.contains("InputImage width and height should be at least 32!") ?? false)) {
ScaffoldMessenger.of(context).showSnackBar(
constSnackBar(content: Text("Selected area must be at least 32x32 pixels.")),
);
}
},
),
),
);
<key>NSCameraUsageDescription</key><string>Need camera access for live scanning</string><key>NSPhotoLibraryUsageDescription</key><string>Need photo access to pick images</string>