Dynamic Web TWAIN: page scanning process how to automatically detect and delete blank pages?

In "Separate Scan document method (1) - Dynamic Web TWAIN: How to use a blank page as a separator of the scanned document," we mentioned can use a blank page as a separator document. However, sometimes the scene is often required not only document separation features include automatic detection and blank page deletion function. This article will briefly introduce how to use Dynamic Web TWAIN achieve a blank page in the process of web documents scanned automatically detect deletion function.

method one

If the TWAIN driver for the device supports discard blank pages, you can use the built-in functionality of the driver.

  1. You can IfShowUI property is set to true user interface (UI) display source, you can check the options out there (it is usually displayed as a 'discard blank').
  2. If you do not want the user interface to display source can be IfAutoDiscardBlankpages set to true or negotiation ICAP_AUTODISCARDBLANKPAGES function in your code to automatically discard blank pages. Please note that this property or function only when the scanner itself supports this feature (at the hardware level) to be effective. The following code snippet,
DWObject.SelectSource();
DWObject.OpenSource;
DWObject.IfShowUI = false;
//*Use the property
DWObject.IfAutoDiscardBlankpages = true;
//*Use capability negotiation
DWObject.Capability = EnumDWT_Cap.ICAP_AUTODISCARDBLANKPAGES;
DWObject.CapType = EnumDWT_CapType.TWON_ONEVALUE;
DWObject.CapValue = -1;//Auto
if(DWObject.CapSet){
   alert("Successful!");
}
DWObject.AcquireImage();

Method Two

Use a method to quickly achieve the desired functionality, but it also has a fatal flaw, and that is dependent on hardware support. In fact, not all of the scanning device has a function to automatically detect blank pages. If the device does not support, how to do it? At this point, there is a common method (software level) is to use Dynamic Web TWAIN SDK's IsBlankImageExpress interface. To automatically detect and discard blank pages, you can after each transmission triggered OnPostTransfer do this event. The following code snippet,

function DWObject_OnPostTransfer() {
DWObject.BlankImageMaxStdDev = 20;
if (DWObject.IsBlankImageExpress(DWObject.CurrentImageIndexInBuffer)) {
   DWObject.RemoveImage(DWObject.CurrentImageIndexInBuffer);
   }
}

Note: In many cases, a blank image scans may cause some noise that can affect the results IsBlankImageExpress returned. To improve results, you can adjust BlankImageMaxStdDev value of the property. The default value is 1 (0 represents a monochrome image). Accordingly, by slightly increasing the value (e.g., to 20), image noise will be ignored, the blank image can be detected quickly.

Released six original articles · won praise 0 · Views 1380

Guess you like

Origin blog.csdn.net/weixin_44795817/article/details/89925983