How to automatically deskew an image?

For Dynamic .NET TWAIN v6.x and lower versions only, for V7.x+ please refer to http://developer.dynamsoft.com/dnt/kb

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

1. The first option is to use Dynamic .NET TWAIN's built-in methods.

        Below are the basic steps:

          float Angle;
          Angle = DynamicDotNetTWAIN.GetSkewAngle(DynamicDotNetTWAIN.CurrentImageIndexInBuffer);
  • Use Rotate method to de-skew the image,
          DynamicDotNetTWAIN.Rotate(DynamicDotNetTWAIN.CurrentImageIndexInBuffer,-Angle, 0); 

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

2. The second option is to 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,

          DynamicDotNetTwain.Capability = (Dynamsoft.DotNet.TWAIN.Enums.TWCapability)4433;  //AutoDeskew
          DynamicDotNetTwain.CapType = Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ONEVALUE;
          DynamicDotNetTwain.CapValue = 0;
          bool bRet = DynamicDotNetTwain.CapSet();


If you need any assistance or have any problem, please feel free to contact us.