[sane-devel] How to reverse-engineer scanner sensor data (CIS)

Alexander Grau alexandergrau at gmx.de
Thu Oct 4 11:15:23 UTC 2007


Hello,

I try to get the following scanner working under Linux (with sane or 
directly
without libusb).

* Q-Scan Mini FlatBed Scanner DIN A5, Portable Peripheral CO., Ltd.
* USB 2.0, QS-113C chipset
* CIS sensor (600 x 1200 dpi), 24 bits/pixel - no brand of CIS to be 
find in the scanner
* http://www.griden.ru/a5.html


1. I did try the sane "sane-mustek_usb2" module (supporting the QS-113 
chipset).
The scanner motor, lamp etc. works, but the image output is mostly a 
very dark image
(I assume because my scanner has a CIS sensor and this module only 
supports CCD).


2. Second approach was to capture a 1-bit, 8-bit (gray) and 24-bit 
(color) scan with
usbsnoop and the Windows TWAIN driver and make a libusb c program of it 
by parsing it with
"usbsnoop2libusb.pl". The resulting c code 
(http://grauonline.de/alexwww/qscan/testcolor.zip)
works excellent (scanner motor, lamp etc. work), but I have absolutely 
no idea how
to decode the image data I get back...

The data I get back is 11072538 bytes long (TWAIN driver scans a 1275 x 
720 pixels
24-bit color image) and repeats like this:

451 bulk read returned 64000 bytes
452 control msg returned 8 bytes
453 control msg returned 4 bytes
454 bulk read returned 28160 bytes
455 bulk read returned 108 bytes
456 control msg returned 4 bytes
457 control msg returned 4 bytes
458 control msg returned 4 bytes
459 control msg returned 4 bytes
460 control msg returned 8 bytes
461 control msg returned 4 bytes

462 control msg returned 64000 bytes
463 control msg returned 8 bytes
464 control msg returned 4 bytes
465 control msg returned 28160 bytes

...and so on (http://grauonline.de/alexwww/qscan/libusb_answers_partial.zip)

The scanned Windows image is a 50 % red + 50 % green image
(http://grauonline.de/alexwww/qscan/win_color.jpg).

The data I get with the Linux code of the same image is a mixture of red 
and green:
(http://grauonline.de/alexwww/qscan/linux_color.jpg).


Questions:

1. What is the best approach to decode CIS data? How is the format with 
other scanners?
2. Could the color change because of timing problems? I think the time 
critical
  parts are done in the scanner ASIC, so timing shouldn't be a problem 
here (and the ASIC
  is programmed the same way as the TWAIN driver does)
3. Is my approach hopeless without color correction? Also, from digital 
cameras I
  know there must occur some interpolation between the pixel colors. Is 
this needed
  for CIS too?

Any further hints are appreciated!

Best regards,
Alexander Grau

(a l e x a n d e r g r a u  <at>  g m x  <dot>  d e)




More information about the sane-devel mailing list