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
 Possible to acquire image with selection ?

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
mastinf Posted - Feb 05 2016 : 07:59:07
What i would like to do is to:

1) acquire a low resolution image from a scanner
2) allow the user to select a rectangle area of the image
3) acquire only the selected area in high resolution.

point 1 and 2 is easy. I see i can activate the selection using the mouseintereact.miselect property (Timagenview component)

But how to accomplish point 3 ?

thanks in advance.

Roberto

Roberto Nicchi
Master Informatica
Italy
9   L A T E S T    R E P L I E S    (Newest First)
mastinf Posted - Feb 10 2016 : 02:14:26
No problems for the demo app. You can make it available for download. I'll post a link also in http://www.imageen.com/ieforum/topic.asp?TOPIC_ID=1446

If i use the epson scan driver works as excepected. If i use the WIA driver "almost" works: the frame is acquired (so i suppose that acquisition frames are supported) but the frame doesn't have the right size (it's much larger in height and width). The position seems correct. Don't know. Maybe it's only a problem with this driver. Anyway i had the same problem with an HP scanner (i have opened another thread about this scanner http://imageen.com/ieforum/topic.asp?TOPIC_ID=2453)

Don't you have an Epson (or hp) scanner to try with ?

thanks

Roberto

Roberto Nicchi
Master Informatica
Italy
xequte Posted - Feb 09 2016 : 22:30:31
Also, your demo is a good one so if you don't mind, I will link to a permanent download:

www.imageen.com/files/other/Scan_Selection.zip

You might want to post a link to it here:

http://www.imageen.com/ieforum/topic.asp?TOPIC_ID=1446



Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
xequte Posted - Feb 09 2016 : 22:25:01
Hi Roberto

I tested it here with a Brother scanner. I got the same result using both the Twain and WIA drivers. Perhaps the device you are using does not support acquisition frames?

Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
mastinf Posted - Feb 09 2016 : 02:01:44
Hello,

i have changed the code as you describe. It doesn't helps, sorry.
I have updated the demo app https://www.dropbox.com/s/dtdo4jfotuegiqb/scan_with_selection.zip?dl=0
Does it works for you there using a WIA driver ?

thanks
Roberto

Roberto Nicchi
Master Informatica
Italy
xequte Posted - Feb 08 2016 : 23:08:07
Hi Roberto

You seem to be setting the Twain params (which only affect Twain), but using the generic acquire (to acquire via Twain or WIA). You should be using the AcquireParams, i.e.

    img.io.AcquireParams.AcquireFrameEnabled:=true;
    img.IO.AcquireParams.AcquireFrameLeft:=l/2.54;
    img.IO.AcquireParams.AcquireFrameTop:=t/2.54;
    img.IO.AcquireParams.AcquireFrameRight:=(l+w)/2.54;
    img.IO.AcquireParams.AcquireFrameBottom:=(t+h)/2.54;
    img.io.AcquireParams.VisibleDialog:=false;

    img.io.Acquire;


Nigel
Xequte Software
www.xequte.com
nigel@xequte.com
mastinf Posted - Feb 08 2016 : 02:33:48
Today i have tried my demo app with a problematic scanner (the hp that is the subject of my other thread http://www.imageen.com/ieforum/topic.asp?TOPIC_ID=2453)
I can't use the HP scanjet driver so i i have used the WIA driver.

Is there a problem with WIA drivers (TWAIN compatibility layer) I still don't have an acquired image corresponding to the selected one. Seems that there's a problem with the WIA drivers (using frames) in Imageen. Is there ? If yes could you please provide a fix ?

Roberto

Roberto Nicchi
Master Informatica
Italy
mastinf Posted - Feb 06 2016 : 09:06:29
I have also created a small demo app (Delphi XE6)
You can download it from dropbox
https://www.dropbox.com/s/dtdo4jfotuegiqb/scan_with_selection.zip?dl=0

thanks

Roberto
P.S. I'm using latest ImageEn version 6.2.1

Roberto Nicchi
Master Informatica
Italy
mastinf Posted - Feb 06 2016 : 08:20:12
I'm very close to finish my custom acquiring form.
Now i have the following problem that don't undestand.

I use the code below to scan the selected area (img is a Timageenview)

I'm doing my test with a Epson WP-4515

If i use the epsonscan driver everything seems to works fine: the acquired image is equal to the sected one. This make me think that my code is correct.
If i use the WIA driver the acquired image doesn't have the correct size and position that has been selected: it's larger and shifted.
What's my mistake ?

thanks in advance

var
  l,t,w,h:double;
    img.io.twainparams.xresolution.currentvalue:=300;
    img.io.twainparams.yresolution.currentvalue:=300;
    img.io.twainparams.bufferedtransfer:=true;

    if show_my_preview_form(l,t,w,h) then // this function open a form where a low dpi scan is made, allow the user to select the area to scan and returns left,top,width and height (in centimeters) of the selected area
    begin
      img.io.TwainParams.AcquireFrameEnabled:=true;
      img.IO.TwainParams.AcquireFrameLeft:=l/2.54; // cm are converted in inches
      img.IO.TwainParams.AcquireFrameTop:=t/2.54;
      img.IO.TwainParams.AcquireFrameRight:=(l+w)/2.54;
      img.IO.TwainParams.AcquireFrameBottom:=(t+h)/2.54;
      img.io.TwainParams.VisibleDialog:=false;
    end
    else abort;
  end;

  img.IO.Acquire;


Roberto Nicchi
Master Informatica
Italy
mastinf Posted - Feb 05 2016 : 09:38:13
Ok i have been able to create something that seems to work.
Have created a preview form with a Timageenview inside (autofit=true, mouseinteract.miselect=true)

In this form i can do a preview using the following code:

img.io.twainparams.xresolution.currentvalue:=72;
      img.io.twainparams.yresolution.currentvalue:=72;
      img.io.TwainParams.VisibleDialog:=false;

      img.IO.Acquire;


Later i ca get the selection size using the SelectedRect property.

In this form i have placed two edit (named width_edit and height_edit) components where the user can type the WIDTH and the HEIGHT of the selection (in centimeters)

I want to show the current height and width of the selection so have defined this event:

procedure Tmypreviewform.imgSelectionChanging(Sender: TObject);
var
  w,h:integer;
begin
  w:=img.SelectedRect.width;
  h:=img.SelectedRect.height;

  jfcform1.BeginAssign;
  try
    width_edit.Value:=(w/72)*2.54;
    height_edit.Value:=(h/72)*2.54;
  finally
    jfcform1.EndAssign;
  end;
end;



The edit components have an onchange event attached that contains the code to update the selection rectangle:

procedure Tmypreviewform.larghezza_editChange(Sender: TObject);
var
  x1,y1,x2,y2:integer;
begin
  x1:=img.SelectedRect.x;
  y1:=img.SelectedRect.y;

  x2:=x1+trunc(width_edit.asvalue*72/2.54);
  y2:=y1+trunc(height_edit.asvalue*72/2.54);

  img.SelectionBase := iesbBitmap;
  img.Select(x1,y1,x2,y2);
end;

I have a small problem that i will try to explain.

If i move the selection using the mouse and the onselectionchange event is fired again the edit components are set with a value that is a bit different from the typed one.

For example, if i type 5 cm, when the rectangle is moved by the mouse the value is changed in 4.97 cm

I would like to avoid this.

Any suggestion ?

thanks