How to use openTwain

Feb 22, 2010 at 6:41 PM

Hello, I am working on a scanner application and would like to try openTwain.  However I can not find any instructions for use.  I understand what TWAIN requires, OPEN the DSM, Select a source, enable the source, ect.  I couldn't find anything on your site as far as "how to use".  This is critical if you want anyone to be able to use it.

 

I would be able with a link to instructions, or a quick guide.  I would like to be able to step through the code to make it work with the requirements that I have.

thanks

JM

Coordinator
Feb 22, 2010 at 8:00 PM

Instructions/'how to use'/crucial.. you probably have a point.  More documentation is rarely wrong.  this tread won't pretend to be that documentation but it will attempt to explain the intent of the project and how it may or may not be useful to you.

There are two sample projects in the solution using the library.  One is is a command line sample, very basic, mostly to show that scanning can be done in vb.net with the core library without a dialog.  This makes the library useful for situations where a Ui is not appropriate - serviced projects, batch scanning, remote scanning, automatic acquisition by your webcams whatever.  That project is named cmdHarness and the place to start if you're looking for the command line sample is Module1.

The other is a windows forms project that demonstrates more of the intent of the project.  If you have not already read the oldest 3 posts under 'discussions' now is a pretty good time, they aren't long but they cover my ideas of scanning in general and the feelings I have for how it can be done.  The one named 'twain scanning approaches' it covers the intent of the project which is to (for devices that support the capability) to provide consistent Ui-less acquisition.  You take the acquisition in two phases, phase one you define the settings for a 'profile' and save those settings with some name.  Maybe you define several of these profiles so you have one with duplex scanning, another with one one side, and a couple more with different settings.  Phase 2 is where you acquire the images using one of the profiles.  In this sense your users are not constantly changing their settings.  Sadly there are not a whole lot of devices available that support the required capabilities for this, but still this is the main intent.  If you're looking for scanning from a Windows Forms project set guiHarness as your startup project and if you go this route then you'll start maybe with Manager.vb as it handles the main form.

If you're trying to get your our project working, and are not really interested in my sample (you get points for going it on your own) then you may want to check the core library and in that case cTwain.vb is a pretty decent starting place.  If you're looking to see that your datastructures are correctly translated into vb.net then you should probably start with DataStructures.vb

More specifically I recommended you to this project from twainforum.org for a couple of reasons:

so you could see that there exists at least one open source managed project in vb.net using twain, 

so you could check your DllImports against a set that definitely work ( mine are in DllImports.vb )

and so if you had trouble with twain in vb.net you had someone to ask. 

Too bad there isn't more help out there for vb.net twain projects, and too bad I haven't been as active on twainforum.org as I was last year.  Not getting any help from the community can be rough.  Let me know if you have a specific problem and I'll try to set some time aside to help you though it.

 

/gaccettola

 

 

 

 

Feb 23, 2010 at 6:27 PM
Thank you very much!! You have gave me a direction that I needed.
One problem I was having was trying to use Marshal.PtrToStructure to get the OneValue struc. After looking at your code I saw how you get the data by byte and populate your own structure. I also didn't know that it uses a Fix32 struct, that's why when I examined the bytes it didn't look right. So I tried what you were doing and I got a physical width of 8.5!! GREAT!! Thanks again, and I'll post my success (or lack of) on the forum.
JM

[John Maher] -----Original Message-----
From: gaccettola [mailto:notifications@codeplex.com]
Sent: Monday, February 22, 2010 4:01 PM
To: John Maher
Subject: Re: How to use openTwain [openTwain:155382]

From: gaccettola

Instructions/'how to use'/crucial.. you probably have a point. More documentation is rarely wrong. this tread won't pretend to be that documentation but it will attempt to explain the intent of the project and how it may or may not be useful to you.

There are two sample projects in the solution using the library. One is is a command line sample, very basic, mostly to show that scanning can be done in vb.net with the core library without a dialog. This makes the library useful for situations where a Ui is not appropriate - serviced projects, batch scanning, remote scanning, automatic acquisition by your webcams whatever. That project is named cmdHarness and the place to start if you're looking for the command line sample is Module1.

The other is a windows forms project that demonstrates more of the intent of the project. If you have not already read the oldest 3 posts under 'discussions' now is a pretty good time, they aren't long but they cover my ideas of scanning in general and the feelings I have for how it can be done. The one named 'twain scanning approaches' it covers the intent of the project which is to (for devices that support the capability) to provide consistent Ui-less acquisition. You take the acquisition in two phases, phase one you define the settings for a 'profile' and save those settings with some name. Maybe you define several of these profiles so you have one with duplex scanning, another with one one side, and a couple more with different settings. Phase 2 is where you acquire the images using one of the profiles. In this sense your users are not constantly changing their settings. Sadly there are not a whole lot of devices available that support the required capabilities for this, but still this is the main intent. If you're looking for scanning from a Windows Forms project set guiHarness as your startup project and if you go this route then you'll start maybe with Manager.vb as it handles the main form.

If you're trying to get your our project working, and are not really interested in my sample (you get points for going it on your own) then you may want to check the core library and in that case cTwain.vb is a pretty decent starting place. If you're looking to see that your datastructures are correctly translated into vb.net then you should probably start with DataStructures.vb

More specifically I recommended you to this project from twainforum.org for a couple of reasons:

so you could see that there exists at least one open source managed project in vb.net using twain,

so you could check your DllImports against a set that definitely work ( mine are in DllImports.vb )

and so if you had trouble with twain in vb.net you had someone to ask.

Too bad there isn't more help out there for vb.net twain projects, and too bad I haven't been as active on twainforum.org as I was last year. Not getting any help from the community can be rough. Let me know if you have a specific problem and I'll try to set some time aside to help you though it.

/gaccettola

Coordinator
Feb 23, 2010 at 8:14 PM

Good to hear, really.  Two more things come to mind when I re-read my last response.  Check your DataStructures against mine.  Over the last couple years of working with people getting their vb.net projects online there seem to be a two common issues: 1) Their DllImport definitions are 'almost right' but behave oddly due to the 'almost' part 2) Their data structures are off.  

Once you DllImport and DataStructures are correct working with twain is pretty decent when you have a decent device to test with, which brings me to my second through.  Use a virtual device during your initial development.  Nothing beats having a simulated device for reproduction and testing.  If you have an issue and we are using the same virtual scanner I don't have to think that maybe the issue you're seeing is due to a bad driver and believe me bad twain drivers are everywhere.  I spend more than 80% of the time I work with twain on drivers that don't follow the spec.  If you're looking for setting up a virtual scanner search twainforum for 'simulation mode' - I have a couple posts for setting one up and there are a few other threads there with how to use them.

Otherwise, when or if you have questions just ask.  If it concerns the specification in general I would ask on twainforum first, if it concerns how opentwain supports the specification ask here.

.

 

Mar 11, 2010 at 1:29 PM
What's up Gabe?
Your openTwain was very useful, although it didn't run on my system, it taught me how to get/set capabilities. I have code to get/set almost all caps (frame is not supported and thier may be others). If you would like me to send you the code, I will if it will help your openTwain.
Thanks JPM
-----Original Message-----
From: gaccettola [mailto:notifications@codeplex.com]
Sent: Tuesday, February 23, 2010 4:16 PM
To: John Maher
Subject: Re: How to use openTwain [openTwain:155382]

From: gaccettola

Good to hear, really. Two more things come to mind when I re-read my last response. Check your DataStructures against mine. Over the last couple years of working with people getting their vb.net projects online there seem to be a two common issues: 1) Their DllImport definitions are 'almost right' but behave oddly due to the 'almost' part 2) Their data structures are off.

Once you DllImport and DataStructures are correct working with twain is pretty decent when you have a decent device to test with, which brings me to my second through. Use a virtual device during your initial development. Nothing beats having a simulated device for reproduction and testing. If you have an issue and we are using the same virtual scanner I don't have to think that maybe the issue you're seeing is due to a bad driver and believe me bad twain drivers are everywhere. I spend more than 80% of the time I work with twain on drivers that don't follow the spec. If you're looking for setting up a virtual scanner search twainforum for 'simulation mode' - I have a couple posts for setting one up and there are a few other threads there with how to use them.

Otherwise, when or if you have questions just ask. If it concerns the specification in general I would ask on twainforum first, if it concerns how opentwain supports the specification ask here.

.

Coordinator
Mar 11, 2010 at 1:35 PM

Truly happy to hear it could help you in some way.  Code donations are always welcome and if I can work them into the library in a useful way I'd be more than happy to add them.

best regards,

 

 

Mar 18, 2010 at 7:01 PM
Hey Gabe,
Here is a form that can set capabilities. i have also included my clsScan so you can take what you need out of it. Some code my look familiar :). Thanks again for the help and I hope you can use something from my code. If you do can you please let me know. I'll feel good if I can give a little back. If anything is unclear then write me, I'll explain it.
-----Original Message-----
From: gaccettola [mailto:notifications@codeplex.com]
Sent: Thursday, March 11, 2010 9:36 AM
To: John Maher
Subject: Re: How to use openTwain [openTwain:155382]

From: gaccettola

Truly happy to hear it could help you in some way. Code donations are always welcome and if I can work them into the library in a useful way I'd be more than happy to add them.

best regards,