Author |
Topic |
CC_ImgDev
5 Posts |
Posted - Mar 04 2016 : 11:52:11
|
Hi, I have an issue that I have not been able to fully resolve with Twain Scanning.
I am using both a TImageEnView (for single page) and TImageEnMView (for multiple pages)
The issue is that using a Canon DR-C225, certain scan settings will produce an image that has 3 columns of the same page. The source document being scanned is a single page of text.
Most of the issues are when the 'Detect Automatically' options are used for Color Mode, Paper Size and DPI.
I have a table of the settings that do work, and what ones don't. I also realize that different scanners behave differently, which makes it difficult to debug things inside their proprietary scan code. Significantly better scan results have already been achieved by setting the TwainParams.AutoDeskew := false, but somehow I think I am still missing something.
Please let me know if you have some info on a property setting or method of dealing with this issue, we're trying to resolve this issue for our customers.
Thank you, Greg |
|
CC_ImgDev
5 Posts |
Posted - Mar 04 2016 : 15:47:44
|
Hi Nigel,
There is a related post from Carlo, he is my co-worker and made a similar post that I wasn't aware of, but we are talking about the same Canon DR-C225 model. I will give you some more info here about what works and doesn't.
We're only changing settings at run-time on the Canon scanner dialog. Otherwise there is one set of code used for single page scans vs. multiple page scans, and the function for the file type it's saved to may change from JPG (single) to a TIFF or PDF file, so this will change the acquired image that can be seen in either a TImageEnView or TImageEnMView display before saving the file.
Some scan settings will cause the image to change appearance when saved, for example: ImageEnMView.MIO.SaveToFileTIFF(ScanFileName) on a TIFF file.
I'm attaching a file with some of our test results. I'm tempted to just give the customer a list of workable settings and tell them to use that, but still would like to find out what the underlying issue is and attempt to resolve it.
Thanks, Greg
|
|
|
xequte
38610 Posts |
|
CC_ImgDev
5 Posts |
|
xequte
38610 Posts |
Posted - Mar 05 2016 : 21:17:49
|
No worries.
These issues will be very difficult for us to debug if they only occur with that one scanner. Also, if the driver itself is just buggy or oddly incompatible then adding workarounds for it could adversely affect our support for other devices.
I recommend that you try stepping through the ImageEn code to see where it is failing and then we can decide what our options are.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
CC_ImgDev
5 Posts |
Posted - Mar 07 2016 : 15:39:41
|
Thanks for your feedback Nigel,
Yeah, it's a tough situation to debug, not knowing what is happening inside the scanner, and a wide array of combinations that affect it's behavior.
We've spent a lot of time stepping through the code, and sometimes the image is distorted (multiple columns etc.) directly from the acquire call, other times the image looks good after the acquire stage, but has a problem when saved.
The code is broken down into distinct calls for each file type, calling the appropriate save type for .jpg, .tiff and .pdf files like this example, otherwise they pretty much follow the same code - it just behaves much differently for different scanner settings - especially the 'Automatically Detect' options.
If you see any obvious failings in this approach please let me know what you suggest to correct it...
procedure TMyForm.OnAcquireClose(Sender: TObject);
var
FileExt: string;
Msg: string;
begin
FileExt := UpperCase(ExtractFileExt(ScanFileName));
ScanPages := ImageEnMView.MIO.ParamsCount;
if ScanPages < 1 then exit;
// set compression after file is acquired
if ImageEnMView.MIO.Params[0] <> nil then
begin
if (UpperCase(FileExt) = '.PDF') then
begin
ImageEnMView.MIO.Params[0].PDF_Compression := ioPDF_JPEG;
ImageEnMView.MIO.DuplicateCompressionInfo;
end
else if IsTIFF_File(FileExt) then
begin
//ImageEnMView.MIO.Params[0].TIFF_Compression := ioTIFF_G4FAX;
ImageEnMView.MIO.Params[0].TIFF_Compression:=ioTIFF_JPEG;
ImageEnMView.MIO.DuplicateCompressionInfo;
ImageEnMView.RemoveBlankPages(0.0001, true, true); // to remove black pages
end;
end;
ImageEnMView.Proc.AutoCrop2; // try to remove any black borders
try
if (UpperCase(FileExt) = '.PDF') then
ImageEnMView.MIO.SaveToFilePDF(ScanFileName)
else if IsTIFF_File(FileExt) then
ImageEnMView.MIO.SaveToFileTIFF(ScanFileName);
except on e: exception do
begin
if ImageEnMView.MIO.TwainParams.LastError > 0 then
begin
Msg := format('Error code %d' + #13#10
+ '%s' + #13#10
+ '%s', [ImageEnMView.MIO.TwainParams.LastError,
ImageEnMView.MIO.TwainParams.LastErrorStr,
e.Message]);
MessageDlg(Msg,mtError,[mbOK],0);
end;
end;
end;
Thanks much, Greg
|
|
|
xequte
38610 Posts |
Posted - Mar 07 2016 : 17:02:33
|
Hi Greg
Sorry, are you saying that the image may look OK within the TImageEnMView but becomes odd at the point of saving?
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
CC_ImgDev
5 Posts |
Posted - Mar 07 2016 : 17:20:16
|
Yes that happens in some cases... the preview thumbnail looks good, but can sometimes have an issue when saved. |
|
|
xequte
38610 Posts |
Posted - Mar 14 2016 : 15:49:53
|
Hi
It looks like you are not setting the BitsPerSample and SamplesPerPixel which is required when changing TIFF compression.
For example:
ImageEnMView.MIO.Params[0].TIFF_Compression := ioTIFF_JPEG;
ImageEnMView.MIO.Params[0].BitsPerSample := 8;
ImageEnMView.MIO.Params[0].SamplesPerPixel := 3;
ImageEnMView.MIO.DuplicateCompressionInfo();
For monochrome ioTIFF_G4FAX you need:
ImageEnMView.MIO.Params[0].TIFF_Compression := ioTIFF_G4FAX;
ImageEnMView.MIO.Params[0].BitsPerSample := 1;
ImageEnMView.MIO.Params[0].SamplesPerPixel := 1;
ImageEnMView.MIO.DuplicateCompressionInfo();
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
Scott
USA
8 Posts |
Posted - Jun 07 2016 : 16:56:27
|
Was this issue ever solved? I am having the exact same problem with a Canon DR-C130. When the Color Mode property in the scanner's settings is set to "Detect Automatically", the image shows in 3 columns across the screen. This happens in all of the ImageEn demos that I have tried also. If you change the setting to "Black and White" or "24-bit Color", the image scans in fine. I assume there is some property or combination of properties in ImageEn that can force this setting to not be "Detect Automatically", but I have yet to find that setting(s). |
|
|
xequte
38610 Posts |
Posted - Jun 09 2016 : 00:24:26
|
Hi Scott
The issue earlier was due to the user setting an incompatible color depth and TIFF compression.
Can you let me know what code you are using?
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
Scott
USA
8 Posts |
Posted - Jun 14 2016 : 18:48:51
|
Nigel, with this specific scanner, it is able to detect when a color page is being scanned in. The users have Canon software, CaptureOnTouch on their machines. This software is just to allow the user to interact with the scanner: set settings, scan docs, etc. There is an option in that software to set the “Color Mode” to several values “Detect Automatically”, “Black and White”, “24-bit color”, etc. When I set the value to black and white or 24-bit color, everything is fine. When I set it to detect automatically, it’s like the scanner wants to scan in 3 columns. When I set the bit depth to any value in the code, it displays the scanned image in 3 columns across the screen. When I leave the bit depth alone, it basically chops the image into 3 columns, only displaying the first. I can tell this because looking at the image I can easily tell that only one third of the page is displaying.
Ok, here is what I am doing in the code. I am using a TImageEnMView as a thumbnail view and a TImageEnVect to actually view the images as they are clicked in the thumbnail view. Before I scan I set the following TWainParams.
ImageEnMView.MIO.TwainParams.AutoScan := false;
ImageEnMView.MIO.TwainParams.PixelType.CurrentValue := 1;
//ImageEnMView.MIO.TwainParams.BitDepth.CurrentValue := StrToInt(cmbBitDepth.Text);
//ImageEnMView.MIO.TwainParams.Contrast.CurrentValue := 0;
//ImageEnMView.MIO.TwainParams.Brightness.CurrentValue := 0;
ImageEnMView.MIO.TwainParams.Threshold.CurrentValue := 128;
ImageEnMView.MIO.TwainParams.XResolution.CurrentValue := 150;
ImageEnMView.MIO.TwainParams.YResolution.CurrentValue := 150;
// ImageEnMView.MIO.TwainParams.XScaling.CurrentValue := StrToFloat(ebXScaling.Text);
// ImageEnMView.MIO.TwainParams.YScaling.CurrentValue := StrToFloat(ebYScaling.Text);
This is the code that does the actual scanning:
ImageEnMView.Clear;
ImageEnVect.Clear;
ImageEnMView.MIO.TwainParams.SelectedSource := cmbScanner.ItemIndex;
ImageEnMView.MIO.TwainParams.VisibleDialog := false;
ImageEnMView.MIO.NativePixelFormat := true;
if ImageEnMView.MIO.Acquire then begin
ImageEnMView.MIO.Params[0].TIFF_Compression := ioTIFF_G4FAX;
//ImageEnMView.MIO.Params[0].TIFF_Compression := ioTIFF_LZW;
ImageEnMView.MIO.Params[0].BitsPerSample := 1;
//ImageEnMView.MIO.Params[0].BitsPerSample := 8;
ImageEnMView.MIO.Params[0].SamplesPerPixel := 1;
ImageEnMView.MIO.DuplicateCompressionInfo;
NOTE: THIS LOOP BELOW WAS NOT IN MY ORIGINAL CODE WHERE I SAW THIS ISSUE, BUT IT DOES STILL HAPPEN WITH THE THE LOOP. I ADDED IT BECAUSE THE IMAGES WERE ALL COMING IN IN COLOR, EVEN WHERE I HAD THE BITDEPTH AND PIXELTYPES SET TO 1.
for iImageCount:=0 to ImageEnMView.ImageCount-1 do begin
ImageEnMView.SelectedImage := iImageCount;
ImageEnMView.Proc.ConvertToBW_FloydSteinberg;
end;
ImageEnMView.SelectImage(0);
ImageEnMViewImageSelect(self, 0);
if cbFit.Checked then
ImageEnVect.Fit;
end;
The two procedures below are what I use to manage the correct image showing from the thumbnail view to the ImageEnVect component:
procedure TfrmScanTest.ImageEnMViewImageSelect(Sender: TObject; idx: Integer);
begin
ScrollThumbnailView(idx);
end;
procedure TfrmScanTest.ScrollThumbnailView(PageIndex: integer);
begin
// Copy image
ImageEnMView.CopyToIEBitmap(PageIndex, ImageEnVect.IEBitmap );
// Copy annotations
ImageEnVect.RemoveAllObjects;
ImageEnMView.MIO.Params[PageIndex].ImagingAnnot.CopyToTImageEnVect(ImageEnVect);
ImageEnVect.Update;
end;
I got a server error 500 when trying to attach the image or a zip containing the image. But yes, it does save with the 3 columns exactly how it is displayed in the ImageEnVect component.
|
|
|
Scott
USA
8 Posts |
Posted - Jun 15 2016 : 12:09:26
|
This is one of the images produced. This page was black and white, the setting in the canon software was set to Detect Automatically, and I tried to set the bit depth to 1.
attach/Scott/201661512911_ImageEnColumns.zip 13.1 KB |
|
|
Scott
USA
8 Posts |
Posted - Jun 16 2016 : 11:15:50
|
I am attaching an image from the ImageEn Multi demo. As you can see the second image scanned in has the same issue. The first image comes in fine, the second image shows as 3 columns. As I said before, the image will save this same way. And now we have a client with a Brother scanner reporting the same issue, so it doesn't appear to be limited to just the Canon software like we thought.
|
|
|
xequte
38610 Posts |
Posted - Jun 16 2016 : 18:41:56
|
Hi Scott
We'll investigate this. Can you confirm the ImageEn version you are using?
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
Scott
USA
8 Posts |
Posted - Jun 17 2016 : 09:59:37
|
Nigel, we are using 6.2.0. I need to make a correction on my last post. We can't confirm that this has happened with a different scanner brand yet other than Canon. As far as we can tell also, the Canon CaptureOnTouch software has to be installed so that the advanced setting Color Mode = "Detect Automatically" can be set. If that setting is not set in that software, we don't appear to have issues. I will note though that our users that are installing the Canon software from the installation CD are installing that software and "Detect Automatically" is the default setting so we are seeing the issue frequently. Thanks. |
|
|
w2m
USA
1990 Posts |
Posted - Jun 17 2016 : 10:41:42
|
In the past I have found that WIA often works better than TWAIN. I assume you are using TWAIN, so try using WIA and see if the problem persists. ImageEn1.IO.SelectAcquireSource([ieaWIA])
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
Scott
USA
8 Posts |
Posted - Jun 17 2016 : 11:39:59
|
Bill, when the drivers are installed for this scanner, two drivers install. One is called Canon DR-C130 TWAIN, the other is WIA-CANON DR-C130 USB. The one listed as WIA does actually work fine, it does not have the issues that the TWAIN driver has. However, ImageEn doesn't recognize the driver as WIA, it shows them both as TWAIN. This has been a point of confusion also while investigating this issue. Also, we have been telling our users to use TWAIN compliant scanners and to use the TWAIN drivers for years now, we are trying to avoid completely changing this now. Thanks. |
|
|
w2m
USA
1990 Posts |
Posted - Jun 17 2016 : 13:51:18
|
The only problem with your approach is ImageEn may not be able to fix the problem if it is a driver problem... In that case you have no choice if you want to resolve it. As I understand twain is older than WIA which is why some vendors may not fix their old twain driver problems.
Bill Miller Adirondack Software & Graphics Email: w2m@hughes.net EBook: http://www.imageen.com/ebook/ Custom Commercial ImageEn Development |
|
|
Scott
USA
8 Posts |
Posted - Jun 24 2016 : 16:19:08
|
Bill, that would have been my thought as well but our software written in Delphi 7 using the ImageLib components works perfectly fine with the same driver. The issue we are seeing is with same Canon scanner and driver, and same Canon CaptureOnTouch software. The only change is our same software converted to Delphi XE6 with ImageEn components replacing the ImageLib components. |
|
|
xequte
38610 Posts |
Posted - Jun 26 2016 : 01:09:04
|
Hi Scott
We are investigating this. I expect it is due to to an unexpected color depth in the acquired image.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
Topic |
|