Contact us


All times are UTC - 8 hours



Post new topic Reply to topic  [ 12 posts ] 
Author Message
Offline Profile  


Joined: Wed May 21, 2014 3:38 am
Posts: 19
Currently my application captures an image from the scanner and the user can drag to select an area and crop the image. Is it possible to auto-detect and crop out the white space automatically to save the user the extra step of selecting this region on the image?


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi Matty,

Unfortunately, Auto Crop feature is not available in our SDK.

Instead of Auto Crop, a better way is to detect the border of the paper. If your scanner itself has the capability of automatic border detection, you can simply usecapability negotiation to turn on the feature:

Alternatively, you can set IfShowUI API to true so you can manually turn on the feature in the scanner interface.

If your scanner doesn’t have the capability, I would suggest that you offer a few common page size options on your scan page. To set page size before scanning, you can use the PageSize API.

Thanks,

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Wed May 21, 2014 3:38 am
Posts: 19
I can't be sure that the user's scanner will support capability negotiation. Is this supported by most scanners and how can I work this out about a certain scanner model? I thought about setting the page size because my users will mostly be scanning a standard size page. The PageSize property only appears to support a single value. What does this represent? Can you specify a specific width and height to be captured from the top left corner of the flatbed glass?


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi Matty,

IfAutoamticBorderDetection may not be supported by most scanners.

But most scanners support basic standard size pages, such as A4, A3 and so on. And yes, the PageSize property only supports a single value. You can offer a few common page size options on your scan page, and for each option, you set a proper PageSize value for it. You can refer to this page.

Matty wrote:
Can you specify a specific width and height to be captured from the top left corner of the flatbed glass?

Yes.
There’s another API called SetImageLayout which is more flexible than PageSize. You can specify page size yourself with its help.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Wed May 21, 2014 3:38 am
Posts: 19
Thanks Vincy,

Using SetImageLayout looks like a good option. I'll give that a try.

Can you please further explain the use of Capability Negotiation to detect the border of the paper. If this is supported by the scanner, what values do I pass for the Capability, CapType and CapValue properties? If border detection is not supported by the scanner, will the use of this method of cropping out whitespace throw an exception or will these properties simply be ignored?


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi Matty,

I'm glad that SetImageLayout works.

And as per the Capability Negotiation, you can refer to this articleto see if your scanner support the border detection. And if it is not supported, there won't be anything about this setting.

To use the automatic border detection capability with Dynamic .NET TWAIN, you can refer to the guide here.

FYI, the capability name is ICAP_AUTOMATICBORDERDETECTION, the CapType is TW_ONEVALUE and the CapValue should be true (1). CapSet method shall return false if the capability negotiation fails. For details, you can refer to the first C# sample in the guide page or refer to the code snippet.

Code:
Twain.OpenSource();
 Twain.Capability = Dynamsoft.DotNet.TWAIN.Enums.TWCapability.ICAP_ UNDEFINEDIMAGESIZE;
 Twain.CapType = Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ONEVALUE;
 Twain.CapValue = 1;
if (Twain.CapSet())
  MessageBox.Show("Successful.");//It works when capability negotiation succeeded.
 else
  MessageBox.Show("Failed.\r\n" + Twain.ErrorString);

 Twain.Capability = Dynamsoft.DotNet.TWAIN.Enums.TWCapability.ICAP_AUTOMATICBORDERDETECTION;
 Twain.CapType = Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ONEVALUE;
 Twain.CapValue = 1;

if (Twain.CapSet())
MessageBox.Show("Successful.");//It works when capability negotiation succeeded.
 else
MessageBox.Show("Failed.\r\n" + Twain.ErrorString); // If border detection is not supported by the scanner, the exception expected to be throw should be defined here or these properties will simply be ignored.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Wed May 21, 2014 3:38 am
Posts: 19
Thanks Vincy,

Is there meant to be a link to a knowledge base article in your most recent post?

With the code example provided, is the following section of code required for querying whether the scanner supports auto border detection or was this part of a broader example demonstrating Capability Negotiation?

Code:
Twain.Capability = Dynamsoft.DotNet.TWAIN.Enums.TWCapability.ICAP_ UNDEFINEDIMAGESIZE;
 Twain.CapType = Dynamsoft.DotNet.TWAIN.Enums.TWCapType.TWON_ONEVALUE;
 Twain.CapValue = 1;
if (Twain.CapSet())
  MessageBox.Show("Successful.");//It works when capability negotiation succeeded.
 else
  MessageBox.Show("Failed.\r\n" + Twain.ErrorString);


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi Matty,

Yes, there is a link to Knowledge base article about how to custom capability in Dynamic .NET TWAIN, you can also refer to this link.

And for the code part, ICAP_ UNDEFINEDIMAGESIZE must be enabled for ICAP_AUTOMATICBORDERDETECTION to work referring to the TWAIN specification, so the settings is part of the Capability Negotiation.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Wed May 21, 2014 3:38 am
Posts: 19
Thanks Vincy. That has been really helpful.

With using the SetImageLayout method as follows:

Code:
Twain1.SetImageLayout(0, 0, 3, 3)


when I capture via the flatbed scanner, it captures 3x3 inches from the top left of the image (the behaviour I would expect) but when I capture via the auto document feeder, it captures 3x3 inches from the middle of the document.


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi Matty,

Could you please try the “Scan with custom layout” demo to see if you can reproduce the issue? I tested it with my scanner and it worked fine.

By the way, I would suggest that you contact our LiveChat for instant help. This way, we can help troubleshoot all the remaining issues quickly.

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Offline Profile  


Joined: Wed May 21, 2014 3:38 am
Posts: 19
Vincy wrote:
Hi Matty,

Could you please try the “Scan with custom layout” demo to see if you can reproduce the issue? I tested it with my scanner and it worked fine.

By the way, I would suggest that you contact our LiveChat for instant help. This way, we can help troubleshoot all the remaining issues quickly.


I can't see a demo in the SDK called “Scan with custom layout”. Can you please post a link to the sample project?


User avatar
Offline Profile  


Joined: Tue Mar 08, 2005 12:23 am
Posts: 1691
Hi Matty,

Have you installed Dynamic .NET TWAIN? If so, the demo is in the sample folder of the installation (such as C:\Program Files (x86)\Dynamsoft\Dynamic .NET TWAIN 5.4.1 Trial\Samples\VB .NET Samples)

_________________
Vincy
Dynamsoft Support Team
Follow us@Twitter, Facebook


Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 12 posts ]  Moderators: Michael, Vincy


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
cron
Copyright © 2016 Dynamsoft | All Rights Reserved
dynamic designed by Dynamsoft team