Scanning as input

When things doesn't work as they should.
KevinPawsey
Posts: 76
Joined: Wed Aug 22, 2018 2:52 pm

Re: Scanning as input

Post by KevinPawsey » Thu Mar 14, 2019 7:44 pm

OK, I have just bit the bullet and I have just ordered myself a Canon imageFORMULA DR-2580C Document Scanner.

Does anyone have any experience with using this with Mayan?

I've look at the SANE compatibility, and this is what it says:

Code: Select all

DR-2580C	USB SCSI	0x04a9/0x1608	Complete	Hardware provides: Gray/Color, Simplex/Duplex, Full-width. Driver provides: Binary, Despeckle, Deskew, Cropping, Calibration	canon_dr 
(51)	sane-canon_dr
Appreciate your feedback... it wont arrive for a couple more weeks, so still time to cancel!

TIA

Kevin
Running Mayan-EDMS on: OpenMediaVault, (Docker plugin), on x86 dual-core

KevinPawsey
Posts: 76
Joined: Wed Aug 22, 2018 2:52 pm

Re: Scanning as input

Post by KevinPawsey » Tue Mar 19, 2019 1:06 pm

Today I have received the scanner... much quicker than I expected... just trying to set it up, but it doesn't seem to want to work.

The scanner is seen within the docker image:

Code: Select all

sane-find-scanner 

  # sane-find-scanner will now attempt to detect your scanner. If the
  # result is different from what you expected, first make sure your
  # scanner is powered up and properly connected to your computer.

  # No SCSI scanners found. If you expected something different, make sure that
  # you have loaded a kernel SCSI driver for your SCSI adapter.

could not fetch string descriptor: Pipe error
could not fetch string descriptor: Pipe error
found USB scanner (vendor=0x04a9, product=0x1608) at libusb:001:002
  # Your USB scanner was (probably) detected. It may or may not be supported by
  # SANE. Try scanimage -L and read the backend's manpage.

  # Not checking for parallel port scanners.

  # Most Scanners connected to the parallel port or other proprietary ports
  # can't be detected by this program.
  
  scanimage -L
device `canon_dr:libusb:001:002' is a CANON DR-2580C scanner
I have tried putting the device as

Code: Select all

canon_dr:libusb:001:002
and leaving all the rest of the options as blank, so it will use defaults, but I am getting the following error in the logs:

Code: Select all

sources.models <157> [ERROR] "get_upload_file_object() line 266 Exception while scanning from source:Scanner ; scanimage: open of device canon_dr:libusb:001:002 failed: Invalid argument
"
If I run a scan from the CLI manually, it seems to work ok:

Code: Select all

scanimage -v --format=jpeg -p --mode color -d canon_dr:libusb:001:002 > ~/test.jpg
scanimage: scanning image of size 5100x6600 pixels at 24 bits/pixel
scanimage: acquiring RGB frame
scanimage: min/max graylevel value = 0/255
scanimage: read 100980000 bytes in total
This is a little disappointing, as I thought that if I bought a fully SANE-compatible scanner, I wouldn't have any more of these issues... but at the moment I am back to square one again.

@Rosarior - is there anything else that I can try to get this to work?
Running Mayan-EDMS on: OpenMediaVault, (Docker plugin), on x86 dual-core

KevinPawsey
Posts: 76
Joined: Wed Aug 22, 2018 2:52 pm

Re: Scanning as input

Post by KevinPawsey » Tue Mar 19, 2019 2:56 pm

and after another lightbulb moment, I thought that I would have a think about what is happening, and it turns out that the scanimage command is being done by the user "mayan" and I was testing under the user "root"... funny enough, the following command fails:

Code: Select all

sudo -u mayan scanimage -v --format=jpeg -p --mode color -d canon_dr:libusb:001:002 > ~/test.jpg
scanimage: open of device canon_dr:libusb:001:002 failed: Invalid argument
I managed to find that if I add the mayan user to the "lp" group and then did the following, I could then do a basic scan:

Code: Select all

chgrp lp /dev/bus/usb/001/002
the unfortunate thing is that this needs to be done on each reboot, as the USB devices are re-evaluated/re-created on reboot

The next thing is that I would like to do Duplex scanning, but this is failing with:

Code: Select all

sources.models <47> [ERROR] "get_upload_file_object() line 266 Exception while scanning from source:Scanner ; scanimage: setting of option --source failed (Invalid argument)
having a look at the code, I think that it might be because the options for the canon scanner are are not what is in the code. For selecting the ADF as being duplex, for the canon, I need to do:

Code: Select all

scanimage -v --format=jpeg -p --mode color -d canon_dr:libusb:001:002 --source 'ADF Duplex'
so to select duplex it is "--source 'ADF Duplex'" rather than "--adf-mode duplex".

Is there any way of tweaking the scanimage command line for specific scanners? I don't mind doing a little code altering for the meantime until something more solid can be done with the next version?

Thanks for your help.

Kevin
Running Mayan-EDMS on: OpenMediaVault, (Docker plugin), on x86 dual-core

KevinPawsey
Posts: 76
Joined: Wed Aug 22, 2018 2:52 pm

Re: Scanning as input

Post by KevinPawsey » Wed Mar 20, 2019 10:47 am

ok... another update...

to get this working, I have created a 'shim' for the scanimage executable in /usr/bin. So what I have done is renamed /usr/bin/scanimage to /usr/bin/scanimage_prog, I have then created a shell script that looks like this:

Code: Select all

#!/bin/bash
scanimage_prog --format=tiff --buffermode=yes --stapledetect=yes --rollerdeskew=yes --source 'ADF Duplex' "$@"
from this shim I can insert the relevant settings manually to make the scanner do what I want (switched on deskewing, staple detection and buffering... this, for the most part, works.

The only problem that I have now, and the whole reason I bought a duplex scanner, is that I cannot get it to scan duplex... using the switch --source 'ADF Duplex' does switch on the duplex scanning, but it doesn't produce a multi-page document in Mayan-EDMS... I just get one side.

From the cli, I can get it to save both sides of the page using the following command:

Code: Select all

scanimage --batch=out%d.jpg --format=jpg -d canon_dr:libusb:001:002 --mode color --resolution 200
Scanning -1 pages, incrementing by 1, numbering from 1
Scanning page 1
Scanned page 1. (scanner status = 5)
Scanning page 2
Scanned page 2. (scanner status = 5)
Scanning page 3
scanimage_prog: sane_start: Document feeder out of documents
The end "error" is just that it has finished scanning... I then get multiple files called out1.jpg, out2.jpg out1 being first side and out2 being second side.

One thing to note with this, although this was a single sheet of paper, it scanned the entire sheet, then "scanned" the second sheet as it was in the scanners buffer without the sheet going through (2x scanning surfaces as the paper goes through they are both scanned at the same time. It seems that Mayan is not requesting the second page.

The problem is, as soon as you invoke the --batch command it changes the filenames... which then messes up how Mayan sees the documents to assemble.

Is there an environment variable that is set that I could read and insert into the shim for the batch filename process?? Just a thought...

This is still a work in progress at the moment... but if there is anyone that can shed any light on this, I would greatly appreciate it, as I really would like duplex scanning going properly.

Thanks
Running Mayan-EDMS on: OpenMediaVault, (Docker plugin), on x86 dual-core

Post Reply