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!