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
 Image Measurement / Calibrate issue

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
DMC02766 Posted - Jun 11 2015 : 08:08:18
Hi-
> I am currently using the measureit demo as a base in order to calibrate build some functionality to calibrate images. I first click a button (button3) which sets the mouseinteract as miselect to select an area (1 cm on a picture of a ruler) then on the selectionchange I have it setscalefrompixels although whenever I select the area it always comes up as value 89.10 as the pixel length (I have a label that displays the pixels value from the selection) and the measurement is wrong on the value of midraglen measurement line because of this. But when I select the area a second time it works correctly. I feel like its something small that I am missing but I just cant figure out what it is. So to get it to work I go through these steps as of right now:

1. Click button3 then select a 1 cm section on an image of a ruler.
2. The on selection change then displays the selected pixels per cm on a label (there are also other calculations that take place for calibrating the image in the code although this is where the issue appears to be). It comes up with 89.10 every time I select it the first time no matter what I select.
3. If I was to select again without dragging at this point it would show up as 89.10 every time I select an area, although if I drag a length after the initial selection (it shows the wrong lengths) but then click the button3 to select the area a second time it will then select and show the correct amount of pixels and thus when I drag following the second selection it will show the correct length.

Below is the code:


 procedure Tfrm_orientation.Button3Click(Sender: TObject);  var
    r: TRect;
 
 
 begin
 ImageEnView2.MouseInteract := [miselect]; label25.caption :=('--'); 
 label25.caption :=('Please select 1 cm');
 
 
 end;
 
 
 procedure Tfrm_orientation.ImageEnview2SelectionChange(Sender:
 TObject); 
var
   lx, ly: double;
   r: TRect;
   lenp: double;
   pixnum: integer;
 restocm:double;
 pixnuminc:double;
 pixnuminc1:string;
 
 begin 
 
imageenview2.GetObjrect(Imageenview2.SelObjects[0], r);  
lx := abs(r.Right-r.Left);  ly := abs(r.Bottom-r.Top); 
lenp := sqrt(lx * lx  + ly* ly);
pixnum:= Trunc(lenp);
pixnuminc:= (pixnum * 2.5);
pixnuminc1:=  inttostr(round(pixnuminc));
imageenview2.MUnit := ieuCentimeters;  
ImageEnview2.SetScaleFrompixels(pixnum,1);
lblpixel.Caption := floattostrf(lenp, ffnumber,  8,2);
edit1.Text := inttostr(pixnum);
edit2.Text := (pixnuminc1);
lblheight.Caption := inttostr(imageenview2.IO.Params.height);
lblwidth.Caption := inttostr(imageenview2.io.Params.width);
restocm :=  (imageenview2.IO.params.dpi / 2.54);
lblresolutioncm1.Caption := floattostrf(restocm, ffnumber, 8, 2  );
lblresolution2.Caption := inttostr(imageenview2.IO.params.dpi);
ImageEnView2.MouseInteractVt := [miDragLen];
 imageenview2.deselect;
 
end;
 


Thanks in advance- any help would be greatly appreciated!
2   L A T E S T    R E P L I E S    (Newest First)
DMC02766 Posted - Jun 11 2015 : 15:02:14
That did it! I cannot thank you enough for your help on this! I have been scratching my head all week on this one.
w2m Posted - Jun 11 2015 : 11:57:39
In your example there are no objects, but you use GetObjRect to get the rect. GetObjRect returns the coordinates of hobj object not the coordinates of the selection. You should use SelectedRect to get a rect based on selections not objects.
var
iIERect: TIERectangle;
...
  {ImageEnVect1.GetObjrect(ImageEnVect1.SelObjects[0], r); Do not use this }
  { instead use SelectedRect }
  iIERect := ImageEnVect1.SelectedRect;
  {SelectedRect returns current selected rectangle.}
  lx := abs(iIERect.Width);
  ly := abs(iIERect.Height);
...


You always get the same value when you use ImageEnVect1.GetObjrect(ImageEnVect1.SelObjects[0], r) because there are no ImageEn objects on the image.

Bill Miller
Adirondack Software & Graphics
Email: w2m@hughes.net
EBook: http://www.imageen.com/ebook/
Custom Commercial ImageEn Development