在實際環境中測試
在生產環境中測試無浮水印。
在任何需要的地方都能運作。
C# OCR 函式庫
using IronOcr;
string imageText = new IronTesseract().Read(@"images\image.png").Text;
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
// OCR entire document
ocrInput.LoadPdf("example.pdf", Password: "password");
int[] pages = { 1, 2, 3, 4, 5 };
// Alternatively OCR selected page numbers
ocrInput.LoadPdfPages("example.pdf", pages, Password: "password");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
ocrTesseract.Configuration.ReadBarCodes = true;
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\imageWithBarcode.png");
var ocrResult = ocrTesseract.Read(ocrInput);
foreach (var barcode in ocrResult.Barcodes)
{
Console.WriteLine(barcode.Value);
}
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
ocrTesseract.Language = OcrLanguage.Arabic;
using (var ocrInput = new OcrInput())
{
ocrInput.LoadImage(@"images\arabic.gif");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
}
// Example with a Custom Trained Font Being used:
var ocrTesseractCustomerLang = new IronTesseract();
ocrTesseractCustomerLang.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");
ocrTesseractCustomerLang.AddSecondaryLanguage(OcrLanguage.EnglishBest);
using (var ocrInput = new OcrInput())
{
ocrInput.LoadPdf(@"images\mixed-lang.pdf");
var ocrResult = ocrTesseractCustomerLang.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
}
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
ocrInput.Deskew();
ocrInput.DeNoise();
ocrInput.Despeckle();
ocrInput.EnhanceResolution(225);
ocrInput.Sharpen();
ocrInput.Erode();
ocrInput.Dilate();
ocrInput.Scale(200);
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
// Fast Dictionary
ocrTesseract.Language = OcrLanguage.EnglishFast;
// Turn off unneeded options
ocrTesseract.Configuration.ReadBarCodes = false;
// Assume text is laid out neatly in an orthogonal document
ocrTesseract.Configuration.PageSegmentationMode = TesseractPageSegmentationMode.Auto;
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
// First load all image(s)
ocrInput.LoadImage(@"images\image.png");
// Note: You don't need all of them; most users only need Deskew() and occasionally DeNoise()
ocrInput.WithTitle("My Document");
ocrInput.Binarize();
ocrInput.Contrast();
ocrInput.Deskew();
ocrInput.DeNoise();
ocrInput.Despeckle();
ocrInput.Dilate();
ocrInput.EnhanceResolution(300);
ocrInput.Invert();
ocrInput.Rotate(90);
ocrInput.Scale(150);
ocrInput.Sharpen();
ocrInput.ToGrayScale();
ocrInput.Erode();
// WIZARD - If you are unsure use the debug-wizard to test all combinations:
string codeToRun = OcrInputFilterWizard.Run(@"images\image.png", out double confidence, ocrTesseract);
Console.WriteLine(codeToRun);
// Optional: Export modified images so you can view them.
foreach (var page in ocrInput.GetPages())
{
page.SaveAsImage($"filtered_{page.Index}.bmp");
}
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
using IronSoftware.Drawing;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadImage("blue_and_pink.png");
ocrInput.WithTitle("Recolored");
ocrInput.ReplaceColor(Color.Pink, Color.White, 10);
// Pink detection has 10% tolerance
ocrInput.ReplaceColor(Color.Blue, Color.Black, 5);
// Blue detection has 5% tolerance
// Export the modified image so you can manually inspect it.
foreach (var page in ocrInput.GetPages())
{
page.SaveAsImage($"black_and_white_page_{page.Index}.bmp");
}
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
using IronSoftware.Drawing;
// We can delve deep into OCR results as an object model of
// Pages, Barcodes, Paragraphs, Lines, Words and Characters
// This allows us to explore, export and draw OCR content using other APIs/
var ocrTesseract = new IronTesseract();
ocrTesseract.Configuration.ReadBarCodes = true;
using var ocrInput = new OcrInput();
var pages = new int[] { 1, 2 };
ocrInput.LoadImageFrames("example.tiff", pages);
OcrResult ocrResult = ocrTesseract.Read(ocrInput);
foreach (var page in ocrResult.Pages)
{
// Page object
int PageNumber = page.PageNumber;
string PageText = page.Text;
int PageWordCount = page.WordCount;
// null if we dont set Ocr.Configuration.ReadBarCodes = true;
OcrResult.Barcode[] Barcodes = page.Barcodes;
AnyBitmap PageImage = page.ToBitmap(ocrInput);
double PageWidth = page.Width;
double PageHeight = page.Height;
double PageRotation = page.Rotation; // angular correction in degrees from OcrInput.Deskew()
foreach (var paragraph in page.Paragraphs)
{
// Pages -> Paragraphs
int ParagraphNumber = paragraph.ParagraphNumber;
string ParagraphText = paragraph.Text;
AnyBitmap ParagraphImage = paragraph.ToBitmap(ocrInput);
int ParagraphX_location = paragraph.X;
int ParagraphY_location = paragraph.Y;
int ParagraphWidth = paragraph.Width;
int ParagraphHeight = paragraph.Height;
double ParagraphOcrAccuracy = paragraph.Confidence;
OcrResult.TextFlow paragrapthText_direction = paragraph.TextDirection;
foreach (var line in paragraph.Lines)
{
// Pages -> Paragraphs -> Lines
int LineNumber = line.LineNumber;
string LineText = line.Text;
AnyBitmap LineImage = line.ToBitmap(ocrInput);
int LineX_location = line.X;
int LineY_location = line.Y;
int LineWidth = line.Width;
int LineHeight = line.Height;
double LineOcrAccuracy = line.Confidence;
double LineSkew = line.BaselineAngle;
double LineOffset = line.BaselineOffset;
foreach (var word in line.Words)
{
// Pages -> Paragraphs -> Lines -> Words
int WordNumber = word.WordNumber;
string WordText = word.Text;
AnyBitmap WordImage = word.ToBitmap(ocrInput);
int WordX_location = word.X;
int WordY_location = word.Y;
int WordWidth = word.Width;
int WordHeight = word.Height;
double WordOcrAccuracy = word.Confidence;
foreach (var character in word.Characters)
{
// Pages -> Paragraphs -> Lines -> Words -> Characters
int CharacterNumber = character.CharacterNumber;
string CharacterText = character.Text;
AnyBitmap CharacterImage = character.ToBitmap(ocrInput);
int CharacterX_location = character.X;
int CharacterY_location = character.Y;
int CharacterWidth = character.Width;
int CharacterHeight = character.Height;
double CharacterOcrAccuracy = character.Confidence;
// Output alternative symbols choices and their probability.
// Very useful for spellchecking
OcrResult.Choice[] Choices = character.Choices;
}
}
}
}
}
using IronOcr;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\page1.png");
ocrInput.LoadImage(@"images\page2.bmp");
var page = new int[]{ 2, 3 };
ocrInput.LoadImageFrames(@"images\page3.tiff", page);
ocrInput.Deskew();
var ocrResult = ocrTesseract.Read(ocrInput);
ocrResult.SaveAsSearchablePdf("searchable.pdf");
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
// This is done by default and can be omitted:
// ocrTesseract.Configuration.TesseractVersion = TesseractVersion.Tesseract5;
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
using System;
var ocrTesseract = new IronTesseract()
{
Language = OcrLanguage.EnglishBest,
Configuration = new TesseractConfiguration()
{
ReadBarCodes = false,
RenderHocr = true,
BlackListCharacters = "`ë|^",
PageSegmentationMode = TesseractPageSegmentationMode.AutoOsd,
}
};
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
using IronSoftware.Drawing;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
// A 41% improvement on speed by specifiying a pixel region
var ContentArea = new Rectangle(x: 215, y: 1250, width: 1335, height: 280);
ocrInput.LoadImage("img/example.png", ContentArea);
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadImageFrame("images/multiframe.tiff", 1);
var ocrResult = ocrTesseract.Read(ocrInput);
ocrResult.SaveAsSearchablePdf("searchable.pdf");
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.TargetDPI = 300;
ocrInput.LoadImage(@"images\image.png");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadPdf("scan.pdf");
// Image processing is automatically multi-threaded
ocrInput.Deskew();
// OCR reading is automatically multi-threaded too
var ocrResult = ocrTesseract.Read(ocrInput);
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
ocrTesseract.OcrProgress += (_, ocrProgressEventsArgs) =>
{
Console.WriteLine(ocrProgressEventsArgs.ProgressPercent + "% " + ocrProgressEventsArgs.Duration.TotalSeconds + "s");
};
using var input = new OcrInput();
input.LoadPdf("large.pdf");
// Progress events will fire during the read operation even if the main thread is blocked.
var result = ocrTesseract.Read(input);
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
var pages = new int[] { 1, 2 };
ocrInput.LoadImageFrames("images/multiframe.tiff", pages);
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
using IronOcr;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadPdf("scan.pdf", Password: "password");
// Clean up twisted pages
ocrInput.Deskew();
var ocrResult = ocrTesseract.Read(ocrInput);
ocrResult.SaveAsSearchablePdf("searchable.pdf");
using IronOcr;
using System;
var ocrTesseract = new IronTesseract();
ocrTesseract.UseCustomTesseractLanguageFile("custom_tesseract_files/custom.traineddata");
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
var ocrResult = ocrTesseract.Read(ocrInput);
Console.WriteLine(ocrResult.Text);
//PM> Install-Package IronOcr.Languages.Arabic
//PM> Install-Package IronOcr.Languages.Chinese
using IronOcr;
using System;
var Ocr = new IronTesseract();
// Add a primary language (Default is English)
Ocr.Language = OcrLanguage.English;
// Add as many secondary languages as you like
Ocr.AddSecondaryLanguage(OcrLanguage.Arabic);
Ocr.AddSecondaryLanguage(OcrLanguage.ChineseSimplified);
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
var Result = Ocr.Read(ocrInput);
Console.WriteLine(Result.Text);
using IronOcr;
using IronSoftware.Drawing;
var ocrTesseract = new IronTesseract();
using var ocrInput = new OcrInput();
ocrInput.LoadImage(@"images\image.png");
var ocrResult = ocrTesseract.Read(ocrInput);
foreach (var page in ocrResult.Pages)
{
foreach (var word in page.Words)
{
word.ToBitmap(ocrInput).SaveAs($"page{page.PageNumber}_word{word.WordNumber}.png", AnyBitmap.ImageFormat.Png);
}
}
在當今的數字時代,快速回應 (QR) 使用黑白方塊分享資訊已成為一種不可或缺的工具,這些黑白方塊圖案包含豐富的數據,如網站 URL、產品詳細資訊和聯絡資訊等。目前,使用智慧型手機掃描 QR 碼已經很普遍,而能夠在電腦上做到這一點,則為設備之間的無縫整合開闢了新可能。在這份指南中,我們將探索如何利用電腦資源輕鬆掃描 QR 碼的方法和工具。不論是要訪問網站、取得聯絡資訊或與多樣化的數位內容互動,精通在電腦上掃描 QR 碼的技巧,無疑是駕馭我們互聯世界的寶貴技能。
在本文中,我們將討論如何使用您的網絡攝像頭或筆記型電腦的相機 QR 掃描應用程序掃描 QR 碼。QR 碼閱讀器已成為物理和數位領域之間的橋樑,使用戶能夠通過簡單的掃描即時檢索數據。雖然 QR 碼掃描主要與移動設備相關聯,但技術進步現在已使在電腦上使用網絡攝像頭或其他周邊設備掃描 QR 碼成為可能。此外,如果您希望在 .NET 專案中實現 QR 碼掃描選項,您需要做的只是 IronBarcode 圖書館
大多數現代筆記型電腦和桌上型電腦都內建攝像頭。這些攝像頭可以作為掃描 QR 碼的便利工具,而不需要額外的硬體或軟體。以下是使用具有 QR 碼掃描選項的攝像頭應用程式的方法:
選擇 QR 碼掃描軟體:首先,選擇與您電腦作業系統相容的 QR 碼掃描軟體。不同平台(如 Windows、macOS 和 Linux)都有各種選擇。熱門的選擇之一是"QR Code Scanner"桌面應用程式。
下載和安裝:只需到 Google 上下載您偏好的應用程式,或從官方的 Microsoft 商店獲取。例如,QR Code Scanner 可以在... 微軟商店.
啟動軟體:打開 QR 碼掃描軟體,並授予其訪問您電腦攝像頭的必要權限。
定位 QR Code:將 QR Code 放置在網絡攝像頭的視野內。請確保 QR Code 清晰且光線充足,以獲得最佳掃描效果。
掃描和解讀: 當軟體在相機框架內檢測到QR碼時,它將自動處理其中編碼的數據。這可能會導致各種結果,例如打開特定網站、顯示文字或觸發某個動作。
上傳圖片: 您還可以通過上傳圖片來掃描QR碼。只需點擊“打開 QR 圖片”按鈕,選擇文件上傳圖片,即會打開一個顯示搜尋結果的對話框。
IronBarcode 是一個高度多功能且功能豐富的軟體庫,在簡化各種應用程式中的條碼生成和識別過程中發揮了關鍵作用。憑藉直觀設計的界面和廣泛的功能,IronBarcode 成為開發人員無縫整合強大條碼功能的不可或缺資源。無論是在製作複雜的庫存管理系統、動態銷售點平台,還是任何依賴條碼交互的應用程式中,IronBarcode 都提供了一個卓越的框架,確保輕鬆整合和卓越的效率。
要安裝 IronBarcode 並在您的 .NET 專案中使用,您只需設定 .NET 環境並建立 C# 或 VB.NET 專案。之後,打開 NuGet 套件管理器主控台並執行以下命令:
Install-Package IronOcr
IronBarcode 也可以下載在 官方 NuGet 網站.
現在我們將探索一個使用 IronBarcode 掃描圖像中 QR 碼的代碼範例。使用 IronBarcode 掃描 QR 碼或自動掃描 QR 碼非常簡單。讓我們來看看這個範例。
using IronBarCode;
using System;
var resultFromFile = BarcodeReader.Read(@"QR.png");
Console.WriteLine(resultFromFile);
using IronBarCode;
using System;
var resultFromFile = BarcodeReader.Read(@"QR.png");
Console.WriteLine(resultFromFile);
Imports IronBarCode
Imports System
Private resultFromFile = BarcodeReader.Read("QR.png")
Console.WriteLine(resultFromFile)
在當今互聯的數字環境中,利用電腦資源無縫掃描代碼的能力,提供了物理和數字領域之間的寶貴橋樑。QR碼已經演變成為一種多功能工具,可以即時訪問大量信息。通過內建的網絡攝像頭、本地相機應用程序或瀏覽器內的第三方應用程序,這種能力也拓展到電腦上。從軟件選擇到網絡攝像頭的使用,通過遵循簡單的步驟,使用者可以輕鬆地解讀外部QR碼,打開通向網站、聯繫信息等的路徑。
此外,如 IronBarcode 提升這種體驗,為開發人員提供強大的工具,將條碼功能整合到各種應用中。採用基於計算機的 QR 碼生成和閱讀實踐,掃描在簡化信息交換方面顯得不可或缺。
要了解更多有關如何在 Windows 計算機上閱讀 QR 碼並從 PDF 文件中提取整個 QR 碼的信息,您可以在以下網址找到完整的教程 IronBarcode 網站。
PM > Install-Package IronOcr
30天試用序號 立即。
15天試用金鑰 立即。
想將 IronOCR 部署到現實專案中免費使用嗎?
您的試用金鑰應該在郵件中。試用表格已提交
成功地.
如果不是,請聯繫
support@ironsoftware.com
想將 IronOCR 部署到現實專案中免費使用嗎?
您的試用金鑰應該在郵件中。試用表格已提交
成功地.
如果不是,請聯繫
support@ironsoftware.com
想將 IronOCR 部署到現實專案中免費使用嗎?
您的試用金鑰應該在郵件中。試用表格已提交
成功地.
如果不是,請聯繫
support@ironsoftware.com
想將 IronOCR 部署到現實專案中免費使用嗎?
您的試用金鑰應該在郵件中。試用表格已提交
成功地.
如果不是,請聯繫
support@ironsoftware.com
免費開始
不需要信用卡
在生產環境中測試無浮水印。
在任何需要的地方都能運作。
獲得30天完全功能的產品。
幾分鐘內即可啟動並運行。
試用產品期間完全訪問我們的支援工程團隊
免費開始
不需要信用卡
在生產環境中測試無浮水印。
在任何需要的地方都能運作。
獲得30天完全功能的產品。
幾分鐘內即可啟動並運行。
試用產品期間完全訪問我們的支援工程團隊