T O P I C R E V I E W |
lorife |
Posted - Jan 04 2022 : 12:13:11 Hello, I'm trying your ImageEN DEMO. I need to open a PDF, and extract first 2 pages to another pdf. This is what i'm doing:
IEGlobalSettings().RegisterPlugIns([ iepiPDFium ]);
iev_IN.PdfViewer.Enabled := True;
iev_IN.ClearAll;
iev_IN.IO.Params.ImageIndex := 0;
iev_IN.IO.LoadFromFile('c:\temp\IN.pdf');
iemv_OUT.AppendImage;
iemv_OUT.SetImage(iemv_OUT.SelectedImage, iev_IN.IEBitmap);
iev_IN.IO.Params.ImageIndex := 1;
iev_IN.IO.LoadFromFile('c:\temp\IN.pdf');
iemv_OUT.AppendImage;
iemv_OUT.SetImage(iemv_OUT.SelectedImage, iev_IN.IEBitmap);
iemv_OUT.MIO.SaveToFile('c:\temp\OUT.pdf');
it works, but the resulting file is all blurried, not sharp. If i load a tif and export to PDF the resulting file is perfect.
do you have any idea on why? thank you
|
20 L A T E S T R E P L I E S (Newest First) |
lorife |
Posted - Feb 14 2022 : 03:21:51 ok thanks for the explanation. |
xequte |
Posted - Feb 12 2022 : 19:50:40 No, it's probably fine.
Let's say you have an image in TImageEnView that you want to modify and then revert. Options are:
1. Save Undo > Modify > Undo
or
2. Assign to Temp > Modify > Free
Both will create a second image in memory. Option 1 does twice as much work (excluding the modify). However there are other factors that make it not so clean cut, code readability, for e.g., Option 2 requires creating a temp bitmap and/or a temp TImageEnProc, so the code won't be quite as tidy.
Nigel Xequte Software www.imageen.com
|
lorife |
Posted - Feb 12 2022 : 18:23:26 I add the image to the mview only if it passes some analysis..so at that moment I don't have it there yet. But you're right i might try something else. Thanks |
xequte |
Posted - Feb 12 2022 : 18:05:44 Hi
Saving an undo and then reverting it is fine. There is some cost to it of course, anther image is stored in memory and it takes some time to revert (Undo). So you would only do it that way if you needed the original image afterwards. As the image is stored in the TImageEnMView, I can't see why you need the original image restored in your TImageEnView, but I don't know your whole process, so you may have a valid reason.
Nigel Xequte Software www.imageen.com
|
lorife |
Posted - Feb 12 2022 : 01:42:42 1. I have tried DTK which has many options and it works great. Also you can apply some filters and sometimes they made a difference.
2. Isn't that what i do? I discard all the changes. If not, could you explain me why it's wrong?
Thanks |
xequte |
Posted - Feb 12 2022 : 00:17:03 Hi Lorenzo
1. Sorry, I only checked that the bar codes were read, not their validity.
It is on our to-do list to use a different bar code engine. Our present one has some accuracy issues. In the meantime, you should use a higher resolution source image.
2. If you want to apply a filter to a bar code image before scanning it (and I've not heard of this being effective), you should just apply the filter to a temporary bitmap and then discard it.
Nigel Xequte Software www.imageen.com
|
lorife |
Posted - Feb 11 2022 : 03:37:47 Hello, thank you for writing back and sorry about answering on the mail, I'm replying here what we talked on the mail:
1. Why do you say the barcodes you read are correct? the first one is 22030005 the second is 220300059960. First one is trimmed, they are the same barcode. Using another library are read correctly. Is there something you can do to optimize reading? I don't know, applying some filter before reading? I really need this to be reliable
2. Regarding the idea of applying a filter before reading the barcode what do you think abou this approach? Let's say I would like to apply 3 filters before reading the barcode (to help it reading) but I want to save the original page, could this be a correct way of doing it (I'm referring to undo)?
for pageNumber := 0 to totalPages -1
begin
.. load the page
iev_IN.Proc.SaveUndo;
.. apply some filters
.. read barcodes..
iev_IN.Proc.Undo();
.. append bitmap to imageenMview
end;
.. save imageenMview to file
thank you
|
xequte |
Posted - Feb 07 2022 : 23:45:01 Hi Lorenzo
I've responded to your message.
Please remember that if you want to load images (or PDF files as images) you need to disable the PDF Viewer:
ImageEnView1.PdfViewer.Enabled := False;
Nigel Xequte Software www.imageen.com
|
lorife |
Posted - Feb 07 2022 : 12:36:16 Hello, for some reson I cannot reproduce nr. 1 anymore. I will let you know if it comes up again. Also, I have sent you an email with some of the problems I'm facing. Could you please help me out? Thanks |
xequte |
Posted - Feb 01 2022 : 20:50:01 1. I can't reproduce that. Is there any content in the TImageEnView (e.g. layers). What version of Delphi are you using? 32bit or 64bit apps. What happens if you remove iev_IN.ClearAll; (which should not be necessary). Do you want to send me your PDF test file?
2. It really depends on your purpose. If you just want higher resolution when exporting, use PdfViewerDefaults.DPI. If you want a specific size, use DrawTo with params()
3. Well, for most purposes A4 is meaningless when it comes to images. But let's assume you want to print 1:1 at A4 size. That would mean your image would need to be 8.25 x 11.75 in (Again these are printing value, not image values). If your image is 96dpi, then your pixel size would need to be scaled to 792x1128 pixels. Alternatively, you could just adjust your DPI, which for an 1194*1684 image would need to be 144
for i := 0 to iemv_OUT.Count - 1 do
iemv_OUT.MIO.Params[i].DPI := 144;
Nigel Xequte Software www.imageen.com
|
lorife |
Posted - Feb 01 2022 : 05:48:38 Hello, I confirm that using:
IEGlobalSettings().PdfViewerDefaults.DPI := 144;
produces very good results with image quality and barcode recognition. However I have some things to ask:
1. FIRST NOTE: Launching this code for many pages produces an access violation at the 3rd time.
IEGlobalSettings().PdfViewerDefaults.DPI := 144;
iev_IN.ClearAll; <-- here is the AV
iev_IN.IO.Params.ImageIndex := idx;
iev_IN.IO.LoadFromFilePDF(FullPathIN);
idx := iemv_OUT.AppendImage(0, 0, ie24RGB);
bmp := iemv_OUT.GetTIEBitmap(idx);
iev_IN.PdfViewer.DrawTo(bmp, 2000, 2000, true);
iemv_OUT.ReleaseBitmap(idx, True);
however this works:
iev_IN.ClearAll;
iev_IN.IO.Params.ImageIndex := idx;
iev_IN.IO.LoadFromFilePDF(FullPathIN);
idx := iemv_OUT.AppendImage(0, 0, ie24RGB);
bmp := iemv_OUT.GetTIEBitmap(idx);
iev_IN.PdfViewer.DrawTo(bmp, 2000, 2000, true);
iemv_OUT.ReleaseBitmap(idx, True);
and this too:
IEGlobalSettings().PdfViewerDefaults.DPI := 144;
iev_IN.ClearAll;
iev_IN.IO.Params.ImageIndex := idx;
iev_IN.IO.LoadFromFilePDF(FullPathIN);
bmp := iev_IN.IEBitmap;
idx := iemv_OUT.AppendImage;
iemv_OUT.SetImage(idx, bmp);
1. SECOND NOTE:
now that i can use this:
IEGlobalSettings().PdfViewerDefaults.DPI := 144;
this code works great and quality is ok:
bmp := iev_IN.IEBitmap;
idx := iemv_OUT.AppendImage;
iemv_OUT.SetImage(idx, bmp);
so I guess i'll stick with it, there's no need to use the other method where I can specify the size. Is it correct?
3. THIRD NOTE:
Please help me understand this. If I try to read a pdf and write a tif with this:
iemv_OUT.MIO.Params[0].PDF_Compression := TIOPDFCompression.ioPDF_JPEG;
iemv_OUT.MIO.Params[0].PDF_PaperSize := TIOPDFPaperSize.iepA4;
iemv_OUT.MIO.Params[0].TIFF_Compression := TIOTIFFCompression.ioTIFF_JPEG;
iemv_OUT.MIO.DuplicateCompressionInfo();
I have a good quality file, however it's bigger than a4 and the pages are 1194*1684 pixel. I would like to resize the images on each page so that it fit into an A4. How can I do that? I tried
iev_IN.Proc.Resample(1000, 1000, TResampleFilter.rfFastLinear, true); but 1000 probably it's not enough and it gets blurried. Also I would like to shrink only bigger images, not make smaller images bigger.
thank you |
xequte |
Posted - Jan 29 2022 : 17:35:31 I use the BMP to get a better quality rasterization of the PDF page (at size 2000x2000) as the default size is too low quality.
However you can achieve the same effect in the current beta by increasing the DPI:
IEGlobalSettings().PdfViewerDefaults.DPI := 144;
Nigel Xequte Software www.imageen.com
|
lorife |
Posted - Jan 29 2022 : 17:20:35 Hello, I have asked for the version in the mail.
Menwhile, I have a question. I was doing this when it was not working:
iev_IN.PdfViewer.Enabled := True;
iev_IN.IO.LoadFromFilePDF(FullPathIN)
var selRect := IEVisionRect(0, 0, 0, 0);
var m_symbols := IEVisionLib.createBarCodeScanner().scan(iev_IN.IEBitmap.GetIEVisionImage(), selRect);
However you did this:
iev_IN.PdfViewer.Enabled := True;
iev_IN.IO.LoadFromFilePDF(FullPathIN)
bmp := TIEBitmap.Create;
ImageEnView1.PdfViewer.DrawTo( bmp, 2000, 2000, True );
var selRect := IEVisionRect(0, 0, 0, 0);
var m_symbols := IEVisionLib.createBarCodeScanner().scan(bmp.GetIEVisionImage(), selRect);
bmp.free
But I'm asking, as I already load each page into ImageEn, do I really have to draw to another bmp each page to read the barcode? thanks |
xequte |
Posted - Jan 28 2022 : 23:36:54 Also, in the next release you can double the resolution (apparent size on screen and size of created bitmap) using IEGlobalSettings().PdfViewerDefaults.DPI.
Loading your PDF into the bar code demo successfully detects it using the following:
IEGlobalSettings().PdfViewerDefaults.DPI := 144; // Double the PDF resolution
ImageEnView1.PdfViewer.Enabled := True;
ImageEnView1.PdfViewer.AutoSync := True;
ImageEnView1.IO.LoadFromFilePDF( 'D:\in.pdf' );
You can email me if you want to test this update.
Nigel Xequte Software www.imageen.com
|
xequte |
Posted - Jan 28 2022 : 23:22:47 Hi
The issue here will be that the sync'ed bitmap of PDFViewer will be too low quality for good bar code detection, so you should draw to a bitmap at a larger size.
This works for me:
procedure TMainForm.Button2Click(Sender: TObject);
var
s: TIEVisionBarCodeSymbol;
i: integer;
selRect: TIEVisionRect;
n: TTreeNode;
data: string;
bmp: TIEBitmap;
begin
bmp := TIEBitmap.Create;
try
TreeViewResults.Items.Clear();
ImageEnView1.PdfViewer.DrawTo( bmp, 2000, 2000, True );
selRect := IEVisionRect(0, 0, 0, 0);
m_symbols := IEVisionLib.createBarCodeScanner().scan( bmp.GetIEVisionImage(), selRect );
for i := 0 to m_symbols.size() - 1 do
begin
n := TreeViewResults.Items.AddChild(nil, IntToStr(i));
s := TIEVisionBarCodeSymbol( m_symbols.getObj(i) );
TreeViewResults.Items.AddChild(n, s.getSymbolType().c_str());
data := s.getData().c_str();
// Get rid of any hard returns (for display)
data := StringReplace( data, #13#10, '/', [rfReplaceAll] );
TreeViewResults.Items.AddChild( n, data );
if CheckBoxShowConfidence.Checked then
TreeViewResults.Items.AddChild(n, Format('Confidence: %d', [s.getQuality()]));
end;
finally
bmp.Free;
end;
end;
Nigel Xequte Software www.imageen.com
|
lorife |
Posted - Jan 28 2022 : 06:14:47 Hello, Ok thanks.
Now I'm trying to read barcodes in the file. So, I load the file into imageen then:
selRect := IEVisionRect(0, 0, 0, 0);
m_symbols := IEVisionLib.createBarCodeScanner().scan(iev_IN.IEBitmap.GetIEVisionImage(), selRect); However it does not find anything.
Could you try with the demo I sent you? In the first page there's a barcode, why doesn't int work?
thanks |
xequte |
Posted - Jan 24 2022 : 18:05:28 Thanks, I've reviewed the project.
Quality is good and as expected when saving to image format.
Unfortunately the blurriness when viewing PDF files created in this manner is due to the way PDF saving is handled in ImageEn and the scaling of images by PDF viewers.
Nigel Xequte Software www.imageen.com
|
lorife |
Posted - Jan 24 2022 : 05:55:08 Hello, I have sent you a demo project. |
xequte |
Posted - Jan 23 2022 : 23:11:26 -1 will use the reported size of the PDF, which will look low quality if you enlarge the generated image. The best values to pass depend on your desired usage, e.g. if they are just for displaying on screen, then 2 x screen size might be good.
Can you please attach/link to your source PDF, the bmp you get from DrawTo( bmp, 2000, 2000, true ), and the output PDF, so I can see what you are seeing?
Nigel Xequte Software www.imageen.com
|
lorife |
Posted - Jan 21 2022 : 05:03:40 Hello, thanks.
Please don't hate me...
so I tried:
iev_IN.PdfViewer.DrawTo( bmp, -1, -1, true ); and the output file was in bad quality. then I tried:
iev_IN.PdfViewer.DrawTo( bmp, 2000, 2000, true ); and the quality is better but still a little blurried. So I'm asking: 1. If I leave -1 shouldn't it use the maximum quality 2. what numbers should i write for height and width to achieve a good quality? Please note i'm still not compressing anything, the only code is this:
IEGlobalSettings().RegisterPlugIns([ iepiPDFium ]);
iev_IN.PdfViewer.Enabled := True;
iev_IN.IO.Params.ImageIndex := 0;
iev_IN.IO.LoadFromFilePDF('c:\temp\OBR\S30C-921122015230.pdf');
bmp := TIEBitmap.create();
iev_IN.PdfViewer.DrawTo( bmp, 2000, 2000, true );
iemv_OUT.AppendImage( bmp );
bmp.Free;
iemv_OUT.MIO.SaveToFile('c:\temp\OUT.pdf');
thanks |
|
|