unit CxCore;
interface
const
CV_32FC1 = 4;
CV_64FC1 = 5;
CV_MAT_TYPE_MASK = 31;
type
PDoubleArray = ^TDoubleArray;
TDoubleArray = array [Word] of Double;
PSingleArray = ^TSingleArray;
TSingleArray = array [Word] of Single;
P_CvMat = ^CvMat;
CvMat = record
type_: Integer;
step: Integer;
//for internal use only
refcount: PInteger;
data: record
case Integer of
0: (ptr: PByte);
1: (s: PSmallInt);
2: (i: PInteger);
3: (fl: PSingle);
4: (
db: PDouble)
end;
case Integer of
0: (rows: Integer);
1: (height: Integer;
case Integer of
0: (cols: Integer);
1: (width: Integer))
end;
function cvCreateMat(rows: Integer;
cols: Integer;
type_: Integer): P_CvMat; cdecl;
function cvmGet(const mat: P_CvMat;
row: Integer;
col: Integer): Double; cdecl;
procedure cvmSet(mat: P_CvMat;
row: Integer;
col: Integer;
value: Double); cdecl;
function CV_MAT_TYPE(flags: Cardinal): Cardinal;
implementation
function cvCreateMat(rows: Integer;
cols: Integer;
type_: Integer): P_CvMat; external 'cxcore096.dll';
function cvmGet(const mat: P_CvMat; row: Integer; col: Integer): Double;
// external 'cxcore096.dll';
var
type_: Integer;
begin
type_ := CV_MAT_TYPE(mat.type_);
assert((row < mat.rows) and (col < mat.cols));
if(type_ = CV_32FC1) then
Result :=
PSingleArray(Cardinal(mat.data.ptr) + Cardinal(mat.step) * row)[col]
else
begin
assert(type_ = CV_64FC1);
Result :=
PDoubleArray(Cardinal(mat.data.ptr) + Cardinal(mat.step) * row)[col];
end;
end;
procedure cvmSet(mat: P_CvMat; row: Integer; col: Integer; value: Double);
// external 'cxcore096.dll';
var
type_: Integer;
begin
type_ := CV_MAT_TYPE(mat.type_);
assert((row < mat.rows) and (col < mat.cols));
if(type_ = CV_32FC1) then
PSingleArray(Cardinal(mat.data.ptr) + Cardinal(mat.step) * row)[col] :=
value
else
begin
assert(type_ = CV_64FC1);
PDoubleArray(Cardinal(mat.data.ptr) + Cardinal(mat.step) * row)[col] :=
value;
end;
end;
// #define CV_MAT_TYPE(flags) ((flags) & CV_MAT_TYPE_MASK)
function CV_MAT_TYPE(flags: Cardinal): Cardinal;
begin
Result := flags and CV_MAT_TYPE_MASK;
end;
end.