diff --git a/Source/script/imports/simba.import_matrix.pas b/Source/script/imports/simba.import_matrix.pas index 4e70fa21b..78e6e9089 100644 --- a/Source/script/imports/simba.import_matrix.pas +++ b/Source/script/imports/simba.import_matrix.pas @@ -26,7 +26,7 @@ implementation TIntegerMatrix.Width -------------------- ``` -function TIntegerMatrix.Width: Integer; +property TIntegerMatrix.Width: Integer; ``` *) procedure _LapeIntegerMatrix_Width(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -38,7 +38,7 @@ procedure _LapeIntegerMatrix_Width(const Params: PParamArray; const Result: Poin TIntegerMatrix.Height --------------------- ``` -function TIntegerMatrix.Height: Integer; +property TIntegerMatrix.Height: Integer; ``` *) procedure _LapeIntegerMatrix_Height(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -47,27 +47,27 @@ procedure _LapeIntegerMatrix_Height(const Params: PParamArray; const Result: Poi end; (* -TIntegerMatrix.SetSize ----------------------- +TIntegerMatrix.Area +------------------- ``` -procedure TIntegerMatrix.SetSize(Width, Height: Integer); +property TIntegerMatrix.Area: Integer; ``` *) -procedure _LapeIntegerMatrix_SetSize(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +procedure _LapeIntegerMatrix_Area(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PIntegerMatrix(Params^[0])^.SetSize(PInteger(Params^[1])^, PInteger(Params^[2])^); + PInteger(Result)^ := PIntegerMatrix(Params^[0])^.Area; end; (* -TIntegerMatrix.Area -------------------- +TIntegerMatrix.SetSize +---------------------- ``` -function TIntegerMatrix.Area: Integer; +procedure TIntegerMatrix.SetSize(NewWidth, NewHeight: Integer); ``` *) -procedure _LapeIntegerMatrix_Area(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +procedure _LapeIntegerMatrix_SetSize(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV begin - PInteger(Result)^ := PIntegerMatrix(Params^[0])^.Area(); + PIntegerMatrix(Params^[0])^.SetSize(PInteger(Params^[1])^, PInteger(Params^[2])^); end; (* @@ -194,7 +194,7 @@ procedure _LapeIntegerMatrix_Copy2(const Params: PParamArray; const Result: Poin TBooleanMatrix.Width -------------------- ``` -function TBooleanMatrix.Width: Integer; +property TBooleanMatrix.Width: Integer; ``` *) procedure _LapeBooleanMatrix_Width(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -206,7 +206,7 @@ procedure _LapeBooleanMatrix_Width(const Params: PParamArray; const Result: Poin TBooleanMatrix.Height --------------------- ``` -function TBooleanMatrix.Height: Integer; +property TBooleanMatrix.Height: Integer; ``` *) procedure _LapeBooleanMatrix_Height(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -215,27 +215,28 @@ procedure _LapeBooleanMatrix_Height(const Params: PParamArray; const Result: Poi end; (* -TBooleanMatrix.SetSize ----------------------- +TBooleanMatrix.Area +------------------- ``` -procedure TBooleanMatrix.SetSize(Width, Height: Integer); +property TBooleanMatrix.Area: Integer; ``` *) -procedure _LapeBooleanMatrix_SetSize(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +procedure _LapeBooleanMatrix_Area(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PBooleanMatrix(Params^[0])^.SetSize(PInteger(Params^[1])^, PInteger(Params^[2])^); + PInteger(Result)^ := PBooleanMatrix(Params^[0])^.Area; end; + (* -TBooleanMatrix.Area -------------------- +TBooleanMatrix.SetSize +---------------------- ``` -function TBooleanMatrix.Area: Integer; +procedure TBooleanMatrix.SetSize(Width, Height: Integer); ``` *) -procedure _LapeBooleanMatrix_Area(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +procedure _LapeBooleanMatrix_SetSize(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV begin - PInteger(Result)^ := PBooleanMatrix(Params^[0])^.Area(); + PBooleanMatrix(Params^[0])^.SetSize(PInteger(Params^[1])^, PInteger(Params^[2])^); end; (* @@ -254,7 +255,7 @@ procedure _LapeBooleanMatrix_GetSize(const Params: PParamArray; const Result: Po TSingleMatrix.Width ------------------- ``` -function TSingleMatrix.Width: Integer; +property TSingleMatrix.Width: Integer; ``` *) procedure _LapeSingleMatrix_Width(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -266,7 +267,7 @@ procedure _LapeSingleMatrix_Width(const Params: PParamArray; const Result: Point TSingleMatrix.Height -------------------- ``` -function TSingleMatrix.Height: Integer; +property TSingleMatrix.Height: Integer; ``` *) procedure _LapeSingleMatrix_Height(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -274,43 +275,88 @@ procedure _LapeSingleMatrix_Height(const Params: PParamArray; const Result: Poin PInteger(Result)^ := PSingleMatrix(Params^[0])^.Height; end; +(* +TSingleMatrix.Min +----------------- +``` +property TSingleMatrix.Min: Single; +``` +*) procedure _LapeSingleMatrix_Min(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin PSingle(Result)^ := PSingleMatrix(Params^[0])^.Min; end; +(* +TSingleMatrix.Max +----------------- +``` +property TSingleMatrix.Max: Single; +``` +*) procedure _LapeSingleMatrix_Max(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin PSingle(Result)^ := PSingleMatrix(Params^[0])^.Max; end; +(* +TSingleMatrix.Mean +------------------ +``` +property TSingleMatrix.Mean: Single; +``` +*) procedure _LapeSingleMatrix_Mean(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PDouble(Result)^ := PSingleMatrix(Params^[0])^.Mean; + PSingle(Result)^ := PSingleMatrix(Params^[0])^.Mean; end; (* -TSingleMatrix.SetSize ---------------------- +TSingleMatrix.Area +------------------ ``` -procedure TSingleMatrix.SetSize(Width, Height: Integer); +property TSingleMatrix.Area: Integer; ``` *) -procedure _LapeSingleMatrix_SetSize(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +procedure _LapeSingleMatrix_Area(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PSingleMatrix(Params^[0])^.SetSize(PInteger(Params^[1])^, PInteger(Params^[2])^); + PInteger(Result)^ := PSingleMatrix(Params^[0])^.Area; end; (* -TSingleMatrix.Area ------------------- +TSingleMatrix.ArgMax +-------------------- ``` -function TSingleMatrix.Area: Integer; +property TSingleMatrix.ArgMax: TPoint; ``` *) -procedure _LapeSingleMatrix_Area(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +procedure _LapeSingleMatrix_ArgMax(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PInteger(Result)^ := PSingleMatrix(Params^[0])^.Area(); + PPoint(Result)^ := PSingleMatrix(Params^[0])^.ArgMax; +end; + +(* +TSingleMatrix.ArgMin +-------------------- +``` +property TSingleMatrix.ArgMin: TPoint; +``` +*) +procedure _LapeSingleMatrix_ArgMin(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +begin + PPoint(Result)^ := PSingleMatrix(Params^[0])^.ArgMin; +end; + +(* +TSingleMatrix.SetSize +--------------------- +``` +procedure TSingleMatrix.SetSize(NewWidth, NewHeight: Integer); +``` +*) +procedure _LapeSingleMatrix_SetSize(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +begin + PSingleMatrix(Params^[0])^.SetSize(PInteger(Params^[1])^, PInteger(Params^[2])^); end; (* @@ -433,30 +479,6 @@ procedure _LapeSingleMatrix_MinMax(const Params: PParamArray); LAPE_WRAPPER_CALL PSingleMatrix(Params^[0])^.MinMax(PSingle(Params^[1])^, PSingle(Params^[2])^); end; -(* -TSingleMatrix.ArgMax --------------------- -``` -function TSingleMatrix.ArgMax: TPoint; -``` -*) -procedure _LapeSingleMatrix_ArgMax(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PPoint(Result)^ := PSingleMatrix(Params^[0])^.ArgMax; -end; - -(* -TSingleMatrix.ArgMin --------------------- -``` -function TSingleMatrix.ArgMin: TPoint; -``` -*) -procedure _LapeSingleMatrix_ArgMin(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PPoint(Result)^ := PSingleMatrix(Params^[0])^.ArgMin; -end; - (* TSingleMatrix.NormMinMax ------------------------ @@ -565,12 +587,11 @@ procedure _LapeSingleMatrix_ArgExtrema(const Params: PParamArray; const Result: PPointArray(Result)^ := PSingleMatrix(Params^[0])^.ArgExtrema(PInteger(Params^[1])^, PBoolean(Params^[2])^, PBoolean(Params^[3])^); end; -// Double (* TDoubleMatrix.Width ------------------- ``` -function TDoubleMatrix.Width: Integer; +property TDoubleMatrix.Width: Integer; ``` *) procedure _LapeDoubleMatrix_Width(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -582,7 +603,7 @@ procedure _LapeDoubleMatrix_Width(const Params: PParamArray; const Result: Point TDoubleMatrix.Height -------------------- ``` -function TDoubleMatrix.Height: Integer; +property TDoubleMatrix.Height: Integer; ``` *) procedure _LapeDoubleMatrix_Height(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV @@ -591,27 +612,27 @@ procedure _LapeDoubleMatrix_Height(const Params: PParamArray; const Result: Poin end; (* -TDoubleMatrix.SetSize ---------------------- +TDoubleMatrix.Area +------------------ ``` -procedure TDoubleMatrix.SetSize(Width, Height: Integer); +property TDoubleMatrix.Area: Integer; ``` *) -procedure _LapeDoubleMatrix_SetSize(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV +procedure _LapeDoubleMatrix_Area(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV begin - PDoubleMatrix(Params^[0])^.SetSize(PInteger(Params^[1])^, PInteger(Params^[2])^); + PInteger(Result)^ := PDoubleMatrix(Params^[0])^.Area; end; (* -TDoubleMatrix.Area ------------------- +TDoubleMatrix.SetSize +--------------------- ``` -function TDoubleMatrix.Area: Integer; +procedure TDoubleMatrix.SetSize(NewWidth, NewHeight: Integer); ``` *) -procedure _LapeDoubleMatrix_Area(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV +procedure _LapeDoubleMatrix_SetSize(const Params: PParamArray); LAPE_WRAPPER_CALLING_CONV begin - PInteger(Result)^ := PDoubleMatrix(Params^[0])^.Area(); + PDoubleMatrix(Params^[0])^.SetSize(PInteger(Params^[1])^, PInteger(Params^[2])^); end; (* @@ -632,20 +653,16 @@ procedure ImportMatrix(Script: TSimbaScript); begin DumpSection := 'Matrix'; - //addGlobalType('array of TSingleArray', 'TSingleMatrix'); - //addGlobalType('array of TDoubleArray', 'TDoubleMatrix'); - //addGlobalType('array of TByteArray', 'TByteMatrix'); - //addGlobalType('array of TIntegerArray', 'TIntegerMatrix'); - //addGlobalType('array of TBooleanArray', 'TBooleanMatrix'); - // single - addGlobalFunc('function TSingleMatrix.Width: Integer;', @_LapeSingleMatrix_Width); - addGlobalFunc('function TSingleMatrix.Height: Integer;', @_LapeSingleMatrix_Height); - addGlobalFunc('function TSingleMatrix.Min: Single;', @_LapeSingleMatrix_Min); - addGlobalFunc('function TSingleMatrix.Max: Single;', @_LapeSingleMatrix_Max); - addGlobalFunc('function TSingleMatrix.Mean: Double;', @_LapeSingleMatrix_Mean); - addGlobalFunc('procedure TSingleMatrix.SetSize(Width, Height: Integer);', @_LapeSingleMatrix_SetSize); - addGlobalFunc('function TSingleMatrix.Area: Integer;', @_LapeSingleMatrix_Area); + addGlobalFunc('property TSingleMatrix.Width: Integer;', @_LapeSingleMatrix_Width); + addGlobalFunc('property TSingleMatrix.Height: Integer;', @_LapeSingleMatrix_Height); + addGlobalFunc('property TSingleMatrix.Min: Single;', @_LapeSingleMatrix_Min); + addGlobalFunc('property TSingleMatrix.Max: Single;', @_LapeSingleMatrix_Max); + addGlobalFunc('property TSingleMatrix.Mean: Single;', @_LapeSingleMatrix_Mean); + addGlobalFunc('property TSingleMatrix.Area: Integer;', @_LapeSingleMatrix_Area); + addGlobalFunc('property TSingleMatrix.ArgMax: TPoint;', @_LapeSingleMatrix_ArgMax); + addGlobalFunc('property TSingleMatrix.ArgMin: TPoint;', @_LapeSingleMatrix_ArgMin); + addGlobalFunc('procedure TSingleMatrix.SetSize(NewWidth, NewHeight: Integer);', @_LapeSingleMatrix_SetSize); addGlobalFunc('function TSingleMatrix.GetSize(out Width, Height: Integer): Boolean;', @_LapeSingleMatrix_GetSize); addGlobalFunc('function TSingleMatrix.GetValues(Indices: TPointArray): TSingleArray;', @_LapeSingleMatrix_GetValues); addGlobalFunc('procedure TSingleMatrix.SetValues(Indices: TPointArray; Values: TSingleArray)', @_LapeSingleMatrix_SetValues); @@ -656,8 +673,6 @@ procedure ImportMatrix(Script: TSimbaScript); addGlobalFunc('function TSingleMatrix.ToIntegerMatrix: TIntegerMatrix;', @_LapeSingleMatrix_ToIntegerMatrix); addGlobalFunc('procedure TSingleMatrix.MeanStdev(out Mean, Stdev: Double);', @_LapeSingleMatrix_MeanStdev); addGlobalFunc('procedure TSingleMatrix.MinMax(out MinValue, MaxValue: Single);', @_LapeSingleMatrix_MinMax); - addGlobalFunc('function TSingleMatrix.ArgMax: TPoint;', @_LapeSingleMatrix_ArgMax); - addGlobalFunc('function TSingleMatrix.ArgMin: TPoint;', @_LapeSingleMatrix_ArgMin); addGlobalFunc('function TSingleMatrix.NormMinMax(Alpha, Beta: Single): TSingleMatrix;', @_LapeSingleMatrix_NormMinMax); addGlobalFunc('function TSingleMatrix.Indices(Value: Single; Comparator: EComparator): TPointArray;', @_LapeSingleMatrix_Indices); addGlobalFunc('function TSingleMatrix.ArgMulti(Count: Integer; HiLo: Boolean): TPointArray;', @_LapeSingleMatrix_ArgMulti); @@ -668,18 +683,18 @@ procedure ImportMatrix(Script: TSimbaScript); addGlobalFunc('function TSingleMatrix.Rot90: TSingleMatrix;', @_LapeSingleMatrix_Rot90); addGlobalFunc('function TSingleMatrix.ArgExtrema(Count: Int32; HiLo: Boolean = True; XYIntersection: Boolean = True): TPointArray;', @_LapeSingleMatrix_ArgExtrema); - //double - addGlobalFunc('function TDoubleMatrix.Width: Integer;', @_LapeDoubleMatrix_Width); - addGlobalFunc('function TDoubleMatrix.Height: Integer;', @_LapeDoubleMatrix_Height); - addGlobalFunc('procedure TDoubleMatrix.SetSize(Width, Height: Integer);', @_LapeDoubleMatrix_SetSize); - addGlobalFunc('function TDoubleMatrix.Area: Integer;', @_LapeDoubleMatrix_Area); + // double + addGlobalFunc('property TDoubleMatrix.Width: Integer;', @_LapeDoubleMatrix_Width); + addGlobalFunc('property TDoubleMatrix.Height: Integer;', @_LapeDoubleMatrix_Height); + addGlobalFunc('property TDoubleMatrix.Area: Integer;', @_LapeDoubleMatrix_Area); + addGlobalFunc('procedure TDoubleMatrix.SetSize(NewWidth, NewHeight: Integer);', @_LapeDoubleMatrix_SetSize); addGlobalFunc('function TDoubleMatrix.GetSize(out Width, Height: Integer): Boolean;', @_LapeDoubleMatrix_GetSize); // integer - addGlobalFunc('function TIntegerMatrix.Width: Integer;', @_LapeIntegerMatrix_Width); - addGlobalFunc('function TIntegerMatrix.Height: Integer;', @_LapeIntegerMatrix_Height); - addGlobalFunc('procedure TIntegerMatrix.SetSize(Width, Height: Integer);', @_LapeIntegerMatrix_SetSize); - addGlobalFunc('function TIntegerMatrix.Area: Integer;', @_LapeIntegerMatrix_Area); + addGlobalFunc('property TIntegerMatrix.Width: Integer;', @_LapeIntegerMatrix_Width); + addGlobalFunc('property TIntegerMatrix.Height: Integer;', @_LapeIntegerMatrix_Height); + addGlobalFunc('property TIntegerMatrix.Area: Integer;', @_LapeIntegerMatrix_Area); + addGlobalFunc('procedure TIntegerMatrix.SetSize(NewWidth, NewHeight: Integer);', @_LapeIntegerMatrix_SetSize); addGlobalFunc('function TIntegerMatrix.GetSize(out Width, Height: Integer): Boolean;', @_LapeIntegerMatrix_GetSize); addGlobalFunc('function TIntegerMatrix.GetValues(Indices: TPointArray): TIntegerArray;', @_LapeIntegerMatrix_GetValues); addGlobalFunc('procedure TIntegerMatrix.SetValues(Indices: TPointArray; Values: TIntegerArray);', @_LapeIntegerMatrix_SetValues); @@ -692,10 +707,10 @@ procedure ImportMatrix(Script: TSimbaScript); addGlobalFunc('function TIntegerMatrix.Copy(Y1, Y2: Integer): TIntegerMatrix; overload', @_LapeIntegerMatrix_Copy2); // boolean - addGlobalFunc('function TBooleanMatrix.Width: Integer;', @_LapeBooleanMatrix_Width); - addGlobalFunc('function TBooleanMatrix.Height: Integer;', @_LapeBooleanMatrix_Height); - addGlobalFunc('procedure TBooleanMatrix.SetSize(Width, Height: Integer);', @_LapeBooleanMatrix_SetSize); + addGlobalFunc('property TBooleanMatrix.Width: Integer;', @_LapeBooleanMatrix_Width); + addGlobalFunc('property TBooleanMatrix.Height: Integer;', @_LapeBooleanMatrix_Height); addGlobalFunc('function TBooleanMatrix.Area: Integer;', @_LapeBooleanMatrix_Area); + addGlobalFunc('procedure TBooleanMatrix.SetSize(NewWidth, NewHeight: Integer);', @_LapeBooleanMatrix_SetSize); addGlobalFunc('function TBooleanMatrix.GetSize(out Width, Height: Integer): Boolean;', @_LapeBooleanMatrix_GetSize); DumpSection := ''; diff --git a/Source/script/imports/simba.import_target.pas b/Source/script/imports/simba.import_target.pas index 6a09bffc7..ea46bb996 100644 --- a/Source/script/imports/simba.import_target.pas +++ b/Source/script/imports/simba.import_target.pas @@ -764,30 +764,6 @@ procedure _LapeTarget_GetColorsMatrix(const Params: PParamArray; const Result: P PIntegerMatrix(Result)^ := PSimbaTarget(Params^[0])^.GetColorsMatrix(PBox(Params^[1])^); end; -(* -TTarget.HasImage ----------------- -``` -function TTarget.HasImage(Image: TSimbaImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; MinCount: Integer = 1; Bounds: TBox = [-1,-1,-1,-1]): Boolean; -``` -*) -procedure _LapeTarget_HasImage1(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PBoolean(Result)^ := PSimbaTarget(Params^[0])^.HasImage(PSimbaImage(Params^[1])^, PSingle(Params^[2])^, PColorSpace(Params^[3])^, PChannelMultipliers(Params^[4])^, PInteger(Params^[5])^, PBox(Params^[6])^); -end; - -(* -TTarget.HasImage ----------------- -``` -function TTarget.HasImage(Image: TSimbaImage; Tolerance: Single; MinCount: Integer = 1; Bounds: TBox = [-1,-1,-1,-1]): Boolean; -``` -*) -procedure _LapeTarget_HasImage2(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PBoolean(Result)^ := PSimbaTarget(Params^[0])^.HasImage(PSimbaImage(Params^[1])^, PSingle(Params^[2])^, PInteger(Params^[3])^, PBox(Params^[4])^); -end; - (* TTarget.FindImage ----------------- @@ -848,18 +824,6 @@ procedure _LapeTarget_FindTemplate(const Params: PParamArray; const Result: Poin PPoint(Result)^ := PSimbaTarget(Params^[0])^.FindTemplate(PSimbaImage(Params^[1])^, PSingle(Params^[2])^, PBox(Params^[3])^); end; -(* -TTarget.HasTemplate --------------------- -``` -function TTarget.HasTemplate(Image: TImage; MinMatch: Single; Bounds: TBox = [-1,-1,-1,-1]): Boolean; -``` -*) -procedure _LapeTarget_HasTemplate(const Params: PParamArray; const Result: Pointer); LAPE_WRAPPER_CALLING_CONV -begin - PBoolean(Result)^ := PSimbaTarget(Params^[0])^.HasTemplate(PSimbaImage(Params^[1])^, PSingle(Params^[2])^, PBox(Params^[3])^); -end; - (* TTarget.FindDTM --------------- @@ -1162,11 +1126,7 @@ procedure ImportTarget(Script: TSimbaScript); addGlobalFunc('function TTarget.FindImageEx(Image: TImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; MaxToFind: Integer = -1; Bounds: TBox = [-1,-1,-1,-1]): TPointArray; overload', @_LapeTarget_FindImageEx2); addGlobalFunc('function TTarget.FindImage(Image: TImage; Tolerance: Single; Bounds: TBox = [-1,-1,-1,-1]): TPoint; overload', @_LapeTarget_FindImage1); addGlobalFunc('function TTarget.FindImage(Image: TImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; Bounds: TBox = [-1,-1,-1,-1]): TPoint; overload', @_LapeTarget_FindImage2); - addGlobalFunc('function TTarget.HasImage(Image: TImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; MinCount: Integer = 1; Bounds: TBox = [-1,-1,-1,-1]): TPoint; overload', @_LapeTarget_HasImage1); - addGlobalFunc('function TTarget.HasImage(Image: TImage; Tolerance: Single; MinCount: Integer = 1; Bounds: TBox = [-1,-1,-1,-1]): TPoint; overload', @_LapeTarget_HasImage2); - addGlobalFunc('function TTarget.FindTemplate(Templ: TImage; out Match: Single; Bounds: TBox = [-1,-1,-1,-1]): TPoint', @_LapeTarget_FindTemplate); - addGlobalFunc('function TTarget.HasTemplate(Templ: TImage; MinMatch: Single; Bounds: TBox = [-1,-1,-1,-1]): Boolean', @_LapeTarget_HasTemplate); addGlobalFunc('function TTarget.FindDTM(DTM: TDTM; Bounds: TBox = [-1,-1,-1,-1]): TPoint', @_LapeTarget_FindDTM); addGlobalFunc('function TTarget.FindDTMEx(DTM: TDTM; MaxToFind: Integer = -1; Bounds: TBox = [-1,-1,-1,-1]): TPointArray', @_LapeTarget_FindDTMEx); diff --git a/Source/simba.finder_image.pas b/Source/simba.finder_image.pas index eb751e5a6..01612ef20 100644 --- a/Source/simba.finder_image.pas +++ b/Source/simba.finder_image.pas @@ -29,7 +29,6 @@ function FindImageOnBuffer(var Limit: TLimit; SearchWidth, SearchHeight: Integer): TPointArray; function FindTemplateOnTarget(constref Target: TSimbaTarget; Templ: TSimbaImage; out Match: Single; Bounds: TBox): TPoint; -function HasTemplateOnTarget(constref Target: TSimbaTarget; Templ: TSimbaImage; MinMatch: Single; Bounds: TBox): Boolean; var ImageFinderMultithreadOpts: record @@ -288,7 +287,7 @@ function FindTemplateOnTarget(constref Target: TSimbaTarget; Templ: TSimbaImage; try Mat := MatchTemplate(Image, Templ, TM_CCOEFF_NORMED); - Best := Mat.ArgMax(); + Best := Mat.ArgMax; Match := Mat[Best.Y, Best.X]; Result := Best + Bounds.TopLeft; finally @@ -296,15 +295,6 @@ function FindTemplateOnTarget(constref Target: TSimbaTarget; Templ: TSimbaImage; end; end; -function HasTemplateOnTarget(constref Target: TSimbaTarget; Templ: TSimbaImage; MinMatch: Single; Bounds: TBox): Boolean; -var - Match: Single; -begin - FindTemplateOnTarget(Target, Templ, Match, Bounds); - - Result := Match >= MinMatch; -end; - initialization ImageFinderMultithreadOpts.Enabled := True; ImageFinderMultithreadOpts.SliceHeight := 250; diff --git a/Source/simba.matchtemplate_ccoeff.pas b/Source/simba.matchtemplate_ccoeff.pas index 0a4276731..dd583ae44 100644 --- a/Source/simba.matchtemplate_ccoeff.pas +++ b/Source/simba.matchtemplate_ccoeff.pas @@ -66,9 +66,9 @@ function __MatchTemplate_CCOEFF(Image, Template: TIntegerMatrix; Normed: Boolean if not Normed then begin - mR := TemplChannels.R.Mean(); - mG := TemplChannels.G.Mean(); - mB := TemplChannels.B.Mean(); + mR := TemplChannels.R.Mean; + mG := TemplChannels.G.Mean; + mB := TemplChannels.B.Mean; tplSigma := 0; end else begin diff --git a/Source/simba.target.pas b/Source/simba.target.pas index 52f01a126..c447884b4 100644 --- a/Source/simba.target.pas +++ b/Source/simba.target.pas @@ -235,12 +235,9 @@ TSimbaTarget = record function FindImage(Image: TSimbaImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; ABounds: TBox): TPoint; overload; function FindImageEx(Image: TSimbaImage; Tolerance: Single; MaxToFind: Integer; ABounds: TBox): TPointArray; overload; function FindImageEx(Image: TSimbaImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; MaxToFind: Integer; ABounds: TBox): TPointArray; overload; - function HasImage(Image: TSimbaImage; Tolerance: Single; MinCount: Integer; ABounds: TBox): Boolean; overload; - function HasImage(Image: TSimbaImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; MinCount: Integer; ABounds: TBox): Boolean; overload; // Finder - template function FindTemplate(Templ: TSimbaImage; out Match: Single; ABounds: TBox): TPoint; - function HasTemplate(Templ: TSimbaImage; MinMatch: Single; ABounds: TBox): Boolean; // Finder - dtm function FindDTM(DTM: TDTM; ABounds: TBox): TPoint; @@ -554,26 +551,11 @@ function TSimbaTarget.FindImage(Image: TSimbaImage; Tolerance: Single; ColorSpac Result := TPoint.Create(-1, -1); end; -function TSimbaTarget.HasImage(Image: TSimbaImage; Tolerance: Single; MinCount: Integer; ABounds: TBox): Boolean; -begin - Result := Length(FindImageOnTarget(Self, Image, ABounds, DefaultColorSpace, Tolerance, DefaultMultipliers, MinCount)) >= MinCount; -end; - -function TSimbaTarget.HasImage(Image: TSimbaImage; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers; MinCount: Integer; ABounds: TBox): Boolean; -begin - Result := Length(FindImageOnTarget(Self, Image, ABounds, ColorSpace, Tolerance, Multipliers, MinCount)) >= MinCount; -end; - function TSimbaTarget.FindTemplate(Templ: TSimbaImage; out Match: Single; ABounds: TBox): TPoint; begin Result := FindTemplateOnTarget(Self, Templ, Match, ABounds); end; -function TSimbaTarget.HasTemplate(Templ: TSimbaImage; MinMatch: Single; ABounds: TBox): Boolean; -begin - Result := HasTemplateOnTarget(Self, Templ, MinMatch, ABounds); -end; - function TSimbaTarget.FindDTMEx(DTM: TDTM; MaxToFind: Integer; ABounds: TBox): TPointArray; begin Result := FindDTMOnTarget(Self, DTM, ABounds, MaxToFind); diff --git a/Source/simba.vartype_matrix.pas b/Source/simba.vartype_matrix.pas index c953998aa..087a03e13 100644 --- a/Source/simba.vartype_matrix.pas +++ b/Source/simba.vartype_matrix.pas @@ -10,12 +10,17 @@ interface type TIntegerMatrixHelper = type helper for TIntegerMatrix + private + function GetWidth: Integer; + function GetHeight: Integer; + function GetArea: Integer; public - function Width: Integer; - function Height: Integer; - function Area: Integer; + property Width: Integer read GetWidth; + property Height: Integer read GetHeight; + property Area: Integer read GetArea; + function GetSize(out AWidth, AHeight: Integer): Boolean; - procedure SetSize(AWidth, AHeight: Integer); + procedure SetSize(NewWidth, NewHeight: Integer); function Copy: TIntegerMatrix; overload; function Copy(Y1, Y2: Integer): TIntegerMatrix; overload; function GetValues(Indices: TPointArray): TIntegerArray; @@ -28,30 +33,59 @@ interface end; TByteMatrixHelper = type helper for TByteMatrix + private + function GetWidth: Integer; + function GetHeight: Integer; + function GetArea: Integer; public - function Width: Integer; - function Height: Integer; + property Width: Integer read GetWidth; + property Height: Integer read GetHeight; + property Area: Integer read GetArea; + function GetSize(out AWidth, AHeight: Integer): Boolean; - procedure SetSize(AWidth, AHeight: Integer); + procedure SetSize(NewWidth, NewHeight: Integer); end; TBooleanMatrixHelper = type helper for TBooleanMatrix + private + function GetWidth: Integer; + function GetHeight: Integer; + function GetArea: Integer; public - function Width: Integer; - function Height: Integer; - function Area: Integer; + property Width: Integer read GetWidth; + property Height: Integer read GetHeight; + property Area: Integer read GetArea; + function GetSize(out AWidth, AHeight: Integer): Boolean; - procedure SetSize(AWidth, AHeight: Integer); + procedure SetSize(NewWidth, NewHeight: Integer); end; TSingleMatrixHelper = type helper for TSingleMatrix + private + function GetArgMax: TPoint; + function GetArgMin: TPoint; + function GetMax: Single; + function GetMin: Single; + function GetSum: Double; + function GetWidth: Integer; + function GetHeight: Integer; + function GetArea: Integer; + function GetMean: Single; public - function Width: Integer; - function Height: Integer; - function Area: Integer; + property Width: Integer read GetWidth; + property Height: Integer read GetHeight; + property Area: Integer read GetArea; + property Min: Single read GetMin; + property Max: Single read GetMax; + property ArgMax: TPoint read GetArgMax; + property ArgMin: TPoint read GetArgMin; + property Sum: Double read GetSum; + property Mean: Single read GetMean; + + procedure SetSize(NewWidth, NewHeight: Integer); function GetSize(out AWidth, AHeight: Integer): Boolean; - procedure SetSize(AWidth, AHeight: Integer); function GetSizeMinusOne(out AWidth, AHeight: Integer): Boolean; + function Copy: TSingleMatrix; overload; function Copy(Y1, Y2: Integer): TSingleMatrix; overload; function GetValues(Indices: TPointArray): TSingleArray; @@ -61,18 +95,14 @@ interface procedure Fill(Value: Single); overload; function Flatten: TSingleArray; function ToIntegerMatrix: TIntegerMatrix; - function Mean: Double; procedure MeanStdev(out MeanValue, Stdev: Double); procedure MinMax(out MinValue, MaxValue: Single); - function Min: Single; - function Max: Single; - function ArgMax: TPoint; - function ArgMin: TPoint; + function NormMinMax(Alpha, Beta: Single): TSingleMatrix; function Indices(Value: Single; Comparator: EComparator): TPointArray; function ArgMulti(Count: Integer; HiLo: Boolean): TPointArray; procedure Smoothen(Block: Integer); - function Sum: Double; + function Equals(Other: TSingleMatrix; Epsilon: Single = 0): Boolean; procedure ReplaceNaNAndInf(const ReplaceWith: Single); function Rot90: TSingleMatrix; @@ -80,12 +110,17 @@ interface end; TDoubleMatrixHelper = type helper for TDoubleMatrix + private + function GetWidth: Integer; + function GetHeight: Integer; + function GetArea: Integer; public - function Width: Integer; - function Height: Integer; - function Area: Integer; + property Width: Integer read GetWidth; + property Height: Integer read GetHeight; + property Area: Integer read GetArea; + function GetSize(out AWidth, AHeight: Integer): Boolean; - procedure SetSize(AWidth, AHeight: Integer); + procedure SetSize(NewWidth, NewHeight: Integer); end; implementation @@ -94,7 +129,7 @@ implementation Math, simba.math, simba.containers, simba.container_heaparray, simba.vartype_pointarray, simba.vartype_box; -function TIntegerMatrixHelper.Width: Integer; +function TIntegerMatrixHelper.GetWidth: Integer; begin if (Length(Self) > 0) then Result := Length(Self[0]) @@ -102,12 +137,12 @@ function TIntegerMatrixHelper.Width: Integer; Result := 0; end; -function TIntegerMatrixHelper.Height: Integer; +function TIntegerMatrixHelper.GetHeight: Integer; begin Result := Length(Self); end; -function TIntegerMatrixHelper.Area: Integer; +function TIntegerMatrixHelper.GetArea: Integer; begin Result := Width * Height; end; @@ -120,9 +155,9 @@ function TIntegerMatrixHelper.GetSize(out AWidth, AHeight: Integer): Boolean; Result := (AWidth > 0) and (AHeight > 0); end; -procedure TIntegerMatrixHelper.SetSize(AWidth, AHeight: Integer); +procedure TIntegerMatrixHelper.SetSize(NewWidth, NewHeight: Integer); begin - SetLength(Self, AHeight, AWidth); + SetLength(Self, NewHeight, NewWidth); end; function TIntegerMatrixHelper.Copy: TIntegerMatrix; @@ -247,7 +282,7 @@ function TIntegerMatrixHelper.Indices(Value: Integer; Comparator: EComparator): Result := Buffer.ToArray(False); end; -function TByteMatrixHelper.Width: Integer; +function TByteMatrixHelper.GetWidth: Integer; begin if (Length(Self) > 0) then Result := Length(Self[0]) @@ -255,11 +290,16 @@ function TByteMatrixHelper.Width: Integer; Result := 0; end; -function TByteMatrixHelper.Height: Integer; +function TByteMatrixHelper.GetHeight: Integer; begin Result := Length(Self); end; +function TByteMatrixHelper.GetArea: Integer; +begin + Result := Width * Height; +end; + function TByteMatrixHelper.GetSize(out AWidth, AHeight: Integer): Boolean; begin AWidth := Width; @@ -268,12 +308,12 @@ function TByteMatrixHelper.GetSize(out AWidth, AHeight: Integer): Boolean; Result := (AWidth > 0) and (AHeight > 0); end; -procedure TByteMatrixHelper.SetSize(AWidth, AHeight: Integer); +procedure TByteMatrixHelper.SetSize(NewWidth, NewHeight: Integer); begin - SetLength(Self, AHeight, AWidth); + SetLength(Self, NewHeight, NewWidth); end; -function TBooleanMatrixHelper.Width: Integer; +function TBooleanMatrixHelper.GetWidth: Integer; begin if (Length(Self) > 0) then Result := Length(Self[0]) @@ -281,12 +321,12 @@ function TBooleanMatrixHelper.Width: Integer; Result := 0; end; -function TBooleanMatrixHelper.Height: Integer; +function TBooleanMatrixHelper.GetHeight: Integer; begin Result := Length(Self); end; -function TBooleanMatrixHelper.Area: Integer; +function TBooleanMatrixHelper.GetArea: Integer; begin Result := Width * Height; end; @@ -299,12 +339,102 @@ function TBooleanMatrixHelper.GetSize(out AWidth, AHeight: Integer): Boolean; Result := (AWidth > 0) and (AHeight > 0); end; -procedure TBooleanMatrixHelper.SetSize(AWidth, AHeight: Integer); +procedure TBooleanMatrixHelper.SetSize(NewWidth, NewHeight: Integer); begin - SetLength(Self, AHeight, AWidth); + SetLength(Self, NewHeight, NewWidth); end; -function TSingleMatrixHelper.Width: Integer; +function TSingleMatrixHelper.GetMin: Single; +var + MaxValue: Single; +begin + MinMax(Result, MaxValue); +end; + +function TSingleMatrixHelper.GetMax: Single; +var + MinValue: Single; +begin + MinMax(MinValue, Result); +end; + +function TSingleMatrixHelper.GetArgMax: TPoint; +var + X, Y, W, H: Integer; + Value, Best: Single; + HasValue: Boolean; +begin + Result := TPoint.Create(0, 0); + + if Self.GetSizeMinusOne(W, H) then + begin + HasValue := False; + + for Y := 0 to H do + for X := 0 to W do + begin + Value := Self[Y, X]; + if (not IsNumber(Value)) or (HasValue and (Value <= {%H-}Best)) then + Continue; + + HasValue := True; + Best := Value; + Result.X := X; + Result.Y := Y; + end; + end; +end; + +function TSingleMatrixHelper.GetArgMin: TPoint; +var + X, Y, W, H: Integer; + Value, Best: Single; + HasValue: Boolean; +begin + Result := TPoint.Create(0, 0); + + if Self.GetSizeMinusOne(W, H) then + begin + HasValue := False; + + for Y := 0 to H do + for X := 0 to W do + begin + Value := Self[Y, X]; + if (not IsNumber(Value)) or (HasValue and (Value >= {%H-}Best)) then + Continue; + + HasValue := True; + Best := Value; + Result.X := X; + Result.Y := Y; + end; + end; +end; + +function TSingleMatrixHelper.GetMean: Single; +begin + Result := Self.Sum / Self.Area; +end; + +function TSingleMatrixHelper.GetSum: Double; +var + X, Y, W, H: Integer; + Value: Single; +begin + Result := 0; + + if Self.GetSizeMinusOne(W, H) then + for Y := 0 to H do + for X := 0 to W do + begin + Value := Self[Y, X]; + if IsNumber(Value) then + Result := Result + Value; + end; +end; + +function TSingleMatrixHelper.GetWidth: Integer; begin if (Length(Self) > 0) then Result := Length(Self[0]) @@ -312,12 +442,12 @@ function TSingleMatrixHelper.Width: Integer; Result := 0; end; -function TSingleMatrixHelper.Height: Integer; +function TSingleMatrixHelper.GetHeight: Integer; begin Result := Length(Self); end; -function TSingleMatrixHelper.Area: Integer; +function TSingleMatrixHelper.GetArea: Integer; begin Result := Width * Height; end; @@ -330,9 +460,9 @@ function TSingleMatrixHelper.GetSize(out AWidth, AHeight: Integer): Boolean; Result := (AWidth > 0) and (AHeight > 0); end; -procedure TSingleMatrixHelper.SetSize(AWidth, AHeight: Integer); +procedure TSingleMatrixHelper.SetSize(NewWidth, NewHeight: Integer); begin - SetLength(Self, AHeight, AWidth); + SetLength(Self, NewHeight, NewWidth); end; function TSingleMatrixHelper.GetSizeMinusOne(out AWidth, AHeight: Integer): Boolean; @@ -458,11 +588,6 @@ function TSingleMatrixHelper.ToIntegerMatrix: TIntegerMatrix; Result[Y, X] := Trunc(Self[Y, X]); end; -function TSingleMatrixHelper.Mean: Double; -begin - Result := Self.Sum() / Self.Area(); -end; - procedure TSingleMatrixHelper.MeanStdev(out MeanValue, Stdev: Double); var W, H, X, Y: Integer; @@ -473,7 +598,7 @@ procedure TSingleMatrixHelper.MeanStdev(out MeanValue, Stdev: Double); if Self.GetSizeMinusOne(W, H) then begin - MeanValue := Self.Mean(); + MeanValue := Self.Mean; for Y := 0 to H do for X := 0 to W do @@ -483,7 +608,7 @@ procedure TSingleMatrixHelper.MeanStdev(out MeanValue, Stdev: Double); Stdev += Sqr(Value - MeanValue); end; - Stdev := Sqrt(Stdev / Self.Area()); + Stdev := Sqrt(Stdev / Self.Area); end; end; @@ -521,74 +646,6 @@ procedure TSingleMatrixHelper.MinMax(out MinValue, MaxValue: Single); end; end; -function TSingleMatrixHelper.Min: Single; -var - MaxValue: Single; -begin - MinMax(Result, MaxValue); -end; - -function TSingleMatrixHelper.Max: Single; -var - MinValue: Single; -begin - MinMax(MinValue, Result); -end; - -function TSingleMatrixHelper.ArgMax: TPoint; -var - X, Y, W, H: Integer; - Value, Best: Single; - HasValue: Boolean; -begin - Result := TPoint.Create(0, 0); - - if Self.GetSizeMinusOne(W, H) then - begin - HasValue := False; - - for Y := 0 to H do - for X := 0 to W do - begin - Value := Self[Y, X]; - if (not IsNumber(Value)) or (HasValue and (Value <= {%H-}Best)) then - Continue; - - HasValue := True; - Best := Value; - Result.X := X; - Result.Y := Y; - end; - end; -end; - -function TSingleMatrixHelper.ArgMin: TPoint; -var - X, Y, W, H: Integer; - Value, Best: Single; - HasValue: Boolean; -begin - Result := TPoint.Create(0, 0); - - if Self.GetSizeMinusOne(W, H) then - begin - HasValue := False; - - for Y := 0 to H do - for X := 0 to W do - begin - Value := Self[Y, X]; - if (not IsNumber(Value)) or (HasValue and (Value >= {%H-}Best)) then - Continue; - - HasValue := True; - Best := Value; - Result.X := X; - Result.Y := Y; - end; - end; -end; - function TSingleMatrixHelper.NormMinMax(Alpha, Beta: Single): TSingleMatrix; var Lo, Hi, OldRange, NewRange: Single; @@ -717,23 +774,6 @@ procedure TSingleMatrixHelper.Smoothen(Block: Integer); end; end; -function TSingleMatrixHelper.Sum: Double; -var - X, Y, W, H: Integer; - Value: Single; -begin - Result := 0; - - if Self.GetSizeMinusOne(W, H) then - for Y := 0 to H do - for X := 0 to W do - begin - Value := Self[Y, X]; - if IsNumber(Value) then - Result := Result + Value; - end; -end; - function TSingleMatrixHelper.Equals(Other: TSingleMatrix; Epsilon: Single): Boolean; var X, Y, W, H: Integer; @@ -825,8 +865,8 @@ function TSingleMatrixHelper.ArgExtrema(Count: Int32; HiLo: Boolean = True; XYIn I: Integer; Weights: TSingleArray; begin - W := Self.Width(); - H := Self.Height(); + W := Self.Width; + H := Self.Height; Buffer.Init(Math.Max(2, Ceil(Sqrt(W * H)))); @@ -849,7 +889,7 @@ function TSingleMatrixHelper.ArgExtrema(Count: Int32; HiLo: Boolean = True; XYIn SetLength(Result, Count); end; -function TDoubleMatrixHelper.Width: Integer; +function TDoubleMatrixHelper.GetWidth: Integer; begin if (Length(Self) > 0) then Result := Length(Self[0]) @@ -857,12 +897,12 @@ function TDoubleMatrixHelper.Width: Integer; Result := 0; end; -function TDoubleMatrixHelper.Height: Integer; +function TDoubleMatrixHelper.GetHeight: Integer; begin Result := Length(Self); end; -function TDoubleMatrixHelper.Area: Integer; +function TDoubleMatrixHelper.GetArea: Integer; begin Result := Width * Height; end; @@ -875,9 +915,9 @@ function TDoubleMatrixHelper.GetSize(out AWidth, AHeight: Integer): Boolean; Result := (AWidth > 0) and (AHeight > 0); end; -procedure TDoubleMatrixHelper.SetSize(AWidth, AHeight: Integer); +procedure TDoubleMatrixHelper.SetSize(NewWidth, NewHeight: Integer); begin - SetLength(Self, AHeight, AWidth); + SetLength(Self, NewHeight, NewWidth); end; end. diff --git a/Tests/matchtemplatemask.simba b/Tests/matchtemplatemask.simba index efc733a32..b7b65310e 100644 --- a/Tests/matchtemplatemask.simba +++ b/Tests/matchtemplatemask.simba @@ -9,8 +9,8 @@ var begin try mat := MatchTemplateMask(img.ToMatrix(), templ.ToMatrix(), formula); - Assert(mat.ArgMin() = minLoc); - Assert(mat.ArgMax() = maxLoc); + Assert(mat.ArgMin = minLoc); + Assert(mat.ArgMax = maxLoc); if (minValue <> 0) and (maxValue <> 0) then begin diff --git a/Tests/matchtemplatemask2.simba b/Tests/matchtemplatemask2.simba index 82374f10b..61b7d7f94 100644 --- a/Tests/matchtemplatemask2.simba +++ b/Tests/matchtemplatemask2.simba @@ -9,7 +9,7 @@ begin templ.FreeOnTerminate := True; mat := MatchTemplateMask(img.ToMatrix(), templ.ToMatrix(), TM_CCOEFF_NORMED); - Assert(mat.ArgMax() = [8,8]); + Assert(mat.ArgMax = [8,8]); for s in mat.Flatten() do if not IsNumber(s) then diff --git a/Tests/matrix.simba b/Tests/matrix.simba new file mode 100644 index 000000000..b106681a2 --- /dev/null +++ b/Tests/matrix.simba @@ -0,0 +1,61 @@ +{$assertions on} + +// Test basic matrix methods + +procedure TestSingleMatrix; +var + Mat: TSingleMatrix; +begin + Mat.SetSize(99, 101); + Assert(Mat.Width = 99); + Assert(Mat.Height = 101); + Assert(Mat.Area = 99*101); + + Mat[1,1] := -0.5; + Mat[90,90] := 100.5; + + Assert(Abs(Mat.Min - (-0.5)) < 0.001); + Assert(Abs(Mat.Max -100.5) < 0.001); + + Assert(Abs(Mat.Mean - 0.01) < 0.001); + Assert(Mat.ArgMax = [90,90]); + Assert(Mat.ArgMin = [1,1]); +end; + +procedure TestDoubleMatrix; +var + Mat: TDoubleMatrix; +begin + Mat.SetSize(99, 101); + Assert(Mat.Width = 99); + Assert(Mat.Height = 101); + Assert(Mat.Area = 99*101); +end; + +procedure TestIntMatrix; +var + Mat: TIntegerMatrix; +begin + Mat.SetSize(99, 101); + Assert(Mat.Width = 99); + Assert(Mat.Height = 101); + Assert(Mat.Area = 99*101); +end; + +procedure TestBoolMatrix; +var + Mat: TBooleanMatrix; +begin + Mat.SetSize(99, 101); + Assert(Mat.Width = 99); + Assert(Mat.Height = 101); + Assert(Mat.Area = 99*101); +end; + +begin + TestSingleMatrix(); + TestDoubleMatrix(); + TestIntMatrix(); + TestBoolMatrix(); +end. +