Resource Base
Table of contents

How to automatically deskew an image

Generally, there are two ways to automatically deskew an image with Dynamic .NET TWAIN.

  • Option 1: Use Dynamic .NET TWAIN’s built-in methods. Below are the basic steps:
    • Calculate the skew angle by using GetSkewAngle Method,
        double Angle;
        Angle = m_ImageCore.ImageProcesser.GetSkewAngle(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer);
      
    • Use Rotate method to de-skew the image,
        m_ImageCore.ImageProcesser.Rotate(m_ImageCore.ImageBuffer.CurrentImageIndexInBuffer, -Angle, true, Dynamsoft.Core.Enums.EnumInterpolationMethod.BestQuality);
      

      If you want to do de-skew to each scanned image, you can call the above code in OnPostTransfer Event.

Option 2: Use custom capability of the scanner, which requires the support of the scanner itself.

You can use CapSet functionality and the code is as follows,
```c#
m_TwainManager.Capability = (Dynamsoft.TWAIN.Enums.TWCapability)4433; //AutoDeskew
m_TwainManager.CapType = Dynamsoft.TWAIN.Enums.TWCapType.TWON_ONEVALUE;
m_TwainManager.CapValue = 0;
bool bRet = m_TwainManager.CapSet();
```

If you need any assistance or have any problem, please feel free to contact support@dynamsoft.com.

This page is compatible for:

Version 7.5

Is this page helpful?

YesYes NoNo

In this article:

latest version

    • Latest Version
    © 2003–2021 Dynamsoft. All rights reserved.
    Privacy Statement / Site Map / Home / Purchase / Support