SimulPiscator / AirSane

Publish SANE scanners to MacOS, Android, and Windows via Apple AirScan.
GNU General Public License v3.0
243 stars 26 forks source link

Failed scan with Brother DCP-1622W #92

Open leshniak opened 1 year ago

leshniak commented 1 year ago

I have troubles while scanning documents with Brother DCP-1622W via airsane v0.3.4 and macOS 12.5. The preview looks good, but target scans are always weirdly trimmed and corrupted. It doesn't matter if I change the scan format/area. Scanning using scanimage works fine.

This might be helpful:

git commit: N/A (branch N/A, rev N/A+)
build date: 2022-10-07T15:57:18Z
reading device options from '/etc/airsane/options.conf'
enumerating  devices...
sane_init(nullptr, nullptr)
sane_get_devices() ...
... sane_get_devices() -> SANE_Status Success
sane_exit()
found: Brother_DCP-1610W_series@edison (Brother *DCP-1610W)
stable unique name: Brother_DCP-1610W_series@edison:Brother *DCP-1610W:1
uuid: 842a8d0a-d7b2-5c56-9a3b-d76e4b40fd35
sane_init(nullptr, nullptr)
sane_open(Brother_DCP-1610W_series@edison) -> 0x7f900092b0
[source] := "FlatBed"
[source] := "Automatic Document Feeder(left aligned,Duplex)"
sane_close(0x7f900092b0)
sane_exit()
published as 'Brother *DCP-1610W'
listening on 192.168.5.2:8091
listening on [fe80::dea6:32ff:fe03:3c61]:8091
document format requested: image/jpeg
document format used: image/png
job kind: single
using color gamma of 1
sane_init(nullptr, nullptr)
sane_open(Brother_DCP-1610W_series@edison) -> 0x7f88008100
[mode] := "24bit Color" -> reload options
[source] := "FlatBed"
[resolution] := 100dpi
[tl-x] := 0mm
[tl-y] := 0mm
[br-x] := 212mm
[br-y] := 356mm
sane_start(0x7f88008100) with options:
[br-x] = 211.881mm
[br-y] = 355.567mm
[mode] = "24bit Color"
[resolution] = 100dpi
[source] = "FlatBed"
[tl-x] = 0mm
[tl-y] = 0mm
sane_read(0x7f88008100): End of file reached
images completed: 1
sane_cancel(0x7f88008100)
sane_cancel(0x7f88008100)
sane_close(0x7f88008100)
sane_exit()
document format requested: image/jpeg
document format used: image/png
job kind: single
using color gamma of 1
sane_init(nullptr, nullptr)
sane_open(Brother_DCP-1610W_series@edison) -> 0x7f88008f00
[mode] := "24bit Color" -> reload options
[source] := "FlatBed"
[resolution] := 300dpi
[tl-x] := 0mm
[tl-y] := 65mm
[br-x] := 207mm
[br-y] := 356mm
sane_start(0x7f88008f00) with options:
[br-x] = 206.981mm
[br-y] = 355.567mm
[mode] = "24bit Color"
[resolution] = 300dpi
[source] = "FlatBed"
[tl-x] = 0mm
[tl-y] = 64.994mm
sane_read(0x7f88008f00): End of file reached
images completed: 1
incomplete or excess scan data
sane_cancel(0x7f88008f00)
sane_cancel(0x7f88008f00)
sane_close(0x7f88008f00)
sane_exit()
Zrzut ekranu 2022-10-8 o 09 15 36

P.S. Thanks for your job!

SimulPiscator commented 1 year ago

In v3.4.0, there was a bug, ignoring that SANE parameter settings might interfere with each other, i.e. setting one parameter could result in changes to other parameters. Since v3.5.0, SANE parameters are set in an order that makes it unlikely to result in unwanted parameter changes.

There is a chance that the problem might go away when you switch to v3.5.0.

leshniak commented 1 year ago

Ok, I'll try it after the weekend and go back with the result.

meiser79 commented 1 year ago

Seems to be the same issue as described in #40.

leshniak commented 1 year ago

Unfortunately the issue still exists :/

git commit: fef10a4 (branch HEAD, rev 245)
build date: 2022-10-09T10:51:14Z

How I can help with debugging?

SimulPiscator commented 1 year ago

Thanks for your offer to help with debugging. Could you post one of the distorted scans? Also, please give me some time to go back to @meiser79 's issue #40, and to contemplate my source code.

leshniak commented 1 year ago

Outputs: scanimage.log.txt scanimage airsaned

SimulPiscator commented 1 year ago

Apart from being cut at the top, the scanned image looks fine. So the issue is how it happens that tl-y is set to 65mm rather than 0. @meiser79 reported on a very similar (or identical) issue (#40) that the nonzero value is actually sent by Apple Image Capture.

If you have access to a Windows 10 or Windows 11 installation, can you try scanning from there? Just to see whether it's an Apple Image Capture issue, or an AirSane one.

Another option would be to install the sane-airscan backend and use scanimage to scan through sane-airscan and AirSane.

SimulPiscator commented 1 year ago

And (really sorry for mentioning it) did you move the dashed rectangle in the preview area up to the top?

leshniak commented 1 year ago

I don't have a device with Windows, but I'll try to test it somehow.

Sure, I've tried to move the rectangle even beyond the top - it didn't help.

leshniak commented 1 year ago

It works correctly while using the same system scan window with native macOS drivers.

meiser79 commented 1 year ago

Hi, I re-did all my tests with current git version.

I tested with Ubuntu 20.04 net and sane-airscan backend, Windows 10, Mopria and Apple Image Capture (AIC) on macOS 12.6.

It's still the same behaviour as described in #40. Only AIC with advanced options sends the YOffset (tl-y), all other scans are fine. As described in #40, I guess, it's because the SANE brother4 backend shows 211.881x355.567 mm for maxWidth and maxHeight. But it should be 210x297 mm for A4. My support request to Brother is unanswered since 18/12/2020.

stevensantos-docs commented 1 year ago

I beleive Olaf is working on a native sane driver for the brother4 series of scanners. Maybe check with him.

On Sat, Oct 15, 2022, 5:13 AM Peter Meiser @.***> wrote:

Hi, I re-did all my tests with current git version.

I tested with Ubuntu 20.04 net and sane-airscan backend, Windows 10, Mopria and Apple Image Capture (AIC) on macOS 12.6.

It's still the same behaviour as described in #40 https://github.com/SimulPiscator/AirSane/issues/40. Only AIC with advanced options sends the YOffset (tl-y), all other scans are fine. As described in #40 https://github.com/SimulPiscator/AirSane/issues/40, I guess, it's because the SANE brother4 backend shows 211.881x355.567 mm for maxWidth and maxHeight. But it should be 210x297 mm for A4. My support request to Brother is unanswered since 18/12/2020.

— Reply to this email directly, view it on GitHub https://github.com/SimulPiscator/AirSane/issues/92#issuecomment-1279702254, or unsubscribe https://github.com/notifications/unsubscribe-auth/ANVCVCJPYACB2YEMUVXLIHDWDJYTNANCNFSM6AAAAAARAEPXX4 . You are receiving this because you are subscribed to this thread.Message ID: @.***>

meiser79 commented 1 year ago

I found https://gitlab.com/sane-project/backends/-/tree/brother_mfp_backend/backend/brother_mfp, but only one scanner is supported (MFC-J4320DW).

EDIT: merge request is here: https://gitlab.com/sane-project/backends/-/merge_requests/751

SimulPiscator commented 1 year ago

@meiser79

As described in https://github.com/SimulPiscator/AirSane/issues/40, I guess, it's because the SANE brother4 backend shows 211.881x355.567 mm for maxWidth and maxHeight. But it should be 210x297 mm for A4.

IIRC, you even tried forcing maxWidth and maxHeight to the correct values in AirSane, but without success? If this is not the case, it would be easy to add an option to AirSane to set the maximum scan area to a user-defined value.

meiser79 commented 1 year ago

@SimulPiscator I don't know if I did it right the last time, and I've lost the patch. If you provided a patch for this option, I could test it.

SimulPiscator commented 1 year ago

@meiser79 In server/scanner.cpp, before line 635, insert this: mMaxHeight = 3436; mMaxWidth = 2448; If this doesn't change anything, you might also try mMaxPhysicalHeight = 3436; mMaxPhysicalWidth = 2448;

meiser79 commented 1 year ago

Hi, both changes don't help.

The preview scan is fine, tl_y = 0:

document format requested: image/jpeg
document format used: image/png
job kind: single
using color gamma of 0.555555
sane_init(nullptr, nullptr)
sane_open(brother4:bus1;dev1) -> 0x7f3118084460
[source] := "FlatBed"
[mode] := "24bit Color" -> reload options
[resolution] := 100dpi
[tl-x] := 0mm
[tl-y] := 0mm
[br-x] := 210mm
[br-y] := 297mm
sane_start(0x7f3118084460) with options:
[br-x] = 209.981mm
[br-y] = 296.973mm
[mode] = "24bit Color"
[resolution] = 100dpi
[source] = "FlatBed"
[tl-x] = 0mm
[tl-y] = 0mm
sane_read(0x7f3118084460): End of file reached
images completed: 1
sane_cancel(0x7f3118084460)
sane_cancel(0x7f3118084460)
sane_close(0x7f3118084460)
sane_exit()

But on the scan itself, tl_y = 5.99945mm:

document format requested: image/jpeg
document format used: image/png
job kind: single
using color gamma of 0.555555
sane_init(nullptr, nullptr)
sane_open(brother4:bus1;dev1) -> 0x7f31180943b0
[source] := "FlatBed"
[mode] := "24bit Color" -> reload options
[resolution] := 100dpi
[tl-x] := 0mm
[tl-y] := 6mm
[br-x] := 207mm
[br-y] := 297mm
sane_start(0x7f31180943b0) with options:
[br-x] = 206.981mm
[br-y] = 296.973mm
[mode] = "24bit Color"
[resolution] = 100dpi
[source] = "FlatBed"
[tl-x] = 0mm
[tl-y] = 5.99945mm
sane_read(0x7f31180943b0): End of file reached
images completed: 1
sane_cancel(0x7f31180943b0)
sane_cancel(0x7f31180943b0)
sane_close(0x7f31180943b0)
sane_exit()

BTW, I had to increase mMaxHeight/mMaxPhysicalHeight and mMaxWidth/mMaxPhysicalWidth to 2508x2480, so that I can select A4 in AIC.

Just to be sure that I did it right, here's the diff:

diff --git a/server/scanner.cpp b/server/scanner.cpp
index 130afc6..16e8500 100644
--- a/server/scanner.cpp
+++ b/server/scanner.cpp
@@ -632,6 +632,8 @@ Scanner::Private::InputSource::init(const sanecpp::option_set& opt)
                        &mMaxPhysicalWidth,
                        &mMaxPhysicalHeight })
     *pValue = ::floor(*pValue * f + 0.5);
+  mMaxHeight = 3508; mMaxWidth = 2480;
+  mMaxPhysicalHeight = 3508; mMaxPhysicalWidth = 2480;
   return nullptr;
 }
SimulPiscator commented 1 year ago

@meiser79: The diff looks correct. Also thanks for extensive testing with various scanning software on various OSes!

Given that AIC is the only software that shows this behavior, it's an absolute mystery to me. How does the brother4 backend trigger that in AIC, and why does it exist in AIC in the first place?

meiser79 commented 1 year ago

Sorry, but I have no clue how to continue here. :-(

leshniak commented 1 year ago

Maybe we should wait for that new open-source driver.

SimulPiscator commented 3 months ago

The open-source driver now has support for the DCP-1610W: https://gitlab.com/sane-project/backends/-/blob/brother_mfp_backend/backend/brother_mfp/brother_mfp.cpp The DCP-1622W is actually a variant of the DCP-1610W: https://support.brother.com/g/b/spec.aspx?c=eu_ot&lang=en&prod=dcp1622we_eu

leshniak commented 3 months ago

I've made it working completely wireless using airscan backend and the following definition in /etc/sane.d/airscan.conf:

[devices]
#"Kyocera MFP Scanner" = http://192.168.1.102:9095/eSCL
#"Some Unwanted Scanner" = disable
"Brother DCP-1610W series" = http://DCP-1610W/WebServices/Device, wsd

It uses WSD protocol supported by this device and then airsaned announces the scanner via AirScan.

SimulPiscator commented 3 months ago

Ah, cool. I've noticed the DCP-16xxW do not have eSCL, just WSD, so you can have both now.