Home › Forums › TWAIN Classic › Setting TWAIN Custom or Extended Capabilities
- This topic has 9 replies, 6 voices, and was last updated 14 years, 2 months ago by Thierry.
- AuthorPosts
I am building my own TWAIN UI to run against mutliple different vendors scanners.
So instead of popping up the vendors TWAIN UI for a particular scanner, I’ll pop up my own TWAIN UI.
I have been able to get my own TWAIN UI to negotiate most mandatory capabilities properly, so much so that my own UI now accurately represents most of the the features available on the scanner thats currently plugged into my PC.
One area that is not quite working out as I had expected is setting the correct thresholding options.
All scanners support Fixed Thresholding, whereby we can set the manual value of the threshold setting. This is often the default setting within the vendors TWAIN driver.
But many scanners also support addiitonal dynamic threhsolding options when scanning in Black and white to auto enhance the readability of the text on the image.
For example Kodak scanners use ICAP_HALFTONES to allow you to set other types of thresholding like ATP, or Ithresholding. So by setting the appropriate ICAP_HALFTONES value I can switch the scanner from Fixed Thresholding to ATP or Ithresholding instead. So I have been able to easily accomodate these Kodak options into my own TWAIN UI
Canon Scanners support several types of Dynamic Thresholding, but these options do not appear to all be implemented using CAP_HALFTONES (e.g. Error Diffusion is set using ICAP_HALFTONES , whereas are, whereas Advanced Text Enhancement and Advance Text Enhancement II are not set using ICAP_HALFTONES). I am looking for information from Canon that shows how to set the dyanmic thresholding to Advanced Text Enhancement using TWAIN advanced or extended capabilities.
Does anyone know how to do this for Canon Scanners?. At present I can set this by writing direct to the Canon Scanner ini file, but I should not have to do this.
Avision scanners also support several types of Dynamic Thresholding but in their UI they refer to this as binarization. Their options include Fixed proxessing, Dynamic Threshold, Halftone 1, Halftone 2, Halftone 3, Halftone 4, Halftone 5, Diffusion.
They have implemented Halftone 1, Halftone 2, Halftone 3, Halftone 4, Halftone 5, Diffusion using ICAP_HALFTONES, but Fixed proxessing and Dynamic Threshold have been implemented by some other method. At present I can set this by writing direct to the Aviision Scanner inii file, but I should not have to do this.
I have approached Avision for the information as to which specific scanner capabilities I should query/set so I can build the correct list of dynamic thresholding options for their scanners.
Why do Vendors implement features in their TWAIN UI’s and not provide easy advanced TWAIN capability access to them?
If anyone else out there has specific knowledge on this I’d appreciate having a dialog with you.
Thanks Mike
Why do Vendors implement features in their TWAIN UI’s and not provide easy advanced TWAIN capability access to them?
For the same reason they don’t bother to implement many of the capability getters 🙁
I faced the same problem and ended up using twirl to reverse-engineer the UI and “sniff” which CAPS it was using.
I even wrote a small guide for that:
http://fmct.blogspot.com/2009/09/guessing-twain-custom-capabilities.htmlBe aware that sometimes you might still have to write to the .INI/CUSTOMDSDATA settings depending on the scanner. For Fujitsu scanners I found there is no other way for features like their dynamic thresholding solution.
Problem is solved.
I thought I’d say how I’d actually fixed the problem over the weekend.
I figured out a way to get all of the info I need regarding setting custom capabilities, without having to pull teeth getting the info from vendors.
1. Select Twain source
2. Open a TWAIN session
3. Build an array of all SUPPORTED CAPS and their current value (before array)
4. Launch the vendor TWAIN UI
5. Change the capabilities you want to change on the scanner
6. Scan a page to make sure settings stick
7. Open the TWAIN session again
8. Build an array of all SUPPORTED CAPS and their current value with the new settings (after array)
9. Compare the before and after capability arrays
10. The differences will be what we need to set to force the scanner into the mode we wanted to use.
11. Add code to my app that will set those changed custom capabilities just before we start the session.Thanks to those who took the time to respond,escpecially the person who used Twirl to do a similar thing.
The guys at Dosadi have some very useful diagnostic tools on their website don’t they! I’d like to thank them for helping the TWAIN community by having those tools online.
By the way the people who write the TWAIN drivers at Avision and Canon were very helpful in providing some hints on how to get around this. I can’t name them here, but thanks also to them.
Hope others will find this info very useful.
Mike
This is one of the things the sample TWAIN2 application on SourceForge does.
https://sourceforge.net/projects/twain-samples/Jim Watters
Thanks Jim,
I’ll check it outMike
Just wanted to give my latest update on this topic. I ended up building a form in my application that allows me to capture TWAIN capabilities changes and also Ini File settings changes that are invoked after using the Vendor TWAIN UI.
Behind the scenes I just simply take before and after snapshots of the TWAIN CAPS and before and after snapshots for ini file settings. Then I compare before with after and display a list of changes to the operator, who then selects the changes they want to record. These changes are then played back by my app at the appropriate point in the actual scanning process.
Using a combination of these 2 approaches allows me to now set all of the scanner features that the Vendors show in their TWAIN UI, but have implemented using poorly documentated custom capabilities or ini file settings.
Thanks to all those who contributed to this topic.
Regards Mike
Why do Vendors implement features in their TWAIN UI’s and not provide easy advanced TWAIN capability access to them?
asked another way, why don’t more of them support CustomDsData which is built specifically for this purpose. the answer to this is kinda sad. but not as sad as the general state of most twain drivers out there.
.
I sent an email to Fujitsu raising the fact that they are setting dynamic thresholding via the ini file only and not using custom caps.
They initially said they would not fix it, but after pointing out that Kodak and Canon provide TWAIN capabilities or custom caps to do this, they have agreed to address the issue in the next release of their TWAIN driver, where they will add a custom cap to allow you to flick between Fixed Processing, SDTC and Advanced DTC modes.
Mike
@Mike Kirkby wrote:
I sent an email to Fujitsu raising the fact that they are setting dynamic thresholding via the ini file only and not using custom caps.
They initially said they would not fix it, but after pointing out that Kodak and Canon provide TWAIN capabilities or custom caps to do this, they have agreed to address the issue in the next release of their TWAIN driver, where they will add a custom cap to allow you to flick between Fixed Processing, SDTC and Advanced DTC modes.
Mike
I hope you’re right, they never agreed to do anything like that before …
Also if you obtain the ‘FTS’ file specification you’ll be very lucky. I had to reverse engineered it (this way I can set the Advanced DTC’ mode or any GUI option not provided directly as a capability).- AuthorPosts