|<< 
Wojciech Adam Koszek 
> Other





Using Canon CanoScan 1220OU scanner with FreeBSD


Wojciech A. Koszek
wkoszek@FreeBSD.org
2009.03.01

Introduction

Before 2009.02.28 I have never had a scanner before. I stayed away from anything related with image scanning or image acquisition. In the past I formed a thesis that "computers going to outweight human writing by the year 2004".

However, increasing heap of notes shifting around my room gave me a feeling that my situation is rather reversed to my thesis. I finally decided to acquire a cheap, moderately flat USB scanner, powered from the USB data bus, just not to make my desk situation even worse.

I got Canon CanoScan N1220OU USB scanner from Allegro for something around 20$, including shipping.

This scanner is supported by the FreeBSD system out-of-box. You need to have USB support compiled into the kernel.

System setup and software installation

For default configuration file, GENERIC, support for USB should be present.

	wkoszek@laptop:~$ uname -a
	FreeBSD laptop.freebsd.czest.pl 8.0-CURRENT FreeBSD 8.0-CURRENT #0 r189167: Sun Mar  1 00:04:48 UTC
	2009     wkoszek@laptop.freebsd.czest.pl:/usr/src/sys/i386/compile/GENERIC  i386

You should be able to confirm USB presence with following command:

	wkoszek@laptop:~$ kldstat -v | grep usb
			300 usbus/ushub
			298 ushub/usb_linux
			295 ohci/usbus
			294 uhci/usbus
			293 ehci/usbus
			292 at91_udp/usbus
			291 uss820/usbus

If you've modularized your kernel, you should get the very same result by loading uscanner.ko driver:

	# kldload uscanner

Once you have kernel support present, you can plug your USB scanner. Correct detection of a device should be confirmed in dmesg output:

	ugen0.3: <Canon> at usbus0
	uscanner0: <Canon CanoScan, class 0/0, rev 1.00/1.00, addr 3> on usbus0

(please note that at a time of 2009.03.01 FreeBSD gained new USB subsystem; with the old USB layer, output from the dmesg might differ a bit). Anyway, both old and new USB code supported my scanner.

We can now install scanner software:

	# (cd /usr/ports/graphics/sane-backends && make install clean)
	# (cd /usr/ports/graphics/sane-frontends && make install clean)

SANE's programs will output the scanning result in PPM format, and since it can't be used sensibly without a conversion, I recommend to install ImageMagick as well:

	# (cd /usr/ports/graphics/ImageMagick && make install clean)

Image acquisition

You should be able to see your scanner of a list of supported devices:

	wkoszek@laptop:/home/wkoszek# scanimage -L
	device `plustek:libusb:/dev/usb:/dev/ugen0.3' is a Canon CanoScan N1220U flatbed scanner

Scanning of the A4 sheet (215x297mm) with 350DPI resolution can be performed as follows:

	wkoszek@laptop:~# scanimage -x 215 -y 297 --resolution 350 > output.ppm

Conversion is trivial:

	wkoszek@laptop:~# convert output.ppm output.jpg

There's no need to obtain PPM file of course - pipes solve the problem. Just to present differences between formats:

	wkoszek@laptop:~# du -ch output.*
	2,3M    output.jpg
	20M    output.png
	35M    output.ppm
	57M    total