Scanner
23 May 2004

Status

In the 2.4 and early 2.6 kernels, the scanner was supported by a kernel module. In the recent 2.6 kernels, the scanner is supported by libusb. To make the transition, do this:
  • Add user steen to group scanner
  • In /etc/sane.d/snapscan.conf uncomment the line
    /dev/usb/scanner0 bus=usb
  • Snapscan worked out of the box on trevi, using kooka -- though initially only for user root

Commands

  • scanimage -L (list scanners)
    • scanimage -T -v  (run verbose tests)
    • scanimage -d hp_rts88xx:libusb:002:002 > image.pnm
    • scanimage > image.pnm (with export SANE_DEBUG_hp_rts88xx=255)
  • sane-find-scanner
  • dmesg | grep scan
  • lsusb
  • dpkg-reconfigure -plow libsane
  • adduser steen scanner
  • l /proc/bus/usb/002/006
  • pinfo /usr/share/doc/libsane/README.Debian.gz
  • /etc/hotplug/usb/libsane.usermap -- list of supported USB scanners
  • /etc/hotplug/usb/libusbscanner -- executed by hotplug when you plug in scanner
  • nano /etc/sane.d/snapscan.conf
  • export SANE_DEBUG_SNAPSCAN=2 (to increase debug level)
  • tesseract-ocr            Command line ocr tool
  • kooka -d snapscan:libusb:002:006

Software

Guides


OCR

28 February 2005

This time I used Kooka to scan, saved pgm files, straightened the images in the gimp, and converted with
gocr -v 7 -i kscan*pgm -o test.txt
Good results; a page in 5 seconds, but needs cleaning.

Also try tesseract-ocr, a command line ocr tool

26 August 2004

The optical character recognition program GOCR works well on clean non-italic fonts.  The .tif format is supposed to work if you have the netpbm package installed, but it didn't work for me -- look into this. I used the Gimp to generate .pcx files, which gocr accepts with no problems. The program tolerates minor deviations from correct orientation -- at least on the order of a degree or two.

Software
  • gocr
    • gocr-gtk
    • gocr-doc
  • tesseract-ocr
  • netpbm
  • netpbm-nonfree
The simplest is to use the command line:
gocr -i input-file.pcx -o output-file.txt
The result was definitely acceptable, though it's years behind the OCR program I've been using in Windows: no training, no manual mode where you see the image and pick the right words, and no dictionary or spell check -- even weird characters occur frequently, such as accented i's. Still, it's plenty good enough to be useful.

Installation history

On 13 June 2005 I tested Tim's donated UMAX Astra 2200 usb scanner as a drop-in replacement of the Agfa on Sigillo, plugging in its power and usb. It is seen and scans, but just texture.  I set the type to usb in /etc/sane.d/umax.config and tried some low-level commands:
# scanimage -L
device `v4l:/dev/video0' is a Noname CPiA Camera virtual device
device `umax:libusb:002:008' is a UMAX     Astra 2200       flatbed scanner

# scanimage -d umax:libusb:002:008 >image.pnm
That also produced a pink textured image, like a weave, with no signs of picking up anything.

On 23 May 2004 I noticed the scanner was not working -- it had been working fine earlier, on a 2.6 kernel, but I don't recall exactly when it stopped working. After 2.6.3 the scanner module was no longer present, so that's likely the time. I ran
# sane-find-scanner

found USB scanner (vendor=0x06bd [AGFA], product=0x0001 [SNAPSCAN 1212U]) at libusb:002:007
found USB scanner (vendor=0x0553, product=0x0002 [USB Camera]) at libusb:002:004
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.
So far so good. Then,
# scanimage -L
device `v4l:/dev/video0' is a Noname CPiA Camera virtual device
device `snapscan:libusb:002:007' is a AGFA SNAPSCAN 1212U flatbed scanner
Still looks good. Then I ran kooka, and it sees only the webcam, not the scanner.

I read instructions in /usr/share/doc/libsane/README.Debian.gz that /etc/hotplug/usb/libsane.usermap contains a list of supported scanners, and find AGFA-Gevaert NV|SnapScan 1212U listed. I then have a look at /etc/hotplug/usb/libusbscanner, which just seems to set the permissions -- and I find that this is working fine -- the scanner at /proc/bus/usb/002/006 (or 007) gets its permissions set to root.scanner and 660.

So why isn't it detected by kooka and xsane? The /etc/sane directory does not exist, and the scanner doesn't need a dll file. I try this:
scanimage -d snapscan:libusb:002:007
No luck.

Then I read these instructions and try
cat /proc/bus/usb/devices

T:  Bus=02 Lev=02 Prnt=02 Port=06 Cnt=03 Dev#=  5 Spd=12  MxCh= 0
D:  Ver= 1.00 Cls=ff(vend.) Sub=ff Prot=ff MxPS= 8 #Cfgs=  1
P:  Vendor=06bd ProdID=0001 Rev= 1.20
S:  Manufacturer=AGFA
S:  Product=SNAPSCAN 1212U
C:* #Ifs= 1 Cfg#= 1 Atr=40 MxPwr=100mA
I:  If#= 0 Alt= 0 #EPs= 3 Cls=ff(vend.) Sub=ff Prot=ff Driver=(none)
E:  Ad=81(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
E:  Ad=02(O) Atr=02(Bulk) MxPS=   8 Ivl=0ms
E:  Ad=83(I) Atr=03(Int.) MxPS=   8 Ivl=16ms
The device node -- if I need a device node -- is /dev/usb/scanner0. However, this should be handled by hotplug. Somehow hotplug is not starting the right driver, which is also called usbscanner -- or is it?
locate usbscanner
finds only /etc/hotplug/usb/libusbscanner, from the libsane package. I upgrade the package:
Setting up libsane (1.0.14-2) ...
Installing new version of config file /etc/hotplug/usb/libsane.usermap ...
Installing new version of config file /etc/hotplug/usb/libusbscanner ...
Installing new version of config file /etc/sane.d/epson.conf ...
Installing new version of config file /etc/sane.d/gt68xx.conf ...
Installing new version of config file /etc/sane.d/matsushita.conf ...
Installing new version of config file /etc/sane.d/mustek.conf ...
Installing new version of config file /etc/sane.d/mustek_pp.conf ...
Installing new version of config file /etc/sane.d/plustek.conf ...
Installing new version of config file /etc/sane.d/teco1.conf ...
Installing new version of config file /etc/sane.d/umax_pp.conf ...
Installing new version of config file /etc/sane.d/artec_eplus48u.conf ...
Installing new version of config file /etc/sane.d/snapscan.conf ...
Installing new version of config file /etc/sane.d/dll.conf ...
I now have something in /etc/sane.d/snapscan.conf -- I uncomment the line
# For USB scanners also specify bus=usb, e.g.
/dev/usb/scanner0 bus=usb
This should really be in debconf, or the preinstallation script. I disconnect and reconnect the scanner and now get this:
May 23 15:35:53 sigillo kernel: usb 2-1.7: USB disconnect, address 5
May 23 15:35:57 sigillo kernel: usb 2-1.7: new full speed USB device using address 6
May 23 15:35:57 sigillo usb.agent[2509]:      libusbscanner: loaded sucessfully
Now we get a driver. But kooka still doesn't see the device under user steen (I didn't try root, but see below).

In the libsane package I also see this:
/etc/sane.d/snapscan.conf
/usr/share/man/man5/sane-snapscan.5.gz
/usr/lib/sane/libsane-snapscan.so.1
/usr/lib/sane/libsane-snapscan.so.1.0.14
/usr/lib/sane/libsane-snapscan.la
From the man page, I discover that the driver expects to see the device on /dev/usb/scanner0 -- how does that work on the 2.6.5 kernel?

And this general stuff:
/usr/share/doc/libsane/PROBLEMS
/usr/share/doc/libsane/html
/usr/share/doc/libsane/html/sane-backends-external.html
/usr/share/doc/libsane/html/sane-backends.html
/usr/share/doc/libsane/html/sane-mfgs-external.html
/usr/share/doc/libsane/html/sane-mfgs.html
/usr/share/doc/libsane/examples
/usr/share/doc/libsane/examples/README
/usr/share/doc/libsane/examples/xerox
/usr/share/doc/libsane/README.gz
/usr/share/doc/libsane/AUTHORS.gz
/usr/share/doc/libsane/NEWS.gz
/usr/share/doc/libsane/README.linux.gz
/usr/share/doc/libsane/README.Debian.gz
/usr/share/doc/libsane/changelog.Debian.gz
/usr/share/doc/libsane/changelog.gz
I now try:
# export SANE_DEBUG_SNAPSCAN=2
# scanimage -d snapscan:libusb:002:006
[sanei_debug] Setting debug level of snapscan to 2.
[snapscan] add_usb_device: error opening device /dev/usb/scanner0: Invalid argument
[snapscan] calibrate: reading calibration data (4 lines)
P6
# SANE data follows
Oodles of it, garbage on screen, and the scanner doesn't do a proper scan -- but it moves! I then try
# scanimage -L
[sanei_debug] Setting debug level of snapscan to 2.
[snapscan] add_usb_device: error opening device /dev/usb/scanner0: Invalid argument
So clearly scanimage expects to find the device on /dev/usb/scanner0, and so far it's not been symlinked correctly (hotplug should handle this). I rebooted and now this worked:
scanimage -d snapscan:libusb:002:006 >image.pnm
However, this only works for user root -- other users don't see the scanner. I add user steen to group scanner, but still don't see the device. However, in X I can now issue (as user root)
xsane snapscan:libusb:002:006
and get a perfect scan. Ditto for
kooka -d snapscan:libusb:002:006
So we're sort of in business. I run (as user steen)
strace sane-find-scanner
and see this:
open("/proc/bus/usb/002/006", O_RDONLY) = -1 EACCES (Permission denied)
I'll try logging out and back in. OK, that worked. User steen, member of group scanner, now sees and can use the scanner.


 

 

top