Author |
Topic |
|
Sidney Egnew
USA
55 Posts |
Posted - May 01 2017 : 08:50:34
|
Is it possible to save individual pages during an acquire instead of after all pages have been scanned? |
|
Ralf
120 Posts |
Posted - May 01 2017 : 10:59:47
|
Try to use the ImageEnMViewAfterAcquireBitmap(Sender: TObject; index: Integer); |
|
|
xequte
38610 Posts |
Posted - May 01 2017 : 19:31:41
|
Here is an example:
// Save scanned images directly to file without adding them to a TImageEnMView
procedure TForm1.ImageEnMView1AcquireBitmap(Sender: TObject; ABitmap: TIEBitmap; DpiX, DpiY: Integer; var Handled: Boolean);
var
filename: string;
begin
filename := FormatDateTime( '"C:\Scanned Documents\Scan_"yymmdd-hhnnss-zzz".jpg"', Now );
ABitmap.Write( filename);
Handled := True;
end;
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
Sidney Egnew
USA
55 Posts |
Posted - May 02 2017 : 01:07:59
|
Thanks. |
|
|
Sidney Egnew
USA
55 Posts |
Posted - May 02 2017 : 09:28:25
|
I was able to save the files using a .tif file extension. My software identifies them as Tagged Image Format but all files are 8.50 x 11.99 inches and exactly the same number of bytes which seems a little odd.
It also does not appear the actual document size was detected. The scanned batches are mixed content, documents, checks, and envelopes. I can clearly see the physical edge in the images of pages that are smaller that 8.5 x 11.
Other than not detecting the physical page size everything appears correct. I followed your example except I made the file extension .TIF.
I am doing this to acquire: ImageEnMView1.MIO.TwainParams.AutoBorderDetection := True; ImageEnMView1.MIO.TwainParams.AutoRotate := True; ImageEnMView1.MIO.Acquire;
I am doing this to save: FileName := edPath.Text+fBatchId+Format('_%4.4d',[fImageNumber])+'.tif'; ABitmap.Write(FileName);
Border Detection and Auto Rotate are not working.
How can I get Border Detection and Auto Rotate to work?
Why are all my files exactly the same size?
Thanks |
|
|
xequte
38610 Posts |
|
Sidney Egnew
USA
55 Posts |
Posted - May 03 2017 : 17:35:48
|
I wrote a new application using a TImageEnMIO and used the AcquireBitmap event to save the individual pages. I tested the various color compatible compression methods but there was little change in the file sizes. I am concerned my code is wrong and compression is not being done.
I set the appropriate myTiffCompression value based on a combobox selection before I acquire. myTiffCompression: TioTiffCompression; The AcquireBitmap procdure is shown below.
Is the code correct for doing the compression?
procedure TfmMain.ImageEnMIOAcquireBitmap(Sender: TObject;
ABitmap: TIEBitmap;
DpiX, DpiY: Integer;
var Handled: Boolean);
var
FileName: String;
I: Integer;
begin
Inc(myImageNumber);
FileName := SavePathEdit.Text+myBatchId+Format('_%4.4d',[myImageNumber])+'.tif';
ScanMemo.Lines.Add(DateTimeToStr(Now)+' '+FileName);
Application.ProcessMessages;
for I := 0 to ImageEnMIO.ParamsCount-1 do
IMageEnMIO.Params[I].TIFF_Compression := myTIFFCompression;
ABitmap.Write(FileName);
Handled := True;
end; |
|
|
xequte
38610 Posts |
Posted - May 03 2017 : 23:56:00
|
Hi
IMageEnMIO.Params[i] is the params of the images in the associated TImageEnMView, which in your case would be null.
Just set the params of the bitmap:
ABitmap.ParamsEnabled := True;
ABitmap.Params.TIFF_Compression := myTIFFCompression;
ABitmap.Write(FileName);
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
Sidney Egnew
USA
55 Posts |
Posted - May 04 2017 : 00:45:40
|
I scanned the same set of TIFF pages using different compression methods:
183 MB, Uncompressed 35 MB, LZW 4 MB, JPEG 62 MB, PACKBITS JPEG produced the best compression.
The time to scan/compress using Uncompressed, LZW, JPEG were about the same. The time using PACKBITS compression was three times longer than the others.
Images are acquired at different sites and will be written to a network drive for processing. When scanning of a batch is completed, a program will process the images and extract barcodes, MICR, and OCR data. It will then move the files to their permanent storage location.
Compression will reduce the transfer time across the network. Locally, this is insignificant but we have a sometimes unreliable microwave link to one site. Because of this, we suspect compression at the scan site will be beneficial.
Once we have the pages at the server location, they will be processed to extract data. I will be rewriting this program to use IEVision. Can I expect IEVision to see the same quality when processing the compressed files as the uncompressed?
If I understand your components, I can load them and rewrite in any format/compression I want at a later time. Is this correct?
Based on what I have told you, please suggest compression method for each phase: Transfer to Network Drive? OCR/MICR/Barcode Extraction? Transfer to Permanent Storage?
Thanks
|
|
|
xequte
38610 Posts |
Posted - May 04 2017 : 01:56:19
|
Hi Sidney
JPEG is a lossy compression method, so you may get a worse OCR result when using it. Whether the effect is major or negligible will depend on the size of the text in the images (you would need to test to confirm).
Generally, you would be better to use the lossless compression method, which should be LZW.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
xequte
38610 Posts |
Posted - May 04 2017 : 01:58:40
|
> If I understand your components, I can load them and rewrite in any format/compression I want at a later time
Yes, but you need to consider Lossless vs Lossy formats.
When you save to JPEG (or TIFF with JPEG compression) then data is thrown away by the compression algorithm to reduce the size of the file. You could save to a lossless format afterwards (such as PNG), but you can never get back that data that was lost when saving to JPEG.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
Sidney Egnew
USA
55 Posts |
Posted - May 04 2017 : 08:02:06
|
Does LZW affect OCR/MICR/Barcode detection in IEVision?
Would it be better to save uncompressed initially and do the final save as LZW? |
|
|
xequte
38610 Posts |
Posted - May 04 2017 : 16:15:42
|
Hi Sidney
"Lossless" compression means no data is lost when saving. Most save formats are lossless, only JPEG and a few others a lossy.
So whether you saving in a lossless or an uncompressed format makes no difference, because the quality is the same.
IOW, LZW is lossless, so it is fine to save as LZW prior to IEVision usage.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
Sidney Egnew
USA
55 Posts |
Posted - May 04 2017 : 23:16:39
|
Nigel,
I understand LZW and lossless compression. The problem here is that I am having issues with OCR quality. The question is: will recognition improve when I OCR the non-compressed image instead of the LZW image?
Thanks, Sidney |
|
|
xequte
38610 Posts |
Posted - May 04 2017 : 23:31:02
|
No, it will not. The loaded image (i.e. the image in memory) will be identical.
Nigel Xequte Software www.xequte.com nigel@xequte.com
|
|
|
|
Topic |
|