3
Good afternoon! I need to develop a python application and I’m not getting the program to get an image of a scanner sector, only of the entire area that the scanner can scan (approximately a A4 sheet). I’m still a beginner in language.
My need is to monitor a scanner area, performing for example 2 images per minute. Only I don’t need all the A4 sheet that the scanner is capable of. I need a sector, a square 10cm x 10cm.
As soon as the software detects any change from the previous image to the current one, I would like it to play an alert sound and stop monitoring.
My problem is that using the lib Twain 1.0.5 and Image Scanner i cannot define an area. In all the tests I performed the obtained is always the "A4 sheet".
I am totally open to suggestions, including for programming language exchange. My fear (and guess) is that these aforementioned libraries do not realize what I need and I found no other test.
The closest I got to the necessary was when I modified the value in the "simple_base.py" file of the library Twain 1.0.5:
self.SD.Requestacquire(0, 0) # 1,1 to show scanner user interface
Adjusting the value from (0, 0) to (1, 1) the program opens a scanner driver window, where I can adjust so that the scanner only reads an area. The problem is that this is done manually. I wanted to leave an area as default because it is always the one that should be monitored.
Thank you very much!
How about cropping the image after scanning? Would it be acceptable for you? Cropping (Crop) is simple using Pillow.
– sergiopereira
@sergiopereira Unfortunately it is not appropriate because getting a high resolution image through a scanner, if it is the whole sheet, ends up taking more than 30 seconds and then the monitoring accuracy drops drastically. I had already thought about the possibility, but the test did not go very well... Thanks for the suggestion!
– Hitoshi
Let me get this straight: are you using a scanner to monitor change in any object (possibly a document)? I can’t believe Scanners are good for this kind of task. Mainly because he literally "scans" the image instead and captures it in one take, the performance for this type of task is really bad. Also, documents in a scanner don’t usually change on their own (they change when the user changes them). Wouldn’t it be better to use a webcam, for example? Maybe if you give more details of your problem it will be easier a suggestion.
– Luiz Vieira