[sane-devel] Plustek and calibration
Charles Lindsey
chl at clerew.man.ac.uk
Thu Dec 3 21:33:49 GMT 2020
I have an Epson Perfection 1250/Photo which uses the plustek backend. It works
fine for color and gray modes, but for lineart, every time you scan a page it
introduces more black noise along the right hand edge of the page. It turned out
to be the result of calibration. I still don't know why repeated calibration
causes that problem, but that is how I cured it.
Obviously, on startup (more specifically on warmup), any scanner has to be
calibrated; in fact if the warmup is set to 'auto' it repeats the calibration
until the result remains unchanged three times. Examination of the code for the
Plustek Backend shows that it does much more; indeed every time you start a new
scan, it does a new calibration (except for automatic document feeders and the
like). This wastes time (typically six times until the obligatory three
identical results), and it causes my black noise in lineart mode (for reasons
yet unknown). So here are two questions:
1. Does this behavior exist in other backends?
2. Is this excessive calibration really necessary? I suspect not; surely, once
warmup is complete, the calibration will always be the same. It is just a
property of the CCD and the lamp. It will likely stay the same for months -
indeed xsane allows you to send it to a cache file and reload it again on
startup (you may recall an unexpected consequence of this that I reported here a
while back due to using a cache generated on 1.0.27 and still used on 1.0.31).
So I hacked the code so that calibration only happened once per switch-on of the
lamp. Here is my patch as applied to plustek-usb.c.
*** plustek-usb.c.orig 2020-12-03 17:20:01.094781356 +0000
--- plustek-usb.c 2020-12-03 00:13:19.376063183 +0000
***************
*** 895,901 ****
--- 895,904 ----
DBG( _DBG_INFO, "usbDev_setScanEnv()\n" );
/* clear all the stuff */
+ SANE_Bool save_fCalibrated = scan->fCalibrated;
memset( scan, 0, sizeof(ScanDef));
+ /* but restore fCalibrated */
+ scan->fCalibrated = save_fCalibrated;
if((si->ImgDef.dwFlag & SCANDEF_Adf) &&
(si->ImgDef.dwFlag & SCANDEF_ContinuousScan)) {
***************
*** 1082,1092 ****
--- 1085,1098 ----
dev->usbDev.a_bRegs[0x0a] = 1;
#endif
dev->usbDev.a_bRegs[0x0a] = 0;
+ /* LINDSEY: Do we Really need to recalibrate for every scan? */
+ #if 0
if((scan->dwFlag & SCANDEF_Adf) && (scan->dwFlag & SCANDEF_ContinuousScan)) {
scan->fCalibrated = SANE_TRUE;
} else {
scan->fCalibrated = SANE_FALSE;
}
+ #endif
scan->sParam.PhyDpi.x = usb_SetAsicDpiX(dev,scan->sParam.UserDpi.x);
scan->sParam.PhyDpi.y = usb_SetAsicDpiY(dev,scan->sParam.UserDpi.y);
It is for you guys to decide whether this is worth making permanent. I
understand Ralph has a similar Epson scanner, so perhaps he could check whether
that has this lineart problem, and give this patch a try.
Just a few more oddities that I encountered on the way.
Even after the patch, it sits for 13 seconds in usb_IsDataAvailableInDRAM()
before the scan data starts to become available, even though after that it comes
out steadily even if several buffers-full have to be downloaded. I think this is
a problem with the scanner hardware which is too lazy about getting the carriage
out of its garage.
The other is that it is a right pain to get into a state where you can get the
gdb debugger to function on the backend code. It took me a couple of days to
figure out how to construct a plustek.so that could be used with LD_PRELOAD. I
could describe this further if anybody is interested.
--
Charles H. Lindsey ---------At my New Home, still doing my own thing------
Tel: +44 161 488 1845 Web: http://www.cs.man.ac.uk/~chl
Email: chl at clerew.man.ac.uk Snail-mail: Apt 40, SK8 5BF, U.K.
PGP: 2C15F1A9 Fingerprint: 73 6D C2 51 93 A0 01 E7 65 E8 64 7E 14 A4 AB A5
More information about the sane-devel
mailing list