IRONSOFTWAREHOME
閱讀圖片
using IronOcr;
using IronSoftware.Drawing;
using System;

// Instantiate OCR engine
var ocr = new IronTesseract();

using var inputPhoto = new OcrInput();
inputPhoto.LoadImageFrame("ocr.tiff", 0);

// Read photo
OcrPhotoResult result = ocr.ReadPhoto(inputPhoto);

// Index number refer to region order in the page
int number = result.TextRegions[0].PageNumber;

// Extract the text in the first region
string textinregion = result.TextRegions[0].TextInRegion;

//Extract the co-ordinates of the first text region
Rectangle region = result.TextRegions[0].Region;

var output = $"Text in First Region: {textinregion}\n"
             + $"Text Region:\n"
             + $"Starting X: {region.X}\n"
             + $"Starting Y: {region.Y}\n"
             + $"Region Width: {region.Width}\n"
             + $"Region Height: {region.Height}\n"
             + $"Result Confidence: {result.Confidence}\n\n"
             + $"Full Scnned Photo Text: {result.Text}";

Console.WriteLine(output);
Imports IronOcr
Imports IronSoftware.Drawing
Imports System

' Instantiate OCR engine
Dim ocr As New IronTesseract()

Using inputPhoto As New OcrInput()
    inputPhoto.LoadImageFrame("ocr.tiff", 0)

    ' Read photo
    Dim result As OcrPhotoResult = ocr.ReadPhoto(inputPhoto)

    ' Index number refer to region order in the page
    Dim number As Integer = result.TextRegions(0).PageNumber

    ' Extract the text in the first region
    Dim textinregion As String = result.TextRegions(0).TextInRegion

    'Extract the co-ordinates of the first text region
    Dim region As Rectangle = result.TextRegions(0).Region

    Dim output As String = $"Text in First Region: {textinregion}" & vbCrLf &
                           $"Text Region:" & vbCrLf &
                           $"Starting X: {region.X}" & vbCrLf &
                           $"Starting Y: {region.Y}" & vbCrLf &
                           $"Region Width: {region.Width}" & vbCrLf &
                           $"Region Height: {region.Height}" & vbCrLf &
                           $"Result Confidence: {result.Confidence}" & vbCrLf & vbCrLf &
                           $"Full Scnned Photo Text: {result.Text}"

    Console.WriteLine(output)
End Using
NuGet Download
PM > Install-Package IronOcr
閱讀圖片

閱讀圖片

在GitHub上查看

準備開始了嗎?

Nuget Downloads 6,236,385版本:2026.9剛剛發布

Key in blue circle

立即免費取得 30 天試用金鑰

Your trial license will be sent to your email address

無任何限制。100% 解鎖。無需信用卡。

bullet_checked無需信用卡或建立帳號無任何限制。100% 解鎖。無需信用卡。
  • Logo Aetna
  • Logo NASA
  • Logo GE
  • Logo Porsche
  • Logo USDA
  • Logo Qatar
Join Millions of Engineers who’ve tried IronPDF
獲取您的無義務諮詢
填寫以下表格或發送電子郵件至sales@ironsoftware.com
您的詳細資訊將始終保密。
被全球數百萬工程師信任
Iron Software的客戶標誌
立即獲取您的30天試用金鑰
無需信用卡或帳戶建立