Skip to content

Mirrored text used for recognition after upgrading OpenCvSharp to latest version Windows #177

@kobruleht

Description

@kobruleht

Describe the bug

After upgrading OpenCvSharp to latest version, text recognition is poor in windows. Returned postions do not correspond to image, it looks like image is mirrored before OCR.

Steps to reproduce the bug

Program.cs:

    builder.Services.AddSingleton(s => {
      RecognizationModel model_rec = RecognizationModel.FromDirectoryV5("latin_PP-OCRv5_mobile_rec_infer");
      ClassificationModel model_cls = ClassificationModel.FromDirectory("PP-LCNet_x1_0_textline_ori_infer",ModelVersion.V5);
      DetectionModel model_det = DetectionModel.FromDirectory("PP-OCRv5_server_det",ModelVersion.V5);
      FullOcrModel model = new(model_det,model_cls,model_rec);
      return new QueuedPaddleOcrAll(() => new PaddleOcrAll(model,PaddleDevice.Mkldnn()) {
        Enable180Classification = true,
        AllowRotateDetection = true,
      },consumerCount: 1);
    }
);

Controller:

public sealed class OcrLines(QueuedPaddleOcrAll ocr) {

async Task RunAsync(byte[] image) {
  using Mat imgSrc = Mat.FromImageData(image);
  var result = await ocr.Run(imgSrc);
}

}

Use latest OpenCvSharp nuget package version 4.13.0.20260213 in Windowsi.

Attached image contains text

EESTI PAKENDIRINGLUS OÜ

It is recognized as

EEATKEIDIBIICAO AE

It looks like text is tried to recognized from mirrored image.

Image

Expected behavior

Text should recognized as

EESTI PAKENDIRINGLUS OÜ

If previous OpenCvSharp version 4.11.0.20250507 is used, OCR works properly.

Screenshots

No response

Release version

	<PackageReference Include="Sdcb.PaddleInference" Version="3.0.1" />
	<PackageReference Include="Sdcb.PaddleInference.runtime.linux-x64" Version="3.1.0.54" />
	<PackageReference Include="Sdcb.PaddleInference.runtime.win64.mkl" Version="3.1.0.54" />
	<PackageReference Include="Sdcb.PaddleOCR" Version="3.0.1" />
	<PackageReference Include="Sdcb.PaddleOCR.Models.LocalV5" Version="3.0.0" />

IDE

Microsoft Visual Studio Community
January 2026 Feature Update
Version: 18.2.2

OS version

Windows 11

Additional context

In Debian Linux where OpenCv is complied from source, using latest OpenCvSharp recognizes text properly.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions