ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Problems to acquire multiple images - Scanner Burr

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
mauro.filho Posted - Oct 17 2012 : 15:30:23
Hi,

I'm trying to acquire multiple images with TImageEnMView TImageEnMIO but I'm having a problem.

I use TImageEnMIO.Acquire and it works, but only on the first time, if I try to acquire again, it throws the error:
"First chance exception at $75A4B9BC. Exception class EAccessViolation with message 'Access violation at address 00000000. Read of address 00000000'. Process VivereAgente.exe (5888)"

VivereAgente is my project
I'm using ImageEn v3.1.4

Anybody can help me?

Mauro
11   L A T E S T    R E P L I E S    (Newest First)
fab Posted - Nov 06 2012 : 13:42:35
Mauro,
I re-tested the code in your last email, and it works, even with multiple images (excluding "DTWAIN32" unit, that I don't know what it is...).
Perhaps it is a compatibility problem with your device.
mauro.filho Posted - Oct 30 2012 : 07:37:26
Here is my project, my frm is just a form with a button

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls,
  ImageEnView, IEMIO, ImageEnIO, ieview,iexAcquire, iemview,
  jpeg,
  DTWAIN32;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure ImageEnMIOAfterAcquireBitmap(Sender: TObject; index: Integer);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  ImageEnMIO: TImageEnMIO;
  ImageEnMView: TImageEnMView;
  scanId: integer = 1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

var
   service: string;
   localDPI: integer;
   I: Integer;
   firstScan: Boolean;
begin
     firstScan := false;
     localDPI := 200;

     if ImageEnMIO = nil then
     begin
      firstScan := True;
      ImageEnMIO := TImageEnMIO.Create(Self);
      ImageEnMView := TImageEnMView.Create(Self);
     end;

	   //I tried with AcquireOpen and the result is the same, error.
     //ImageEnMIO.AttachedMView := nil;
     //ImageEnMIO.AcquireOpen;
     ImageEnMIO.AttachedMView := ImageEnMView;
     try
     if firstScan = True then
     begin
        ImageEnMView.Clear;

        ImageEnMIO.OnAfterAcquireBitmap := ImageEnMIOAfterAcquireBitmap;
        ImageEnMIO.AutoAdjustDPI := false;
        ImageEnMIO.FilteredAdjustDPI := false;
        ImageEnMView.DpiX := 200;// localDPI; // in this case localDPI is 200
        ImageEnMView.DpiY := 200; //localDPI;

        with ImageEnMIO.TWainParams do
        begin
			// in this case scanId is 1
             if scanId >= 0 then
             begin
               ImageEnMIO.SetAcquireSource(ieaTwain,scanId) // THE ERROR HAPPENS HERE
             end
             else begin
               ImageEnMIO.TWainParams.SelectedSource := ImageEnMIO.TWainParams.GetDefaultSource;
             end;
             DuplexEnabled := true;//(frenteverso = 'S') And (DuplexSupported);
             BufferedTransfer := true;
             YResolution.CurrentValue := localDPI;
             XResolution.CurrentValue := localDPI;
             ProgressIndicators := false;
             //PixelType.CurrentValue := PIXEL_TYPE;
             VisibleDialog := False;
             AutoScan := True;
        end;

     end; 
        try

          if ImageEnMIO.Acquire then
          begin

          end else begin
            //result := formataErro('Processo cancelado !');
          end;
        except
          //result := formataErro('Processo cancelado !');
        end;
     finally
        if ImageEnMIO <> nil then
        begin          
          //ImageEnMIO.AcquireClose;
          ImageEnMIO.TwainParams.FreeResources;
          FreeAndNil(ImageEnMIO);
        end;

        if ImageEnMView <> nil then
        begin
          FreeAndNil(ImageEnMView);
        end;

    end;

end;


procedure TForm1.ImageEnMIOAfterAcquireBitmap(Sender: TObject; index: Integer);
var
   fstream: TFileStream;
   fileName: string;
   tempFileName: array [0..MAX_PATH-1] of char;
   //imageEn: TImageEnIO;
   //mstream: TMemoryStream;
begin
     if GetTempFileName(PChar('D:\temp\'), 'img_', 0, tempFileName) = 0 then
        raise Exception.Create(SysErrorMessage(GetLastError));

     fileName := stringReplace(tempFileName, extractFileExt(tempFileName), '.jpg', [rfReplaceAll]);

     with TJPEGImage.Create do
     begin
          try
             Assign(ImageEnMView.GetBitmap(index));
             CompressionQuality := 50;

             fstream := TFileStream.Create(fileName, fmCreate);
             try
                SaveToStream(fstream);
             finally
                fstream.Free
             end;

             //SetResJpg(fileName, 150, 150);

             //setImagens(fileName, qtdImagens);
             //qtdImagens := (qtdImagens + 1);

             SysUtils.DeleteFile(tempFileName);
          finally
            ImageEnMView.ClearImageCache(index);
            free;
          end;
     end;
end;

end.
fab Posted - Oct 28 2012 : 00:00:45
Giancarlo,
you should not insert Acquire between AcquireOpen/AcquireClose.
AcquireOpen/AcquireClose are intended only to allow user to acquire multiple pages maintaining the scanner dialog open.
Acquire call should stay alone.
fab Posted - Oct 27 2012 : 23:59:28
Mauro, please could you send me your (new) project?
giancarlo Posted - Oct 24 2012 : 05:16:56
I have the same problem.
The first time I acquire multiple page is ok, but if I recall a new acquire, i get the error:
"Access violation at address 00000000. Read of address 00000000"

My code is very simple:
ImageEnIO1.AcquireOpen;
ImageEnIO1.Acquire();
FORM2.ShowModal;//just to show "please wait"
ImageEnIO1.AcquireClose;

with the step-debugger i've notice the exception is on IMSCAN.PAS on row 1276:
if (fBitmap.Width <> IOParams.Width) or (fBitmap.Height <> IOParams.Height) or (fBitmap.PixelFormat <> pixfor) then
fBitmap.allocate(IOParams.Width, IOParams.Height, pixfor);

someone can help me?
thank you
mauro.filho Posted - Oct 22 2012 : 04:58:28
Hi Frabrizio, thanks for your help,

but, the error is the same.
I created a new project with your code, changing de scanID to 1 and adding the uses

"ImageEnView, IEMIO, ImageEnIO, ieview,iexAcquire, iemview, jpeg"

In the first acquire it works, but, if I try acquire again...

Do you have de the Burroughs Smart Source scanner?

I don't know if the following log can help.

Debug Output: TWAIN(DG_IMAGE, DAT_IMAGEMEMXFER, MSG_GET) Process Project1.exe (4664)
Debug Output: = TWRC_XFERDONE Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_CAPABILITY, MSG_GET, CAP_CAPTION) Process Project1.exe (4664)
Debug Output: = TWRC_FAILURE Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_PENDINGXFERS, MSG_ENDXFER) Process Project1.exe (4664)
Debug Output: = TWRC_SUCCESS Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT) Process Project1.exe (4664)
Debug Output: = TWRC_NOTDSEVENT Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT) Process Project1.exe (4664)
Debug Output: = TWRC_NOTDSEVENT Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT) Process Project1.exe (4664)
Debug Output: = TWRC_NOTDSEVENT Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_EVENT, MSG_PROCESSEVENT) Process Project1.exe (4664)
Debug Output: = TWRC_NOTDSEVENT Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_USERINTERFACE, MSG_DISABLEDS) Process Project1.exe (4664)
Debug Output: = TWRC_FAILURE Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS) Process Project1.exe (4664)
Debug Output: = TWRC_FAILURE Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_STATUS, MSG_GET) Process Project1.exe (4664)
Debug Output: = TWRC_SUCCESS Process Project1.exe (4664)
Debug Output: TWAIN(DG_CONTROL, DAT_IDENTITY, MSG_CLOSEDS) Process Project1.exe (4664)
Debug Output: = TWRC_FAILURE Process Project1.exe (4664)
Thread Exit: Thread ID: 5704. Process Project1.exe (4664)
Module Unload: DCIMAN32.dll. Process Project1.exe (4664)
Thread Exit: Thread ID: 5152. Process Project1.exe (4664)
Module Unload: gdiplus.dll. Process Project1.exe (4664)
Thread Exit: Thread ID: 4556. Process Project1.exe (4664)
Thread Exit: Thread ID: 5708. Process Project1.exe (4664)
Thread Exit: Thread ID: 252. Process Project1.exe (4664)
Thread Exit: Thread ID: 5244. Process Project1.exe (4664)
Module Load: gdiplus.dll. No Debug Info. Base Address: $739A0000. Process Project1.exe (4664)
Thread Start: Thread ID: 3924. Process Project1.exe (4664)
Module Load: DCIMAN32.dll. No Debug Info. Base Address: $6E640000. Process Project1.exe (4664)
Thread Start: Thread ID: 4680. Process Project1.exe (4664)
First chance exception at $768CB9BC. Exception class EAccessViolation with message 'Access violation at address 60FB7941 in module 'TWAIN_32.DLL'. Read of address FEEEFEF6'. Process Project1.exe (4664)
Thread Exit: Thread ID: 5164. Process Project1.exe (4664)

With the tester http://www.softpedia.com/get/System/System-Info/TwainTester.shtml it works, so I think that the scanner driver is OK

Thanks a lot for your help
fab Posted - Oct 20 2012 : 01:17:48
In order to replicate this problem I have rewritten your code, to be compilable without other dependences.

In my tests it works, even executing Button1Click more than one time. Could you try this code, just to see if the problem comes from interactions with other parts?

Please look at this:

var
  ImageEnMIO: TImageEnMIO;
  ImageEnMView: TImageEnMView;
  scanId: integer = 2;

procedure TForm1.Button1Click(Sender: TObject);
var
   service: string;
   localDPI: integer;
   I: Integer;
   firstScan: Boolean;
begin
     firstScan := false;

     if ImageEnMIO = nil then
     begin
      firstScan := True;
      ImageEnMIO := TImageEnMIO.Create(Self);
      ImageEnMView := TImageEnMView.Create(Self);
     end;

	   //I tried with AcquireOpen and the result is the same, error.
     //ImageEnMIO.AttachedMView := nil;
     //ImageEnMIO.AcquireOpen;
     ImageEnMIO.AttachedMView := ImageEnMView;
     try
     if firstScan = True then
     begin
        ImageEnMView.Clear;

        ImageEnMIO.OnAfterAcquireBitmap := ImageEnMIOAfterAcquireBitmap;
        ImageEnMIO.AutoAdjustDPI := false;
        ImageEnMIO.FilteredAdjustDPI := false;
        ImageEnMView.DpiX := 200;// localDPI; // in this case localDPI is 200
        ImageEnMView.DpiY := 200; //localDPI;

        with ImageEnMIO.TWainParams do
        begin
			// in this case scanId is 1
             if scanId >= 0 then
             begin
               ImageEnMIO.SetAcquireSource(ieaTwain,scanId) // THE ERROR HAPPENS HERE
             end
             else begin
               ImageEnMIO.TWainParams.SelectedSource := ImageEnMIO.TWainParams.GetDefaultSource;
             end;
             DuplexEnabled := true;//(frenteverso = 'S') And (DuplexSupported);
             BufferedTransfer := true;
             YResolution.CurrentValue := localDPI;
             XResolution.CurrentValue := localDPI;
             ProgressIndicators := false;
             //PixelType.CurrentValue := PIXEL_TYPE;
             VisibleDialog := False;
             AutoScan := True;
        end;

     end; 
        try

          if ImageEnMIO.Acquire then
          begin

          end else begin
            //result := formataErro('Processo cancelado !');
          end;
        except
          //result := formataErro('Processo cancelado !');
        end;
     finally
        if ImageEnMIO <> nil then
        begin          
          //ImageEnMIO.AcquireClose;
          ImageEnMIO.TwainParams.FreeResources;
          FreeAndNil(ImageEnMIO);
        end;

        if ImageEnMView <> nil then
        begin
          FreeAndNil(ImageEnMView);
        end;

    end;
end;

procedure TForm1.ImageEnMIOAfterAcquireBitmap(Sender: TObject; index: Integer);
var
   fstream: TFileStream;
   fileName: string;
   tempFileName: array [0..MAX_PATH-1] of char;
   //imageEn: TImageEnIO;
   //mstream: TMemoryStream;
begin
     if GetTempFileName(PChar('c:\'), 'img_', 0, tempFileName) = 0 then
        raise Exception.Create(SysErrorMessage(GetLastError));

     fileName := stringReplace(tempFileName, extractFileExt(tempFileName), '.jpg', [rfReplaceAll]);

     with TJPEGImage.Create do
     begin
          try
             Assign(ImageEnMView.GetBitmap(index));
             CompressionQuality := 50;

             fstream := TFileStream.Create(fileName, fmCreate);
             try
                SaveToStream(fstream);
             finally
                fstream.Free
             end;

             //SetResJpg(fileName, 150, 150);

             //setImagens(fileName, qtdImagens);
             //qtdImagens := (qtdImagens + 1);

             SysUtils.DeleteFile(tempFileName);
          finally
            ImageEnMView.ClearImageCache(index);
            free;
          end;
     end;
end;
mauro.filho Posted - Oct 18 2012 : 11:15:42
In my test I'm trying to scan a block of 3 sheets twice without closing the application.
My app is started like a server and receives the command by http request, and stays all of the time started.
I think the AutoScan property don't stops after the acquire and if I try acquire again the following exception is throwed
First chance exception at $75B6B9BC. Exception class EAccessViolation with message 'Access violation at address 72787941 in module 'TWAIN_32.DLL'. Read of address 00000008'. Process VivereAgente.exe (4044)

- the Delphi version - Delphi 11
- the operating system (version and bits) - Windows 7 - 64bits
- scanner model - Burroughs SmartSource Adaptive - SSA1307030-PKG
- the code you use in order to scan:



//I put here just the relevant code

procedure TfrmAgent.IdHTTPServerCommandGet(AContext: TIdContext;
  ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);
var
   action: string;
   server: string;
   retorno : string;
begin
     if isBusy then
     begin
          AResponseInfo.ContentText := '<response><error><message>Vivere Agente ocupado.</message></error></response>';
          exit;
     end;

     try
        try
			isBusy := True;
           AResponseInfo.ContentText := batchCapture();
        except
              isBusy := false;
        end;
     finally
        isBusy := false;
        Sair.enabled := true;
        Sobre.enabled := true;

     end;
end;
			   
function TfrmAgent.batchCapture: string;
var
   service: string;
   localDPI: integer;
   I: Integer;
   firstScan: Boolean;
begin
     firstScan := false;
     
     if ImageEnMIO = nil then
     begin
      firstScan := True;
      ImageEnMIO := TImageEnMIO.Create(Self);
      ImageEnMView := TImageEnMView.Create(Self);
     end;
     UploadManager := TUpload.Create(True);

     UploadManager.service := service;
     UploadManager.FreeOnTerminate := True;
     UploadManager.Resume;
     UploadManager.etiqueta := nrEtiqueta;
	 //I tried with AcquireOpen and the result is the same, error.
     //ImageEnMIO.AttachedMView := nil;
     //ImageEnMIO.AcquireOpen;
     ImageEnMIO.AttachedMView := ImageEnMView;
     try
     if firstScan = True then
     begin        
        ImageEnMView.Clear;

        ImageEnMIO.OnAfterAcquireBitmap := ImageEnMIOAfterAcquireBitmap;
        ImageEnMIO.AutoAdjustDPI := false;
        ImageEnMIO.FilteredAdjustDPI := false;
        ImageEnMView.DpiX := localDPI; // in this case localDPI is 200
        ImageEnMView.DpiY := localDPI;

        with ImageEnMIO.TWainParams do
        begin
			// in this case scanId is 1
             if scanId >= 0 then
             begin
               ImageEnMIO.SetAcquireSource(ieaTwain,scanId) // THE ERROR HAPPENS HERE
             end
             else begin
               ImageEnMIO.TWainParams.SelectedSource := ImageEnMIO.TWainParams.GetDefaultSource;
             end;
             DuplexEnabled := (frenteverso = 'S') And (DuplexSupported);
             BufferedTransfer := true;
             YResolution.CurrentValue := localDPI;
             XResolution.CurrentValue := localDPI;
             ProgressIndicators := false;
             PixelType.CurrentValue := PIXEL_TYPE;
             //AutoFeed := True;
             //FeederEnabled := True;
             VisibleDialog := False;
             AutoScan := True;
        end;

     end; 
        try

          if ImageEnMIO.Acquire do
          begin
		     // my application upload the imagens after acquired
			 // this block code control the upload process. UploadManager is a kind of listener that upload all the images acquired
			 // this works fine without AutoScan, and this scanner don't works whit AutoFeed
             UploadManager.totalImagens := qtdImagens;
             UploadManager.indiceDigitalizacao := qtdImagens;

             while UploadManager.status <> 'C' do // after upload Upload manager set to 'C' this variable
                qtdImagens := qtdImagens;
             for I := ultimaCarregada to qtdImagens do
             begin
                UploadManager.imagens[I, 0] := imagens[I, 0];
                UploadManager.imagens[I, 1] := 'N';
                imagens[I, 1] := 'S';
             end;
             UploadManager.totalImagens := qtdImagens;
             UploadManager.indiceDigitalizacao := qtdImagens - 1;
             UploadManager.status := 'P'; // Libera para Processamento

             while not UploadManager.finalizado do
                qtdImagens := qtdImagens;}
          end else begin
            result := formataErro('Processo cancelado !');
          end;
        except
          result := formataErro('Processo cancelado !');
        end;
     finally
        if ImageEnMIO <> nil then
        begin          
          //ImageEnMIO.AcquireClose;
          ImageEnMIO.TwainParams.FreeResources;
          FreeAndNil(ImageEnMIO);
        end;

        if ImageEnMView <> nil then
        begin
          FreeAndNil(ImageEnMView);
        end;

    end;
end;

procedure TfrmAgent.ImageEnMIOAfterAcquireBitmap(Sender: TObject; index: Integer);
var
   fstream: TFileStream;
   fileName: string;
   tempFileName: array [0..MAX_PATH-1] of char;
   //imageEn: TImageEnIO;
   //mstream: TMemoryStream;
begin
     if GetTempFileName(PChar(GetTempDir), 'img_', 0, tempFileName) = 0 then
        raise Exception.Create(SysErrorMessage(GetLastError));

     fileName := stringReplace(tempFileName, extractFileExt(tempFileName), '.jpg', [rfReplaceAll]);

     with TJPEGImage.Create do
     begin
          try
             Assign(ImageEnMView.GetBitmap(index));
             CompressionQuality := 50;

             fstream := TFileStream.Create(fileName, fmCreate);
             try
                SaveToStream(fstream);
             finally
                fstream.Free
             end;

             SetResJpg(fileName, 150, 150);

             setImagens(fileName, qtdImagens);
             qtdImagens := (qtdImagens + 1);

             SysUtils.DeleteFile(tempFileName);
          finally
            ImageEnMView.ClearImageCache(index);
            free;
          end;
     end;
end;


PS: My english is not good, I'm sorry by my grammar errors
fab Posted - Oct 18 2012 : 10:12:21
Please let me know also:
- the Delphi version
- the operating system (version and bits)
- scanner model
- the code you use in order to scan
mauro.filho Posted - Oct 18 2012 : 04:00:33
Sorry,

The version is 4.1.3
fab Posted - Oct 17 2012 : 15:41:15
Hi,
please could you test 4.x versions?
BTW: 3.1.4 doesn't exist.