Scanning with java
Hi there,
I am collecting some advice and suggestions for using java with scanner. I was previously using a scanning program to handle survey results.... but there are HEAPS of trouble of that program(and I paid for that program). I am thinking of writing a simple java program to "collect data from scanner - as long as it is accurate". I was thinking if the survey, which was designed by me, has a rigid format, then it will be a matter of finding the exact geometrical coordinate of each answer and make the program that can recongise the output from the scanner and hence collect the result of each question.... I am not sure how possible, and feasible, and difficult to write a Java program to handle data collection from a scanner. Furthermore, I am worry that if this program is distributed, will there be LOTS of trouble? With regard to data collection, that come from different model of scanner and various condition of the survey, such as there are many cross-out or twink-out or even the data was not collect properly...
Any suggestions or advice would be VERY MUCH appericate. Thank you.
Sam
Java isn't so good at this type of stuff... although u can get some twain APIs. It sounds like a lot of bother with Java to be honest. I guess next time you could do a browser-based survey?
>I am thinking of writing a simple java
> program to "collect data from scanner - as long as it
> is accurate".
Actually, it would not matter what language you use, "simple" is a gross understatement...
>I was thinking if the survey, which was
> designed by me, has a rigid format, then it will be a
> matter of finding the exact geometrical coordinate of
> each answer and make the program that can recongise
> the output from the scanner and hence collect the
> result of each question....
Well this is the heart of your question, break it down and you will better be able to define the problem...
Something like...
1.write code that will create a GUI
2. write code that gets an image from a scanner
3. write code that can read image
(this will be the hard part... so you would want to research designing and programming pattern recognition software.)
3(A) write code that can recognize patterns in the scanned image
3(B)write code that will tranform patterns in to text data
4. write code that will take all this text and create a formated document
5.write code that will print and save the document.
6.Since I am writing code, also save statistical data from said generated document and generate a report
7. what ever else you can think of...
>I am not sure how
> possible, and feasible, and difficult to write a Java
> program to handle data collection from a scanner.
Once you get a better is idea about the problem is, you can then figure out what tools you will need...
and with scanning, nothing is accurate so you will have to account for that...
Good luck...
- MaxxDmg...
-' He who never sleeps...'
Hi,
it realy seems a quite complex problem.
One part of it - getting the image from the scanner within the java application - can be solved using the Morena Image Acquisition Framework from http://www.gnome.sk
To get a particular area of the sheet is quite easy with Morena (you just use the setFrame method of the TwainSource class), but you still have to use an OCR for recognition of the text. However, for this you can be inspired by the advises of our customer at http://www.gnome.sk/Twain/free_applications/free.html.
There, you can see his approach:
A one-button reading system - how to combine a twain scanner, twain software, an ocr reader and a speech synthesizer to create a one-button reading system.
Erika
> Hi there,
>
> I am collecting some advice and suggestions for using
> java with scanner. I was previously using a scanning
> program to handle survey results.... but there are
> HEAPS of trouble of that program(and I paid for that
You need JTwain, which is available at http://asprise.com/product/jtwain.
JTwain supports all kinds of digital cameras and scanners.
You can use Java to access, contorl digital cameras and scanners, and of course,
to acquire images with flexible settings.
The developers' guide is available @ http://asprise.com/product/jtwain/devGuide.php
Here is the sample code:
try {
// the SourceManager manages and controls all the data(image) sources, eg. scanners, digital cameras,
Source source = SourceManager.instance().getDefaultSource();
source.open();
// Enables or disables the UI
source.setUIEnabled(false);
Image image = source.acuqireImage();
... // Uses image here ...
// Saves the image into a file
source.saveLastAcquiredImageIntoFile("test.jpg");
}catch(Exception e) {
e.printStackTrace();
}finally{
SourceManager.closeSourceManager();
}
Good luck!
Hi,can you send me da JTwain software please.
Wait, before you go off trying to learn how to use this scanner api, let me ask you:
1) How important is it that you control the scanner via the program?
I ask because our group ran into a similar problem. We had output from an analog strip chart (don't ask) and we needed to analyze it. I stuck the paper chart into my scanner and edited the chart with a photoediting program I had (Photoshop). When you do a scan, you get a lot of artifacts: the bumps on the paper, smudges on the scanner window, etc. With Photoshop, I increased the contrast (while visually checking that no data was lost) and I erased marks that the researcher had made (like "This is the peak here", circled). Then I saved the resulting picture as a bmp. (NOT a jpeg)
Then I wrote a program that would read all of the pixels, and, when any pixel value was darker than a minimum, I put that point into an array of data. Usually there were several pixels per datapoint, so I used error bars to indicate all of the pixels that were at that x axis position. This program was very simple. I hacked it in a couple of hours. (*blush* it isn't good code.. I was in a hurry)
Even if you got these scanner APIs, you'd still have to analyze the picture, right? So you'd have to write something similar anyway.
2) What sort of survey is it? Is it a yes or no (mark or no mark) in specific locations? Or is it character recognition?
There are numerous good programs out there that scan surveys specifically. If your program needs to recognize text, I would think that it would be much less painful to get a commercial program. If it's a darken the circle sort of deal, what about scantron?
If you design your own program that does *everything* you want, you'd have to
1) connect to the scanner, get images from the scanner, allow for scanner errors
2) do image transformations to get rid of scanner artifacts that might affect your result, e.g. Fourier transform, low pass filter, maybe. (This step requires some math.)
3) do a recognition sweep that looks for certain patterns (hard) or for mark/no mark at specific locations (easy)
As to your question of "hanging chads" (haha) by which I mean ambiguous results, I think it wouldn't be too difficult to program something that determined if there was more than one mark (inappropriately); it would be best to list these for the operator to view.
If a user other than yourself needs to use your program, you will need to make an appropriate, clear, easy-to-use, visually-pleasing GUI for each of the three above steps. Otherwise people will not use your program, no matter how well it computes the scanning algorithms. This is not a trivial thing to do, but it is doable (time is the issue, though)
You might consider asking the open source community (sourceforge, eg.) to do it for you. Then everyone could benefit from the solution.
:) jen
Dammit, nevermind. I didn't see that this was a resurrected thread.:p
> Dammit, nevermind. I didn't see that this was a resurrected thread.No worries, it's nearly Easter, the season of resurrections :-)
> Hi there,
>
> I am collecting some advice and suggestions for using
> java with scanner. I was previously using a scanning
> program to handle survey results.... but there are
> HEAPS of trouble of that program(and I paid for that
> program). I am thinking of writing a simple java
> program to "collect data from scanner - as long as it
> is accurate". I was thinking if the survey, which was
> designed by me, has a rigid format, then it will be a
> matter of finding the exact geometrical coordinate of
> each answer and make the program that can recongise
> the output from the scanner and hence collect the
> result of each question.... I am not sure how
> possible, and feasible, and difficult to write a Java
> program to handle data collection from a scanner.
> Furthermore, I am worry that if this program is
> distributed, will there be LOTS of trouble? With
> regard to data collection, that come from different
> model of scanner and various condition of the survey,
> such as there are many cross-out or twink-out or even
> the data was not collect properly...
>
> Any suggestions or advice would be VERY MUCH
> appericate. Thank you.
>
> Sam
Our agency uses Scantron 8200 type Optical Mark Reader Data Terminals (scanners) to read,score tests and collect data state wide. At present we have several apps that use the scanners, unfortunately all are DOS based. We are presently try to convert to Java apps as replacement. The manual for the scanner contains a chapter on how to write software for it. The process is as follows:The application reads a setup file (acsii) provided by the manufacturer to define the form being read and sends it to the scanner. Once the scanner is ready it sends a signal via serial port to the app. The app the sends a code to read a form. The scanner reads a form and send the ascii data to the app which processes it. The process continues this conversation until all the forms are read. All the codes are in the manual.Our problem is converting the process to Java using JavaComm, but the process itself is a simple RS232 conversation between app and scanner.Lots of Luck Neal
I used scantron clarity 120 to collect data. I test to scantron CD demo, all failure(OS windwos xp2). There is no source code for the java code. Would you please share some advice to control the scontron form scan ?
1. I tried to use javacomm, how to send the command to scanner and accept the results?
2. Do we need any additional lib? I only installed the driver.