Ok, so I read up on DDTMS and thought that I had them figured out, apparently not
. I can't figure out what I am doing wrong, but the DTM never returns as found. Unfortunately, I don't seem to be able to find any documentation on the FindRotatedDTM function, so I have tried to mimic examples given.
So here is the code I have so far.
SCAR Code:
function getCorrectedCompassAngle(roadColor, tol : Integer) : Extended;
var
RoadCent : TDTMPointDef;
RoadSub : Array[0..6] of TDTMPointDef;
RoadDTMSkel : TDTM;
RoadDTM : Integer;
empty : Integer;
angle : Extended;
begin
Result := 0;
if (findVarrokEastBank) then // Make sure we are near the bank.
begin
RoadCent.x := 619;
RoadCent.y := 46;
RoadCent.areasize := 0;
RoadCent.areashape := 0;
RoadCent.color := roadColor;
RoadCent.tolerance := tol;
RoadSub[0].x := 618;
RoadSub[0].y := 62;
RoadSub[0].areasize := 0;
RoadSub[0].areashape := 0;
RoadSub[0].color := roadColor;
RoadSub[0].tolerance := tol;
RoadSub[1].x := 623;
RoadSub[1].y := 62;
RoadSub[1].areasize := 0;
RoadSub[1].areashape := 0;
RoadSub[1].color := roadColor;
RoadSub[1].tolerance := tol;
RoadSub[2].x := 606;
RoadSub[2].y := 47;
RoadSub[2].areasize := 0;
RoadSub[2].areashape := 0;
RoadSub[2].color := roadColor;
RoadSub[2].tolerance := tol;
RoadSub[3].x := 607;
RoadSub[3].y := 42;
RoadSub[3].areasize := 0;
RoadSub[3].areashape := 0;
RoadSub[3].color := roadColor;
RoadSub[3].tolerance := tol;
RoadSub[4].x := 635;
RoadSub[4].y := 44;
RoadSub[4].areasize := 0;
RoadSub[4].areashape := 0;
RoadSub[4].color := roadColor;
RoadSub[4].tolerance := tol;
RoadSub[5].x := 634;
RoadSub[5].y := 49;
RoadSub[5].areasize := 0;
RoadSub[5].areashape := 0;
RoadSub[5].color := roadColor;
RoadSub[5].tolerance := tol;
RoadSub[6].x := 586;
RoadSub[6].y := 21;
RoadSub[6].areasize := 0;
RoadSub[6].areashape := 0;
RoadSub[6].color := roadColor;
RoadSub[6].tolerance := tol;
RoadDTMSkel.MainPoint := RoadCent;
RoadDTMSkel.SubPoints := RoadSub;
RoadDTM := AddDTM(RoadDTMSkel);
if FindDtmRotated(RoadDTM, empty, empty, MMX1, MMY1, MMX2, MMY2, Radians(-30), Radians(30), 0.005, angle) then
begin
Result := angle;
end else
WriteLn ('didnt find DTM: ' + IntToStr(RoadDTM));
FreeDTM(RoadDTM);
end;
end;
This was called with getCorrectedCompassAngle(FindVarrockRoadColor, 20);
attached is the reference image as well as the DTM that the DDTM was based off of. Any help would be appreciated.
As you could probably tell, the ultimate goal is to try and get a correct compass angle from the startup. I have noticed that the compass can be off by up to 15 degees! (rough guesstimate) and I wanted to use this function to correct that, however, since it never returns true I don't know how I can correctly adjust.
Again, any help would be appreciated, thanks!