• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Ron McLeod
  • paul wheaton
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
  • Himai Minh
Bartenders:

Open-source TWAIN library

 
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to build a Java app that can use any document scanner, whether it is connected to the same network as the computer or to the computer itself.

I can't find an open-source library that I can use. I guess if I can find native applications, I can build my own library.
 
Montana Burr
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So there's this thing called SANE, which provides a way for applications to interact with TWAIN drivers. If the user's computer has the right SANE backend, my app should be able to communicate with any scanner driver.
 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Montana Burr wrote:I want to build a Java app that can use any document scanner, whether it is connected to the same network as the computer or to the computer itself.


Well, from what I understand, TWAIN is a Windows standard, and this article suggests that there are ways of doing it; but it is nearly 10 years old. This one, which is quite a bit newer, suggests that JTwain or Morena might do what you want, but my thought is: why do you need to do this in Java?

There might well be a good reason, but scanners generally work pretty automatically, so why not just use Java to process the resulting file?

Winston
 
Montana Burr
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:

Montana Burr wrote:I want to build a Java app that can use any document scanner, whether it is connected to the same network as the computer or to the computer itself.


Well, from what I understand, TWAIN is a Windows standard, and this article suggests that there are ways of doing it; but it is nearly 10 years old. This one, which is quite a bit newer, suggests that JTwain or Morena might do what you want, but my thought is: why do you need to do this in Java?

There might well be a good reason, but scanners generally work pretty automatically, so why not just use Java to process the resulting file?

Winston



Good question.


The Java app is to make it easier for someone who has an account on FamilySearch.org to scan a photo and upload it to the FamilySearch system. I want the app to know where the scanned image is without asking the user. Ideally, the user would tell the scanner to save the image to a location that is accessible to the computer, and the app would assume that the user wants to upload that image to FamilySearch. The app would allow the user to edit the image before the app uploads it. The app should allow the user to use his or her favorite image editing program, then, after the user saves the file, ask him or her if he or she is ready to upload it.

For the last part, I'm thinking of creating a loop in which the app checks the "Last Modified" date once per second. If it changes, that means the user will have edited the image.

I came up with the idea for the app when I learned that the scanner at my local family history center can scan a photo and upload it to FamilySearch. It would be nice if similar functionality was offered at home.

Edit: Since some users have a program that is invoked whenever the user tells the scanner to scan the image to their computers (such as HP Scan, for HP scanners), perhaps the best course of action would be to first check if the user has such software for the scanner he or she wants to use
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Montana Burr wrote:The Java app is to make it easier for someone who has an account on FamilySearch.org to scan a photo and upload it to the FamilySearch system. I want the app to know where the scanned image is without asking the user. Ideally, the user would tell the scanner to save the image to a location that is accessible to the computer, and the app would assume that the user wants to upload that image to FamilySearch. The app would allow the user to edit the image before the app uploads it. The app should allow the user to use his or her favorite image editing program, then, after the user saves the file, ask him or her if he or she is ready to upload it.


OK, well it sounds to me like you have at least 3 different things going on here - Scanning, Editing, and Uploading - all three of which can probably be done by existing utilities. The last one could certainly be done directly with Java, the first two probably not (or at least not easily); so all your Java app is really doing is "tying them together".

So my first piece of advice would be to deal with them (at least initially) as 3 completely separate problems, and your post was about TWAIN libraries, so I'd stick with that part to kick off with. Get the document from the scanner to some file at a predetermined place in the system. You can then deal with Steps 2 and 3 later on.

I'm no expert on this but, given Java's cross-platform nature, I'd suspect that any "scanning library" you find written in Java is likely to be a compromise that does things in generic or "default" ways, and may well not support all the things that your scanner can actually do. I suspect also that the learning curve for such a library is pretty steep.

It also strikes me that an awful lot of this can probably be configured into your existing scanner software. Yes, it means a bit more set-up for the client, but it would probably only need to be done once, after which you could then just write/use your Java app as a launcher.

For the last part, I'm thinking of creating a loop in which the app checks the "Last Modified" date once per second. If it changes, that means the user will have edited the image.


Sounds overly complex to me. First (and it's purely a personal preference): I dislike passive "checkers" - ie, modules that simply sit and "buzz" until something happens. It seems far more sensible to me to have modules (or Java objects) notify each other when something has happened.

In your case - and sticking purely to the "scanning" part of your problem - I'd probably do something like this:
1. Configure your scanner software to save its images to a specific directory; and if you can configure a specific "Scan for Upload" button to do this, all the better. I have a cheap Canon one, and it allows me to do just that. Alternatively, configure your Java launcher to use the scanner software's own directory.
You might also want to force the scanner to always store documents as images (eg, jpegs) initially, so that your app doesn't have to deal with multiple formats. If left to its own devices, my scanner will choose what it thinks is the best file type for the task (PDFs for text or jpegs for images).
2. Configure your Java launcher to "know" where the scanner software is. Personally, I'd just use a properties file that it reads.
3. Write a Java program that simply launches the scanner software, and checks whether anything has been added to the target directory when it returns.

I suspect that while you're trying this out and getting it to work, other things may occur to you as to how to "streamline" the process, but for now stick purely to this part of the problem. Make sure that you can launch your scanner software and know what file (or files) it created when it returns. Every time.

HIH

Winston
 
Montana Burr
Greenhorn
Posts: 22
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Winston Gutkowski wrote:

Montana Burr wrote:The Java app is to make it easier for someone who has an account on FamilySearch.org to scan a photo and upload it to the FamilySearch system. I want the app to know where the scanned image is without asking the user. Ideally, the user would tell the scanner to save the image to a location that is accessible to the computer, and the app would assume that the user wants to upload that image to FamilySearch. The app would allow the user to edit the image before the app uploads it. The app should allow the user to use his or her favorite image editing program, then, after the user saves the file, ask him or her if he or she is ready to upload it.


OK, well it sounds to me like you have at least 3 different things going on here - Scanning, Editing, and Uploading - all three of which can probably be done by existing utilities. The last one could certainly be done directly with Java, the first two probably not (or at least not easily); so all your Java app is really doing is "tying them together".

So my first piece of advice would be to deal with them (at least initially) as 3 completely separate problems, and your post was about TWAIN libraries, so I'd stick with that part to kick off with. Get the document from the scanner to some file at a predetermined place in the system. You can then deal with Steps 2 and 3 later on.

I'm no expert on this but, given Java's cross-platform nature, I'd suspect that any "scanning library" you find written in Java is likely to be a compromise that does things in generic or "default" ways, and may well not support all the things that your scanner can actually do. I suspect also that the learning curve for such a library is pretty steep.

It also strikes me that an awful lot of this can probably be configured into your existing scanner software. Yes, it means a bit more set-up for the client, but it would probably only need to be done once, after which you could then just write/use your Java app as a launcher.

For the last part, I'm thinking of creating a loop in which the app checks the "Last Modified" date once per second. If it changes, that means the user will have edited the image.


Sounds overly complex to me. First (and it's purely a personal preference): I dislike passive "checkers" - ie, modules that simply sit and "buzz" until something happens. It seems far more sensible to me to have modules (or Java objects) notify each other when something has happened.

In your case - and sticking purely to the "scanning" part of your problem - I'd probably do something like this:
1. Configure your scanner software to save its images to a specific directory; and if you can configure a specific "Scan for Upload" button to do this, all the better. I have a cheap Canon one, and it allows me to do just that. Alternatively, configure your Java launcher to use the scanner software's own directory.
You might also want to force the scanner to always store documents as images (eg, jpegs) initially, so that your app doesn't have to deal with multiple formats. If left to its own devices, my scanner will choose what it thinks is the best file type for the task (PDFs for text or jpegs for images).
2. Configure your Java launcher to "know" where the scanner software is. Personally, I'd just use a properties file that it reads.
3. Write a Java program that simply launches the scanner software, and checks whether anything has been added to the target directory when it returns.

I suspect that while you're trying this out and getting it to work, other things may occur to you as to how to "streamline" the process, but for now stick purely to this part of the problem. Make sure that you can launch your scanner software and know what file (or files) it created when it returns. Every time.

HIH

Winston



1) I don't really care how the first two problems are solved, as long as the Java app somehow knows that the user imported a picture and probably intends to upload that picture to FamilySearch. Maybe the app should see if a piece of software that is used for editing is supposed to load by default. If no such software is launched, or can otherwise be easily configured to be launched, after a scan, then the app will ask the user what editing software he or she wants to use.

2) I would like to eliminate as much work on the user's end as possible.

3) There is some sort of a file-system-watching API that might do the trick. If possible, the VM will tell the computer that it wants to be notified when something changes. If the computer won't send that notification, the VM will resort to repeatedly checking.

4) Ideally, the app would not rely on the presence of any scanning software that the scanner uses to scan anything to the computer. In my case, I can't tell the scanner to scan to my computer because somebody decided not to make my scanner's software compatible with OS X 10.9.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Montana Burr wrote:1) I don't really care how the first two problems are solved...


Then why is your question directed at them? If you really aren't interested in them, then concentrate on uploading the file - and there are plenty of ways to do that, even in Java.

2) I would like to eliminate as much work on the user's end as possible.


A laudable ambition, but probably unworkable in practise. The set-up will have to link the jar you're installing with the scanning and editing software that's installed on the machine unless, as I say, you want custom Java versions of both those things, which has other issues - not the least of which is that they will probably take you months to write.

3) There is some sort of a file-system-watching API that might do the trick.


There certainly is, especially since (I think) version 6; however, as I said above, I'm not at all sure that you need one. All this "VM telling the computer" stuff is likely to simply be 'noise code'.

4) Ideally, the app would not rely on the presence of any scanning software that the scanner uses to scan anything to the computer. In my case, I can't tell the scanner to scan to my computer because somebody decided not to make my scanner's software compatible with OS X 10.9.


So you want to write a complicated custom Java module that probably won't have the same capability as the scanner's own just to deal with the fact that someone hasn't installed their scanner properly? In your case: is this a network scanner? Because it seems amazing to me that you could even buy a scanner that doesn't come with ready-made (or downloadable) software for the Mac.

One possibility that might be worth thinking about is to make these modules as simple as possible (ie, just launchers to existing software) and put the smarts in your set-up (which could almost certainly be written in Java) so that the configuration process is as simple for the user as possible. I believe there are some very good libraries around for writing installation procedures, but my knowledge is probably out-of-date.

Winston
 
reply
    Bookmark Topic Watch Topic
  • New Topic