mirror of
https://github.com/Laex/Delphi-OpenCV.git
synced 2024-11-15 07:45:53 +01:00
HoughLines and HoughCircles image operations
Signed-off-by: Laentir Valetov <laex@bk.ru>
This commit is contained in:
parent
614e5335c0
commit
e093d356cd
@ -3,7 +3,7 @@
|
||||
// Copyright (C) 2013 Project Delphi-OpenCV
|
||||
// ****************************************************************
|
||||
// Contributor:
|
||||
// Laentir Valetov
|
||||
// Laentir Valetov
|
||||
// email:laex@bk.ru
|
||||
// ****************************************************************
|
||||
// You may retrieve the latest version of this file at the GitHub,
|
||||
@ -33,14 +33,13 @@ program cv_AdaptiveSkinDetector;
|
||||
uses
|
||||
System.SysUtils,
|
||||
WinApi.Windows,
|
||||
lib,
|
||||
highgui_c,
|
||||
core_c,
|
||||
Core.types_c,
|
||||
imgproc_c,
|
||||
imgproc.types_c
|
||||
// ,contrib
|
||||
;
|
||||
ocv.lib,
|
||||
ocv.highgui_c,
|
||||
ocv.core_c,
|
||||
ocv.Core.types_c,
|
||||
ocv.imgproc_c,
|
||||
ocv.imgproc.types_c,
|
||||
ocv.contrib;
|
||||
|
||||
const
|
||||
CLOCKS_PER_SEC = 1000;
|
||||
|
@ -3,7 +3,7 @@
|
||||
<ProjectGuid>{37486FE1-CC21-40FA-8006-F946D2DCCC3E}</ProjectGuid>
|
||||
<MainSource>OpenCV200.dpk</MainSource>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Release</Config>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<TargetedPlatforms>91</TargetedPlatforms>
|
||||
<AppType>Package</AppType>
|
||||
<FrameworkType>None</FrameworkType>
|
||||
@ -190,7 +190,7 @@
|
||||
<DCC_UnitSearchPath>..;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=OpenCV Component;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=OpenCV Component;ProductVersion=1.0.0.0;Comments=;LastCompiledTime=28.05.2014 22:11:47</VerInfo_Keys>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=OpenCV Component;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=OpenCV Component;ProductVersion=1.0.0.0;Comments=;LastCompiledTime=30.05.2014 11:33:52</VerInfo_Keys>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
|
||||
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
|
||||
@ -230,7 +230,7 @@
|
||||
<DCC_UnitSearchPath>..;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=OpenCV Component;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=OpenCV Component;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=OpenCV Component;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=OpenCV Component;ProductVersion=1.0.0.0;Comments=;LastCompiledTime=30.05.2014 19:19:54</VerInfo_Keys>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
|
Binary file not shown.
@ -1,35 +1,5 @@
|
||||
package dclOpenCV200;
|
||||
|
||||
{$R *.res}
|
||||
{$R '..\OpenCV.dcr'}
|
||||
{$IFDEF IMPLICITBUILDING This IFDEF should not be used by users}
|
||||
{$ALIGN 8}
|
||||
{$ASSERTIONS ON}
|
||||
{$BOOLEVAL OFF}
|
||||
{$DEBUGINFO OFF}
|
||||
{$EXTENDEDSYNTAX ON}
|
||||
{$IMPORTEDDATA ON}
|
||||
{$IOCHECKS ON}
|
||||
{$LOCALSYMBOLS OFF}
|
||||
{$LONGSTRINGS ON}
|
||||
{$OPENSTRINGS ON}
|
||||
{$OPTIMIZATION ON}
|
||||
{$OVERFLOWCHECKS OFF}
|
||||
{$RANGECHECKS OFF}
|
||||
{$REFERENCEINFO OFF}
|
||||
{$SAFEDIVIDE OFF}
|
||||
{$STACKFRAMES OFF}
|
||||
{$TYPEDADDRESS OFF}
|
||||
{$VARSTRINGCHECKS ON}
|
||||
{$WRITEABLECONST OFF}
|
||||
{$MINENUMSIZE 1}
|
||||
{$IMAGEBASE $400000}
|
||||
{$DEFINE RELEASE}
|
||||
{$ENDIF IMPLICITBUILDING}
|
||||
{$DESCRIPTION 'OpenCV Component'}
|
||||
{$DESIGNONLY}
|
||||
{$IMPLICITBUILD OFF}
|
||||
|
||||
requires
|
||||
OpenCV200,
|
||||
rtl,
|
||||
|
@ -3,7 +3,7 @@
|
||||
<ProjectGuid>{29A87BFF-B0BF-4A7F-BC7D-E36D34A7E4B5}</ProjectGuid>
|
||||
<MainSource>dclOpenCV200.dpk</MainSource>
|
||||
<Base>True</Base>
|
||||
<Config Condition="'$(Config)'==''">Release</Config>
|
||||
<Config Condition="'$(Config)'==''">Debug</Config>
|
||||
<TargetedPlatforms>1</TargetedPlatforms>
|
||||
<AppType>Package</AppType>
|
||||
<FrameworkType>VCL</FrameworkType>
|
||||
@ -123,7 +123,7 @@
|
||||
<PropertyGroup Condition="'$(Cfg_1_Win32)'!=''">
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=OpenCV Component;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=OpenCV Component;ProductVersion=1.0.0.0;Comments=;LastCompiledTime=28.05.2014 22:11:50</VerInfo_Keys>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=OpenCV Component;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=OpenCV Component;ProductVersion=1.0.0.0;Comments=;LastCompiledTime=30.05.2014 11:33:56</VerInfo_Keys>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_1_Win64)'!=''">
|
||||
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
|
||||
@ -141,7 +141,7 @@
|
||||
<DCC_DcuOutput>.</DCC_DcuOutput>
|
||||
<VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
|
||||
<VerInfo_Locale>1033</VerInfo_Locale>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=OpenCV Component;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=OpenCV Component;ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
|
||||
<VerInfo_Keys>CompanyName=;FileDescription=OpenCV Component;FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProductName=OpenCV Component;ProductVersion=1.0.0.0;Comments=;LastCompiledTime=30.05.2014 19:19:57</VerInfo_Keys>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Cfg_2_Win64)'!=''">
|
||||
<DCC_DcuOutput>.\$(Platform)\$(Config)</DCC_DcuOutput>
|
||||
@ -153,7 +153,6 @@
|
||||
<DelphiCompile Include="$(MainSource)">
|
||||
<MainSource>MainSource</MainSource>
|
||||
</DelphiCompile>
|
||||
<DCCReference Include="..\OpenCV.dcr"/>
|
||||
<DCCReference Include="OpenCV200.dcp"/>
|
||||
<DCCReference Include="rtl.dcp"/>
|
||||
<DCCReference Include="vcl.dcp"/>
|
||||
|
Binary file not shown.
@ -248,7 +248,7 @@ type
|
||||
property sigma2: Double index 1 Read GetFloatParam write SetFloatParam;
|
||||
property size1: Integer index 0 Read GetIntParam write SetIntParam;
|
||||
property size2: Integer index 1 Read GetIntParam write SetIntParam;
|
||||
property SmoothOperation: TocvSmoothOperations read FSmoothOperation write SetSmoothOperation default GAUSSIAN;
|
||||
property SmoothType: TocvSmoothOperations read FSmoothOperation write SetSmoothOperation default GAUSSIAN;
|
||||
end;
|
||||
|
||||
TocvThresholdType = (THRESH_BINARY, THRESH_BINARY_INV, THRESH_TRUNC, THRESH_TOZERO, THRESH_TOZERO_INV, THRESH_MASK,
|
||||
@ -434,8 +434,6 @@ type
|
||||
function DoTransform(const Source: IocvImage; out Destanation: IocvImage): Boolean; override;
|
||||
end;
|
||||
|
||||
TocvLineType = (LT_FILLED, LT_8, LT_AA);
|
||||
|
||||
TocvDraw = class(TPersistent)
|
||||
protected
|
||||
FColor: TColor;
|
||||
@ -448,11 +446,15 @@ type
|
||||
FThickness: Integer;
|
||||
FLineType: TocvLineType;
|
||||
FShift: Integer;
|
||||
function GetCvLineType: Integer;
|
||||
function GetCvColor: TCvScalar;
|
||||
public
|
||||
constructor Create(AOwner: TPersistent);
|
||||
destructor Destroy; override;
|
||||
property Color: TColor read FColor write FColor default clGreen;
|
||||
property Shift: Integer read FShift write FShift default 0;
|
||||
property cvLineType: Integer read GetCvLineType;
|
||||
property cvColor: TCvScalar read GetCvColor;
|
||||
published
|
||||
property Enabled: Boolean read FEnabled write FEnabled default True;
|
||||
property Thickness: Integer read FThickness write FThickness default 2;
|
||||
@ -460,6 +462,11 @@ type
|
||||
property Offset: TocvPoint2D32i read FOffset write FOffset;
|
||||
end;
|
||||
|
||||
TocvDrawColor = class(TocvDraw)
|
||||
published
|
||||
property Color;
|
||||
end;
|
||||
|
||||
TocvMatchTemplateMethod = (TM_SQDIFF, TM_SQDIFF_NORMED, TM_CCORR, TM_CCORR_NORMED, TM_CCOEFF, TM_CCOEFF_NORMED);
|
||||
|
||||
TocvMatchTemplate = class(TocvCustomImageOperation)
|
||||
@ -491,10 +498,7 @@ type
|
||||
TocvContourApproximationMethods = (CHAIN_CODE, CHAIN_APPROX_NONE, CHAIN_APPROX_SIMPLE, CHAIN_APPROX_TC89_L1,
|
||||
CHAIN_APPROX_TC89_KCOS, LINK_RUNS);
|
||||
|
||||
TocvDrawMotionRect = class(TocvDraw)
|
||||
published
|
||||
property Color;
|
||||
end;
|
||||
TocvDrawMotionRect = TocvDrawColor;
|
||||
|
||||
TocvMotionDetect = class(TocvCustomImageOperationWithNestedOperation)
|
||||
protected
|
||||
@ -523,6 +527,99 @@ type
|
||||
property NotifyOnlyWhenFound: Boolean index 1 Read GetBoolParam write SetBoolParam;
|
||||
end;
|
||||
|
||||
TocvHoughTransform = (HOUGH_STANDARD, HOUGH_PROBABILISTIC, HOUGH_MULTI_SCALE, HOUGH_GRADIENT);
|
||||
|
||||
TocvDrawHoughCircles = TocvDrawColor;
|
||||
|
||||
TovcHoughCirclesSmooth = class(TPersistent)
|
||||
protected
|
||||
procedure AssignTo(Dest: TPersistent); override;
|
||||
private
|
||||
FSmoothOperation: TocvSmoothOperations;
|
||||
Fsigma1: Double;
|
||||
Fsigma2: Double;
|
||||
Fsize1: Integer;
|
||||
Fsize2: Integer;
|
||||
FEnabled: Boolean;
|
||||
public
|
||||
constructor Create;
|
||||
published
|
||||
property sigma1: Double Read Fsigma1 write Fsigma1;
|
||||
property sigma2: Double Read Fsigma2 write Fsigma2;
|
||||
property size1: Integer Read Fsize1 write Fsize1 default 0;
|
||||
property size2: Integer Read Fsize2 write Fsize2 default 0;
|
||||
property SmoothType: TocvSmoothOperations read FSmoothOperation write FSmoothOperation default GAUSSIAN;
|
||||
property Enabled: Boolean read FEnabled write FEnabled default True;
|
||||
end;
|
||||
|
||||
TocvHoughCircles = class(TocvCustomImageOperation)
|
||||
protected
|
||||
procedure AssignTo(Dest: TPersistent); override;
|
||||
private
|
||||
FHoughTransform: TocvHoughTransform;
|
||||
FDrawCircle: TocvDrawHoughCircles;
|
||||
FOnCircles: TOnOcvCircles;
|
||||
FSmooth: TovcHoughCirclesSmooth;
|
||||
public
|
||||
constructor Create(AOwner: TPersistent); override;
|
||||
destructor Destroy; override;
|
||||
function DoTransform(const Source: IocvImage; out Destanation: IocvImage): Boolean; override;
|
||||
published
|
||||
property Method: TocvHoughTransform read FHoughTransform write FHoughTransform default HOUGH_GRADIENT;
|
||||
property InverseRatio: Double index 0 Read GetFloatParam write SetFloatParam;
|
||||
property MinDist: Double index 1 Read GetFloatParam write SetFloatParam;
|
||||
property Param1: Double index 2 Read GetFloatParam write SetFloatParam;
|
||||
property Param2: Double index 3 Read GetFloatParam write SetFloatParam;
|
||||
property MinRadius: Integer index 0 Read GetIntParam write SetIntParam;
|
||||
property MaxRadius: Integer index 1 Read GetIntParam write SetIntParam;
|
||||
property DrawCircle: TocvDrawHoughCircles read FDrawCircle write FDrawCircle;
|
||||
property OnCircles: TOnOcvCircles read FOnCircles write FOnCircles;
|
||||
property NotifyOnlyWhenFound: Boolean index 0 Read GetBoolParam write SetBoolParam;
|
||||
property Smooth: TovcHoughCirclesSmooth read FSmooth write FSmooth;
|
||||
end;
|
||||
|
||||
TocvHoughLinesCanny = class(TPersistent)
|
||||
protected
|
||||
procedure AssignTo(Dest: TPersistent); override;
|
||||
private
|
||||
FThreshold1: Double;
|
||||
FThreshold2: Double;
|
||||
FApertureSize: Integer;
|
||||
public
|
||||
constructor Create;
|
||||
published
|
||||
property Threshold1: Double read FThreshold1 write FThreshold1;
|
||||
property Threshold2: Double read FThreshold2 write FThreshold2;
|
||||
property ApertureSize: Integer read FApertureSize write FApertureSize default 3;
|
||||
end;
|
||||
|
||||
TocvDrawHoughLines = TocvDrawColor;
|
||||
|
||||
TocvHoughLines = class(TocvCustomImageOperation)
|
||||
protected
|
||||
procedure AssignTo(Dest: TPersistent); override;
|
||||
private
|
||||
FHoughTransform: TocvHoughTransform;
|
||||
FCanny: TocvHoughLinesCanny;
|
||||
FOnLines: TOnOcvLines;
|
||||
FDrawLines: TocvDrawHoughLines;
|
||||
public
|
||||
constructor Create(AOwner: TPersistent); override;
|
||||
destructor Destroy; override;
|
||||
function DoTransform(const Source: IocvImage; out Destanation: IocvImage): Boolean; override;
|
||||
published
|
||||
property Method: TocvHoughTransform read FHoughTransform write FHoughTransform default HOUGH_PROBABILISTIC;
|
||||
property Rho: Double index 0 Read GetFloatParam write SetFloatParam;
|
||||
property Theta: Double index 1 Read GetFloatParam write SetFloatParam;
|
||||
property Param1: Double index 2 Read GetFloatParam write SetFloatParam;
|
||||
property Param2: Double index 3 Read GetFloatParam write SetFloatParam;
|
||||
property Threshold: Integer index 0 Read GetIntParam write SetIntParam;
|
||||
property Canny: TocvHoughLinesCanny Read FCanny write FCanny;
|
||||
property OnLines: TOnOcvLines read FOnLines write FOnLines;
|
||||
property DrawLines: TocvDrawHoughLines read FDrawLines write FDrawLines;
|
||||
property NotifyOnlyWhenFound: Boolean index 0 Read GetBoolParam write SetBoolParam;
|
||||
end;
|
||||
|
||||
TocvHaarCascadeDraw = class(TocvDraw)
|
||||
published
|
||||
property Color;
|
||||
@ -744,7 +841,8 @@ uses
|
||||
ocv.core_c,
|
||||
ocv.imgproc_c,
|
||||
ocv.imgproc.types_c,
|
||||
ocv.cvutils, System.Math;
|
||||
ocv.cvutils,
|
||||
System.Math;
|
||||
|
||||
type
|
||||
TPersistentAccessProtected = class(TPersistent);
|
||||
@ -770,27 +868,6 @@ begin
|
||||
Result := _RegisteredImageOperations;
|
||||
end;
|
||||
|
||||
const
|
||||
cLineType: array [TocvLineType] of Integer = (CV_FILLED, 8, CV_AA);
|
||||
|
||||
procedure GetRGBValue(const AColor: TColor; var r, g, b: byte);
|
||||
Var
|
||||
RGBColor: TColor;
|
||||
begin
|
||||
RGBColor := ColorToRGB(AColor);
|
||||
r := GetRValue(RGBColor);
|
||||
g := GetGValue(RGBColor);
|
||||
b := GetBValue(RGBColor);
|
||||
end;
|
||||
|
||||
function ColorToCvRGB(const Color: TColor): TCvScalar;
|
||||
var
|
||||
r, g, b: byte;
|
||||
begin
|
||||
GetRGBValue(Color, r, g, b);
|
||||
Result := CV_RGB(r, g, b);
|
||||
end;
|
||||
|
||||
{TocvImageOperation}
|
||||
|
||||
procedure TocvImageOperation.SetOnAfterEachOperation(const Value: TOnOcvNotifyCollectionItem);
|
||||
@ -1158,7 +1235,7 @@ Var
|
||||
Image: pIplImage;
|
||||
begin
|
||||
Image := cvCloneImage(Source.IpImage);
|
||||
cvSmooth(Source.IpImage, Image, ocvSmoothOperations[SmoothOperation], size1, size2, sigma1, sigma2);
|
||||
cvSmooth(Source.IpImage, Image, ocvSmoothOperations[SmoothType], size1, size2, sigma1, sigma2);
|
||||
Destanation := TocvImage.Create(Image);
|
||||
Result := True;
|
||||
end;
|
||||
@ -1708,6 +1785,16 @@ begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TocvDraw.GetCvColor: TCvScalar;
|
||||
begin
|
||||
Result := ColorToCvRGB(Color);
|
||||
end;
|
||||
|
||||
function TocvDraw.GetCvLineType: Integer;
|
||||
begin
|
||||
Result := cLineType[LineType];
|
||||
end;
|
||||
|
||||
function TocvDraw.GetOwner: TPersistent;
|
||||
begin
|
||||
Result := FOwner;
|
||||
@ -2070,6 +2157,7 @@ begin
|
||||
Threshold := 25;
|
||||
MaxValue := 255;
|
||||
end;
|
||||
NotifyOnlyWhenFound := False;
|
||||
end;
|
||||
|
||||
destructor TocvMotionDetect.Destroy;
|
||||
@ -2672,6 +2760,221 @@ begin
|
||||
FY := AY;
|
||||
end;
|
||||
|
||||
{TocvHoughCircles}
|
||||
|
||||
procedure TocvHoughCircles.AssignTo(Dest: TPersistent);
|
||||
begin
|
||||
inherited;
|
||||
if Dest is TocvHoughCircles then
|
||||
begin
|
||||
FHoughTransform := (Dest as TocvHoughCircles).FHoughTransform;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TocvHoughCircles.Create(AOwner: TPersistent);
|
||||
begin
|
||||
inherited;
|
||||
FHoughTransform := HOUGH_GRADIENT;
|
||||
InverseRatio := 1;
|
||||
MinDist := 100;
|
||||
Param1 := 100;
|
||||
Param2 := 100;
|
||||
MinRadius := 0;
|
||||
MaxRadius := 0;
|
||||
FDrawCircle := TocvDrawHoughCircles.Create(Self);
|
||||
NotifyOnlyWhenFound := False;
|
||||
FSmooth := TovcHoughCirclesSmooth.Create;
|
||||
FSmooth.SmoothType := GAUSSIAN;
|
||||
FSmooth.size1 := 5;
|
||||
FSmooth.size2 := 5;
|
||||
FSmooth.sigma1 := 0;
|
||||
FSmooth.sigma2 := 0;
|
||||
end;
|
||||
|
||||
destructor TocvHoughCircles.Destroy;
|
||||
begin
|
||||
FDrawCircle.Free;
|
||||
FSmooth.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TocvHoughCircles.DoTransform(const Source: IocvImage; out Destanation: IocvImage): Boolean;
|
||||
type
|
||||
TFloatArray = array [0 .. 10] of Single;
|
||||
pFloatArray = ^TFloatArray;
|
||||
|
||||
Var
|
||||
results: pCvSeq;
|
||||
storage: pCvMemStorage;
|
||||
Circles: TocvCircles;
|
||||
i: Integer;
|
||||
p: pFloatArray;
|
||||
D: IocvImage;
|
||||
begin
|
||||
SetLength(Circles, 0);
|
||||
Destanation := Source;
|
||||
try
|
||||
storage := cvCreateMemStorage(0);
|
||||
results := nil;
|
||||
try
|
||||
|
||||
if Smooth.Enabled then
|
||||
begin
|
||||
D := Source.Same;
|
||||
cvSmooth(Source.IpImage, D.IpImage, ocvSmoothOperations[Smooth.SmoothType], Smooth.size1, Smooth.size2, Smooth.sigma1,
|
||||
Smooth.sigma2);
|
||||
end
|
||||
else
|
||||
D := Source;
|
||||
|
||||
results := cvHoughCircles(D.GrayImage.IpImage, storage, Integer(Method), InverseRatio, MinDist, Param1, Param2, MinRadius,
|
||||
MaxRadius);
|
||||
if Assigned(results) then
|
||||
begin
|
||||
SetLength(Circles, results^.total);
|
||||
for i := 0 to results^.total - 1 do
|
||||
begin
|
||||
p := pFloatArray(cvGetSeqElem(results, i));
|
||||
Circles[i].cX := cvRound(p^[0]);
|
||||
Circles[i].cY := cvRound(p^[1]);
|
||||
Circles[i].Radius := cvRound(p^[2]);
|
||||
if DrawCircle.Enabled then
|
||||
cvCircle(Destanation.IpImage, cvPoint(Circles[i].cX, Circles[i].cY), Circles[i].Radius, DrawCircle.cvColor,
|
||||
DrawCircle.Thickness, DrawCircle.cvLineType, DrawCircle.Shift);
|
||||
end;
|
||||
end;
|
||||
finally
|
||||
cvReleaseMemStorage(storage);
|
||||
end;
|
||||
except
|
||||
end;
|
||||
if Assigned(OnCircles) and ((Length(Circles) > 0) or (not NotifyOnlyWhenFound)) then
|
||||
OnCircles(Self, Destanation, Circles);
|
||||
end;
|
||||
|
||||
{TocvHoughLines}
|
||||
|
||||
procedure TocvHoughLines.AssignTo(Dest: TPersistent);
|
||||
begin
|
||||
inherited;
|
||||
if Dest is TocvHoughLines then
|
||||
begin
|
||||
FHoughTransform := (Dest as TocvHoughLines).FHoughTransform
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TocvHoughLines.Create(AOwner: TPersistent);
|
||||
begin
|
||||
inherited;
|
||||
FHoughTransform := HOUGH_PROBABILISTIC;
|
||||
Rho := 1;
|
||||
Theta := CV_PI / 180;
|
||||
Param1 := 50;
|
||||
Param2 := 10;
|
||||
Threshold := 50;
|
||||
FCanny := TocvHoughLinesCanny.Create;
|
||||
FDrawLines := TocvDrawHoughLines.Create(Self);
|
||||
NotifyOnlyWhenFound := True;
|
||||
end;
|
||||
|
||||
destructor TocvHoughLines.Destroy;
|
||||
begin
|
||||
FCanny.Free;
|
||||
FDrawLines.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TocvHoughLines.DoTransform(const Source: IocvImage; out Destanation: IocvImage): Boolean;
|
||||
Var
|
||||
lines: pCvSeq;
|
||||
line: pCvPointArray;
|
||||
storage: pCvMemStorage;
|
||||
SG, D: IocvImage;
|
||||
i: Integer;
|
||||
ocvlines: TocvLines;
|
||||
begin
|
||||
lines := nil;
|
||||
SetLength(ocvlines, 0);
|
||||
Destanation := Source;
|
||||
try
|
||||
storage := cvCreateMemStorage(0);
|
||||
try
|
||||
SG := Source.GrayImage;
|
||||
D := SG.Same;
|
||||
cvCanny(SG.IpImage, D.IpImage, Canny.Threshold1, Canny.Threshold2, Canny.ApertureSize);
|
||||
lines := cvHoughLines2(D.IpImage, storage, Integer(Method), Rho, Theta, Threshold, Param1, Param2);
|
||||
if Assigned(lines) then
|
||||
begin
|
||||
SetLength(ocvlines, lines^.total);
|
||||
for i := 0 to lines^.total - 1 do
|
||||
begin
|
||||
line := pCvPointArray(cvGetSeqElem(lines, i));
|
||||
ocvlines[i].S := line^[0];
|
||||
ocvlines[i].E := line^[1];
|
||||
if DrawLines.Enabled then
|
||||
cvLine(Destanation.IpImage, line^[0], line^[1], DrawLines.cvColor, DrawLines.Thickness, DrawLines.cvLineType,
|
||||
DrawLines.Shift);
|
||||
end;
|
||||
end;
|
||||
|
||||
if Assigned(OnLines) and ((Length(ocvlines) > 0) or (not NotifyOnlyWhenFound)) then
|
||||
OnLines(Self, Destanation, ocvlines);
|
||||
finally
|
||||
cvReleaseMemStorage(storage);
|
||||
end;
|
||||
except
|
||||
|
||||
end;
|
||||
end;
|
||||
|
||||
{TovcHoughCirclesSmooth}
|
||||
|
||||
procedure TovcHoughCirclesSmooth.AssignTo(Dest: TPersistent);
|
||||
begin
|
||||
inherited;
|
||||
if Dest is TovcHoughCirclesSmooth then
|
||||
begin
|
||||
FSmoothOperation := (Dest as TovcHoughCirclesSmooth).FSmoothOperation;
|
||||
Fsigma1 := (Dest as TovcHoughCirclesSmooth).Fsigma1;
|
||||
Fsigma2 := (Dest as TovcHoughCirclesSmooth).Fsigma2;
|
||||
Fsize1 := (Dest as TovcHoughCirclesSmooth).Fsize1;
|
||||
Fsize2 := (Dest as TovcHoughCirclesSmooth).Fsize2;
|
||||
FEnabled := (Dest as TovcHoughCirclesSmooth).FEnabled;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TovcHoughCirclesSmooth.Create;
|
||||
begin
|
||||
inherited;
|
||||
FSmoothOperation := GAUSSIAN;
|
||||
Fsigma1 := 0;
|
||||
Fsigma2 := 0;
|
||||
Fsize1 := 5;
|
||||
Fsize2 := 5;
|
||||
FEnabled := True;
|
||||
end;
|
||||
|
||||
{TocvHoughLinesCanny}
|
||||
|
||||
procedure TocvHoughLinesCanny.AssignTo(Dest: TPersistent);
|
||||
begin
|
||||
inherited;
|
||||
if Dest is TocvHoughLinesCanny then
|
||||
begin
|
||||
FThreshold1 := (Dest as TocvHoughLinesCanny).FThreshold1;
|
||||
FThreshold2 := (Dest as TocvHoughLinesCanny).FThreshold2;
|
||||
FApertureSize := (Dest as TocvHoughLinesCanny).FApertureSize;
|
||||
end;
|
||||
end;
|
||||
|
||||
constructor TocvHoughLinesCanny.Create;
|
||||
begin
|
||||
inherited;
|
||||
FThreshold1 := 50;
|
||||
FThreshold2 := 200;
|
||||
FApertureSize := 3;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
GetRegisteredImageOperations.RegisterIOClass(TocvNoneOperation, 'None');
|
||||
@ -2693,6 +2996,8 @@ GetRegisteredImageOperations.RegisterIOClass(TocvMotionDetect, 'MotionDetect');
|
||||
GetRegisteredImageOperations.RegisterIOClass(TovcCropOperation, 'Crop');
|
||||
GetRegisteredImageOperations.RegisterIOClass(TovcAddWeightedOperation, 'AddWeighted');
|
||||
GetRegisteredImageOperations.RegisterIOClass(TocvWarpPerspective, 'WarpPerspective');
|
||||
GetRegisteredImageOperations.RegisterIOClass(TocvHoughCircles, 'HoughCircles');
|
||||
GetRegisteredImageOperations.RegisterIOClass(TocvHoughLines, 'HoughLines');
|
||||
|
||||
finalization
|
||||
|
||||
|
@ -70,7 +70,9 @@ begin
|
||||
{} TocvMotionDetect,
|
||||
{} TovcCropOperation,
|
||||
{} TovcAddWeightedOperation,
|
||||
{} TocvWarpPerspective]);
|
||||
{} TocvWarpPerspective,
|
||||
{} TocvHoughCircles,
|
||||
{} TocvHoughLines]);
|
||||
end;
|
||||
|
||||
{$IFDEF FPC}
|
||||
|
@ -30,20 +30,89 @@ interface
|
||||
|
||||
uses
|
||||
{$IFDEF VER15P}
|
||||
WinApi.Windows,
|
||||
System.SysUtils,
|
||||
System.Classes,
|
||||
System.Generics.Collections,
|
||||
System.Types,
|
||||
Vcl.Graphics,
|
||||
{$ELSE}
|
||||
Windows,
|
||||
SysUtils,
|
||||
Classes,
|
||||
Graphics,
|
||||
{$IFNDEF VER5}Types, {$ENDIF VER5}
|
||||
{$ENDIF VER15P}
|
||||
ocv.core_c,
|
||||
ocv.core.types_c;
|
||||
|
||||
Type
|
||||
|
||||
TocvRect = Type TRect;
|
||||
TocvLine = record
|
||||
S, E: TCvPoint;
|
||||
end;
|
||||
|
||||
TocvCircle = record
|
||||
cX, cY: Integer;
|
||||
Radius: Integer;
|
||||
end;
|
||||
|
||||
{$IFDEF VER17P}
|
||||
|
||||
TocvRects = TArray<TocvRect>;
|
||||
TocvCircles = TArray<TocvCircle>;
|
||||
TocvLines = TArray<TocvLine>;
|
||||
{$ELSE}
|
||||
TocvRects = Array of TocvRect;
|
||||
TocvCircles = Array of TocvCircle;
|
||||
TocvLines = array of TocvLine;
|
||||
{$ENDIF}
|
||||
TocvLineType = (LT_FILLED, LT_8, LT_AA);
|
||||
|
||||
IocvFont = interface
|
||||
['{3EAFF1CE-7C65-4138-829F-329C81DDED8F}']
|
||||
function GetFontName: string;
|
||||
procedure SetFontName(const Value: string);
|
||||
function GetFontColor: TColor;
|
||||
procedure SetFontColor(const Value: TColor);
|
||||
function GetFontThickness: Integer;
|
||||
procedure SetFontThickness(const Value: Integer);
|
||||
function GetFontLineType: TocvLineType;
|
||||
procedure SetFontLineType(const Value: TocvLineType);
|
||||
function GetFontHScale: Single;
|
||||
procedure SetFontHScale(const Value: Single);
|
||||
function GetFontVScale: Single;
|
||||
procedure SetFontVScale(const Value: Single);
|
||||
function GetCvFont: TCvFont;
|
||||
property Name: string read GetFontName write SetFontName;
|
||||
property Color: TColor read GetFontColor write SetFontColor;
|
||||
property Thickness: Integer read GetFontThickness write SetFontThickness;
|
||||
property LineType: TocvLineType read GetFontLineType write SetFontLineType;
|
||||
property HScale: Single read GetFontHScale write SetFontHScale;
|
||||
property VScale: Single read GetFontVScale write SetFontVScale;
|
||||
property cvFont: TCvFont Read GetCvFont;
|
||||
end;
|
||||
|
||||
IocvCanvas = interface
|
||||
['{D5BCBC44-8139-42A7-A97A-0A5AD33C6526}']
|
||||
function GetOcvFont: IocvFont;
|
||||
property ocvFont: IocvFont read GetOcvFont;
|
||||
|
||||
procedure Rectangle(const x1, y1, x2, y2: Integer; const Color: TColor = clRed; const Thickness: Integer = 1;
|
||||
const LineType: TocvLineType = LT_8; const Shift: Integer = 0);
|
||||
procedure Circle(const x, y, r: Integer; const Color: TColor = clRed; const Thickness: Integer = 1;
|
||||
const LineType: TocvLineType = LT_8; const Shift: Integer = 0);
|
||||
procedure Ellipse(const CenterX, CenterY: Integer; const Axes: TocvRect; const Angle: double; const start_angle: double;
|
||||
const nd_angle: double; const Color: TColor = clRed; const Thickness: Integer = 1; const LineType: TocvLineType = LT_8;
|
||||
const Shift: Integer = 0);
|
||||
procedure EllipseBox(const Box: TocvRect; const Angle: Single; const Color: TColor = clRed; const Thickness: Integer = 1;
|
||||
Const LineType: TocvLineType = LT_8; const Shift: Integer = 0); overload;
|
||||
procedure EllipseBox(const Box: TCvBox2D; const Color: TColor = clRed; const Thickness: Integer = 1;
|
||||
Const LineType: TocvLineType = LT_8; const Shift: Integer = 0); overload;
|
||||
procedure TextOut(const x, y: Integer; const Text: String; const Shadow: Boolean = False);
|
||||
end;
|
||||
|
||||
IocvImage = interface
|
||||
['{84567F57-A399-4179-AA0F-6F8A2788F89B}']
|
||||
function GetIplImage: pIplImage;
|
||||
@ -55,21 +124,84 @@ Type
|
||||
function Crop(const roi: TCvRect): IocvImage;
|
||||
function GetWidth: Integer;
|
||||
function GetHeight: Integer;
|
||||
function GetCanvas: IocvCanvas;
|
||||
// -------------------------------------------
|
||||
property IpImage: pIplImage Read GetIplImage;
|
||||
property isGray: Boolean read GetisGray;
|
||||
property Width: Integer read GetWidth;
|
||||
property Height: Integer read GetHeight;
|
||||
property isGray: Boolean Read GetisGray;
|
||||
property Width: Integer Read GetWidth;
|
||||
property Height: Integer Read GetHeight;
|
||||
property Canvas: IocvCanvas Read GetCanvas;
|
||||
end;
|
||||
|
||||
TocvFont = class(TInterfacedObject, IocvFont)
|
||||
private
|
||||
FCvFont: TCvFont;
|
||||
FFontColor: TColor;
|
||||
FFontLineType: TocvLineType;
|
||||
procedure CreateOcvFont;
|
||||
protected
|
||||
function GetFontName: string;
|
||||
procedure SetFontName(const Value: string);
|
||||
function GetFontColor: TColor;
|
||||
procedure SetFontColor(const Value: TColor);
|
||||
function GetFontThickness: Integer;
|
||||
procedure SetFontThickness(const Value: Integer);
|
||||
function GetFontLineType: TocvLineType;
|
||||
procedure SetFontLineType(const Value: TocvLineType);
|
||||
function GetFontHScale: Single;
|
||||
procedure SetFontHScale(const Value: Single);
|
||||
function GetFontVScale: Single;
|
||||
procedure SetFontVScale(const Value: Single);
|
||||
function GetCvFont: TCvFont;
|
||||
public
|
||||
constructor Create;
|
||||
property Name: string read GetFontName write SetFontName;
|
||||
property Color: TColor read GetFontColor write SetFontColor;
|
||||
property Thickness: Integer read GetFontThickness write SetFontThickness;
|
||||
property LineType: TocvLineType read GetFontLineType write SetFontLineType;
|
||||
property HScale: Single read GetFontHScale write SetFontHScale;
|
||||
property VScale: Single read GetFontVScale write SetFontVScale;
|
||||
property cvFont: TCvFont Read GetCvFont;
|
||||
end;
|
||||
|
||||
TocvImage = class;
|
||||
|
||||
TocvCanvas = class(TInterfacedObject, IocvCanvas)
|
||||
private
|
||||
FOwner: TocvImage;
|
||||
FocvFont: IocvFont;
|
||||
protected
|
||||
function GetOcvFont: IocvFont;
|
||||
public
|
||||
constructor Create(AOwner: TocvImage);
|
||||
destructor Destroy; override;
|
||||
procedure Rectangle(const x1, y1, x2, y2: Integer; const Color: TColor = clRed; const Thickness: Integer = 1;
|
||||
const LineType: TocvLineType = LT_AA; const Shift: Integer = 0);
|
||||
procedure Circle(const CenterX, CenterY, Radius: Integer; const Color: TColor = clRed; const Thickness: Integer = 1;
|
||||
const LineType: TocvLineType = LT_8; const Shift: Integer = 0);
|
||||
procedure Ellipse(const CenterX, CenterY: Integer; const Axes: TocvRect; const Angle: double; const start_angle: double;
|
||||
const nd_angle: double; const Color: TColor = clRed; const Thickness: Integer = 1; const LineType: TocvLineType = LT_8;
|
||||
const Shift: Integer = 0);
|
||||
procedure EllipseBox(const Box: TocvRect; const Angle: Single; const Color: TColor = clRed; const Thickness: Integer = 1;
|
||||
Const LineType: TocvLineType = LT_8; const Shift: Integer = 0); overload;
|
||||
procedure EllipseBox(const Box: TCvBox2D; const Color: TColor = clRed; const Thickness: Integer = 1;
|
||||
Const LineType: TocvLineType = LT_8; const Shift: Integer = 0); overload;
|
||||
procedure TextOut(const x, y: Integer; const Text: String; const Shadow: Boolean = False);
|
||||
property ocvFont: IocvFont read GetOcvFont;
|
||||
end;
|
||||
|
||||
TocvImage = class(TInterfacedObject, IocvImage)
|
||||
private
|
||||
FImage: pIplImage;
|
||||
FocvCanvas: IocvCanvas;
|
||||
protected
|
||||
function GetIplImage: pIplImage;
|
||||
function GetisGray: Boolean;
|
||||
function GetWidth: Integer;
|
||||
function GetHeight: Integer;
|
||||
function GetCanvas: IocvCanvas;
|
||||
public
|
||||
constructor Create; overload;
|
||||
constructor Create(const AImage: pIplImage); overload;
|
||||
constructor Create(const Bitmap: TBitmap); overload;
|
||||
constructor CreateClone(const AImage: pIplImage);
|
||||
@ -81,7 +213,7 @@ Type
|
||||
function AsBitmap: TBitmap;
|
||||
function Crop(const roi: TCvRect): IocvImage;
|
||||
property IplImage: pIplImage Read GetIplImage;
|
||||
property isGray: Boolean read GetisGray;
|
||||
property isGray: Boolean Read GetisGray;
|
||||
end;
|
||||
|
||||
TOnOcvNotifyCollectionItem = procedure(PrevOperation, Operation, NextOperation: TObject; const IplImage: IocvImage;
|
||||
@ -92,16 +224,11 @@ Type
|
||||
TOnOcvBeforeTransform = procedure(Sender: TObject; const IplImage: IocvImage; Var ContinueTransform: Boolean) of object;
|
||||
TOnOcvContour = procedure(Sender: TObject; const IplImage: IocvImage; const ContourCount: Integer; const Contours: pCvSeq)
|
||||
of object;
|
||||
|
||||
TocvRect = Type TRect;
|
||||
{$IFDEF VER17P}
|
||||
TocvRects = TArray<TocvRect>;
|
||||
{$ELSE}
|
||||
TocvRects = Array of TocvRect;
|
||||
{$ENDIF}
|
||||
TOnOcvHaarCascade = procedure(Sender: TObject; const IplImage: IocvImage; const HaarRects: TocvRects) of object;
|
||||
TOnOcvRect = procedure(Sender: TObject; const IplImage: IocvImage; const Rect: TocvRect) of object;
|
||||
TOnOcvRects = procedure(Sender: TObject; const IplImage: IocvImage; const Rects: TocvRects) of object;
|
||||
TOnOcvCircles = procedure(Sender: TObject; const IplImage: IocvImage; const Circles: TocvCircles) of object;
|
||||
TOnOcvLines = procedure(Sender: TObject; const IplImage: IocvImage; const Lines: TocvLines) of object;
|
||||
|
||||
IocvDataReceiver = interface
|
||||
['{F67DEC9E-CCE0-49D2-AB9B-AD7E1020C5DC}']
|
||||
@ -116,7 +243,7 @@ Type
|
||||
function GetName: string;
|
||||
function GetImage: IocvImage;
|
||||
function GetEnabled: Boolean;
|
||||
property Enabled: Boolean read GetEnabled;
|
||||
property Enabled: Boolean Read GetEnabled;
|
||||
end;
|
||||
|
||||
TocvReceiverList = class(TThreadList) // <IocvDataReceiver>;
|
||||
@ -138,17 +265,17 @@ Type
|
||||
destructor Destroy; override;
|
||||
procedure AddReceiver(const OpenCVVideoReceiver: IocvDataReceiver); virtual;
|
||||
procedure RemoveReceiver(const OpenCVVideoReceiver: IocvDataReceiver); virtual;
|
||||
property Image: IocvImage read GetImage;
|
||||
property Image: IocvImage Read GetImage;
|
||||
end;
|
||||
|
||||
TocvDataReceiver = class(TComponent, IocvDataReceiver)
|
||||
private
|
||||
FocvVideoSource: IocvDataSource;
|
||||
protected
|
||||
procedure TakeImage(const IplImage: IocvImage); virtual;
|
||||
procedure SetVideoSource(const Value: TObject); virtual;
|
||||
procedure SetOpenCVVideoSource(const Value: IocvDataSource); virtual;
|
||||
public
|
||||
procedure TakeImage(const IplImage: IocvImage); virtual;
|
||||
destructor Destroy; override;
|
||||
published
|
||||
property VideoSource: IocvDataSource Read FocvVideoSource write SetOpenCVVideoSource;
|
||||
@ -170,13 +297,15 @@ Type
|
||||
function ocvRect(Left, Top, Right, Bottom: Integer): TocvRect;
|
||||
function ocvRectCenter(cX, cY, Width, Height: Integer): TocvRect;
|
||||
|
||||
procedure GetRGBValue(const AColor: TColor; var r, g, b: byte);
|
||||
function ColorToCvRGB(const Color: TColor): TCvScalar;
|
||||
|
||||
const
|
||||
cLineType: array [TocvLineType] of Integer = (CV_FILLED, 8, CV_AA);
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
ocv.core_c,
|
||||
ocv.imgproc_c,
|
||||
ocv.imgproc.types_c,
|
||||
ocv.highgui_c;
|
||||
uses ocv.imgproc_c, ocv.imgproc.types_c, ocv.highgui_c;
|
||||
|
||||
function ocvRect(Left, Top, Right, Bottom: Integer): TocvRect;
|
||||
begin
|
||||
@ -231,13 +360,13 @@ end;
|
||||
|
||||
procedure TocvDataSource.NotifyReceiver(const IplImage: IocvImage);
|
||||
Var
|
||||
R: Pointer; // IocvDataReceiver;
|
||||
r: Pointer; // IocvDataReceiver;
|
||||
LockList: TList; // <IocvDataReceiver>;
|
||||
begin
|
||||
LockList := FOpenCVVideoReceivers.LockList;
|
||||
try
|
||||
for R in LockList do
|
||||
IocvDataReceiver(R).TakeImage(IplImage);
|
||||
for r in LockList do
|
||||
IocvDataReceiver(r).TakeImage(IplImage);
|
||||
finally
|
||||
FOpenCVVideoReceivers.UnlockList;
|
||||
end;
|
||||
@ -361,6 +490,7 @@ end;
|
||||
|
||||
constructor TocvImage.Create(const AImage: pIplImage);
|
||||
begin
|
||||
Create;
|
||||
FImage := AImage;
|
||||
end;
|
||||
|
||||
@ -368,6 +498,7 @@ constructor TocvImage.Create(const Bitmap: TBitmap);
|
||||
Var
|
||||
bitmapData: PByte;
|
||||
begin
|
||||
Create;
|
||||
Assert(Bitmap.PixelFormat = pf24bit, 'only 24bit'); // Ïîêà òîëüêî òàêîé ôîðìàò - IPL_DEPTH_8U, 3
|
||||
bitmapData := Bitmap.Scanline[0];
|
||||
FImage := cvCreateImage(cvSize(Bitmap.Width, Bitmap.Height), IPL_DEPTH_8U, 3);
|
||||
@ -378,8 +509,14 @@ begin
|
||||
FImage^.roi := nil;
|
||||
end;
|
||||
|
||||
constructor TocvImage.Create;
|
||||
begin
|
||||
FocvCanvas := TocvCanvas.Create(Self);
|
||||
end;
|
||||
|
||||
constructor TocvImage.CreateClone(const AImage: pIplImage);
|
||||
begin
|
||||
Create;
|
||||
FImage := cvCloneImage(AImage);
|
||||
end;
|
||||
|
||||
@ -396,10 +533,16 @@ end;
|
||||
|
||||
destructor TocvImage.Destroy;
|
||||
begin
|
||||
// FocvCanvas.Free;
|
||||
cvReleaseImage(FImage);
|
||||
inherited;
|
||||
end;
|
||||
|
||||
function TocvImage.GetCanvas: IocvCanvas;
|
||||
begin
|
||||
Result := FocvCanvas as IocvCanvas;
|
||||
end;
|
||||
|
||||
function TocvImage.GetHeight: Integer;
|
||||
begin
|
||||
if Assigned(FImage) then
|
||||
@ -462,4 +605,182 @@ begin
|
||||
inherited Remove(Pointer(Item));
|
||||
end;
|
||||
|
||||
procedure GetRGBValue(const AColor: TColor; var r, g, b: byte);
|
||||
Var
|
||||
RGBColor: TColor;
|
||||
begin
|
||||
RGBColor := ColorToRGB(AColor);
|
||||
r := GetRValue(RGBColor);
|
||||
g := GetGValue(RGBColor);
|
||||
b := GetBValue(RGBColor);
|
||||
end;
|
||||
|
||||
function ColorToCvRGB(const Color: TColor): TCvScalar;
|
||||
var
|
||||
r, g, b: byte;
|
||||
begin
|
||||
GetRGBValue(Color, r, g, b);
|
||||
Result := CV_RGB(r, g, b);
|
||||
end;
|
||||
|
||||
{TocvCanvas}
|
||||
|
||||
procedure TocvCanvas.Circle(const CenterX, CenterY, Radius: Integer; const Color: TColor; const Thickness: Integer;
|
||||
const LineType: TocvLineType; const Shift: Integer);
|
||||
begin
|
||||
if Assigned(FOwner) and Assigned(FOwner.FImage) then
|
||||
cvCircle(FOwner.FImage, cvPoint(CenterX, CenterY), Radius, ColorToCvRGB(Color), Thickness, cLineType[LineType], Shift);
|
||||
end;
|
||||
|
||||
constructor TocvCanvas.Create(AOwner: TocvImage);
|
||||
begin
|
||||
FOwner := AOwner;
|
||||
FocvFont := TocvFont.Create;
|
||||
end;
|
||||
|
||||
destructor TocvCanvas.Destroy;
|
||||
begin
|
||||
// FocvFont.Free;
|
||||
inherited;
|
||||
end;
|
||||
|
||||
procedure TocvCanvas.Ellipse(const CenterX, CenterY: Integer; const Axes: TocvRect; const Angle, start_angle, nd_angle: double;
|
||||
const Color: TColor; const Thickness: Integer; const LineType: TocvLineType; const Shift: Integer);
|
||||
begin
|
||||
if Assigned(FOwner) and Assigned(FOwner.FImage) then
|
||||
cvEllipse(FOwner.FImage, cvPoint(CenterX, CenterY), cvSize(Axes.Width, Axes.Height), Angle, start_angle, nd_angle,
|
||||
ColorToCvRGB(Color), Thickness, cLineType[LineType], Shift);
|
||||
end;
|
||||
|
||||
procedure TocvCanvas.EllipseBox(const Box: TCvBox2D; const Color: TColor; const Thickness: Integer; const LineType: TocvLineType;
|
||||
const Shift: Integer);
|
||||
begin
|
||||
if Assigned(FOwner) and Assigned(FOwner.FImage) then
|
||||
cvEllipseBox(FOwner.FImage, Box, ColorToCvRGB(Color), Thickness, cLineType[LineType], Shift);
|
||||
end;
|
||||
|
||||
function TocvCanvas.GetOcvFont: IocvFont;
|
||||
begin
|
||||
Result := FocvFont as IocvFont;
|
||||
end;
|
||||
|
||||
procedure TocvCanvas.EllipseBox(const Box: TocvRect; const Angle: Single; const Color: TColor; const Thickness: Integer;
|
||||
const LineType: TocvLineType; const Shift: Integer);
|
||||
begin
|
||||
EllipseBox(CvBox2D(Box.Left, Box.Top, Box.Width, Box.Height, Angle), Color, Thickness, LineType, Shift);
|
||||
end;
|
||||
|
||||
procedure TocvCanvas.Rectangle(const x1, y1, x2, y2: Integer; const Color: TColor; const Thickness: Integer;
|
||||
const LineType: TocvLineType; const Shift: Integer);
|
||||
begin
|
||||
if Assigned(FOwner) and Assigned(FOwner.FImage) then
|
||||
cvRectangle(FOwner.FImage, cvPoint(x1, y1), cvPoint(x2, y2), ColorToCvRGB(Color), Thickness, cLineType[LineType], Shift);
|
||||
end;
|
||||
|
||||
procedure TocvCanvas.TextOut(const x, y: Integer; const Text: String; const Shadow: Boolean);
|
||||
Var
|
||||
str: pCVChar;
|
||||
Font: TCvFont;
|
||||
begin
|
||||
if Assigned(FOwner) and Assigned(FOwner.FImage) then
|
||||
begin
|
||||
str := @(AnsiString(Text)[1]);
|
||||
Font := ocvFont.cvFont;
|
||||
if Shadow then
|
||||
cvPutText(FOwner.FImage, str, cvPoint(x - 1, y - 1), @Font, CV_RGB(0, 0, 0));
|
||||
cvPutText(FOwner.FImage, str, cvPoint(x, y), @Font, ColorToCvRGB(ocvFont.Color));
|
||||
end;
|
||||
end;
|
||||
|
||||
{TocvFont}
|
||||
|
||||
constructor TocvFont.Create;
|
||||
begin
|
||||
inherited;
|
||||
FillChar(FCvFont, SizeOf(FCvFont), 0);
|
||||
FCvFont.HScale := 0.5;
|
||||
FCvFont.VScale := 0.5;
|
||||
FCvFont.Thickness := 1;
|
||||
FFontLineType := LT_8;
|
||||
FFontColor := clRed;
|
||||
CreateOcvFont;
|
||||
end;
|
||||
|
||||
procedure TocvFont.CreateOcvFont;
|
||||
begin
|
||||
cvInitFont(@FCvFont, CV_FONT_VECTOR0, HScale, VScale, 0, Thickness, cLineType[LineType]);
|
||||
end;
|
||||
|
||||
function TocvFont.GetCvFont: TCvFont;
|
||||
begin
|
||||
Result := FCvFont;
|
||||
end;
|
||||
|
||||
function TocvFont.GetFontColor: TColor;
|
||||
begin
|
||||
Result := FFontColor;
|
||||
end;
|
||||
|
||||
function TocvFont.GetFontHScale: Single;
|
||||
begin
|
||||
Result := FCvFont.HScale;
|
||||
end;
|
||||
|
||||
function TocvFont.GetFontLineType: TocvLineType;
|
||||
begin
|
||||
Result := FFontLineType;
|
||||
end;
|
||||
|
||||
function TocvFont.GetFontName: string;
|
||||
begin
|
||||
Result := FCvFont.nameFont;
|
||||
end;
|
||||
|
||||
function TocvFont.GetFontThickness: Integer;
|
||||
begin
|
||||
Result := FCvFont.Thickness;
|
||||
end;
|
||||
|
||||
function TocvFont.GetFontVScale: Single;
|
||||
begin
|
||||
Result := FCvFont.VScale;
|
||||
end;
|
||||
|
||||
procedure TocvFont.SetFontColor(const Value: TColor);
|
||||
begin
|
||||
FFontColor := Value;
|
||||
FCvFont.Color := ColorToCvRGB(Value);
|
||||
CreateOcvFont;
|
||||
end;
|
||||
|
||||
procedure TocvFont.SetFontHScale(const Value: Single);
|
||||
begin
|
||||
FCvFont.HScale := Value;
|
||||
CreateOcvFont;
|
||||
end;
|
||||
|
||||
procedure TocvFont.SetFontLineType(const Value: TocvLineType);
|
||||
begin
|
||||
FFontLineType := Value;
|
||||
CreateOcvFont;
|
||||
end;
|
||||
|
||||
procedure TocvFont.SetFontName(const Value: string);
|
||||
begin
|
||||
FCvFont.nameFont := pCVChar(AnsiString(Value));
|
||||
CreateOcvFont;
|
||||
end;
|
||||
|
||||
procedure TocvFont.SetFontThickness(const Value: Integer);
|
||||
begin
|
||||
FCvFont.Thickness := Value;
|
||||
CreateOcvFont;
|
||||
end;
|
||||
|
||||
procedure TocvFont.SetFontVScale(const Value: Single);
|
||||
begin
|
||||
FCvFont.VScale := Value;
|
||||
CreateOcvFont;
|
||||
end;
|
||||
|
||||
end.
|
||||
|
1305
source/ocv.contrib.pas
Normal file
1305
source/ocv.contrib.pas
Normal file
File diff suppressed because it is too large
Load Diff
@ -84,7 +84,6 @@
|
||||
// *************************************************************************************************
|
||||
|
||||
{$I OpenCV.inc}
|
||||
|
||||
{$IFDEF DEBUG}
|
||||
{$A8,B-,C+,D+,E-,F-,G+,H+,I+,J+,K-,L+,M-,N+,O-,P+,Q+,R+,S-,T-,U-,V+,W+,X+,Y+,Z1}
|
||||
{$ELSE}
|
||||
@ -99,7 +98,6 @@
|
||||
{$IFDEF VER12P}
|
||||
{$POINTERMATH ON}
|
||||
{$ENDIF}
|
||||
|
||||
unit ocv.core.types_c;
|
||||
|
||||
interface
|
||||
@ -131,24 +129,23 @@ type
|
||||
CVChar = AnsiChar;
|
||||
{$IFNDEF VER16P}
|
||||
{$IFDEF CLR}
|
||||
{$IFDEF VER11P}
|
||||
{$IFDEF VER11P}
|
||||
NativeInt = size_t;
|
||||
NativeUInt = size_t;
|
||||
{$ELSE}
|
||||
{$ELSE}
|
||||
NativeInt = Integer;
|
||||
NativeUInt = Cardinal;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ELSE}
|
||||
{$IFDEF FPC}
|
||||
{$IFDEF FPC}
|
||||
NativeInt = SizeInt;
|
||||
NativeUInt = SizeUInt;
|
||||
{$ELSE}
|
||||
{$ELSE}
|
||||
NativeInt = Integer;
|
||||
NativeUInt = Cardinal;
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
{$ENDIF}
|
||||
|
||||
{$ENDIF}
|
||||
function strdup(const str: pCVChar): pCVChar;
|
||||
function cv_stricmp(const str1, str2: pCVChar): Integer;
|
||||
procedure strcpy(var str1: pCVChar; const str2: pCVChar); overload;
|
||||
@ -287,8 +284,7 @@ const
|
||||
// CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1;
|
||||
// return rng;
|
||||
// }
|
||||
function cvRNG(seed: int64 = -1): TCvRNG; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function cvRNG(seed: int64 = -1): TCvRNG; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
(****************************************************************************************\
|
||||
* Image cType (IplImage) *
|
||||
****************************************************************************************)
|
||||
@ -477,14 +473,13 @@ const
|
||||
{$EXTERNALSYM CV_USRTYPE1}
|
||||
CV_MAT_DEPTH_MASK = (CV_DEPTH_MAX - 1);
|
||||
{$EXTERNALSYM CV_MAT_DEPTH_MASK}
|
||||
function CV_8UC1: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function CV_8UC1: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
{$EXTERNALSYM CV_8UC1}
|
||||
(*
|
||||
CV_8UC2 = CV_MAKETYPE(CV_8U, 2);
|
||||
{$EXTERNALSYM CV_8UC2}
|
||||
*)
|
||||
function CV_8UC3: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_8UC3: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
{$EXTERNALSYM CV_8UC3}
|
||||
(*
|
||||
CV_8UC4 = CV_MAKETYPE(CV_8U, 4);
|
||||
@ -527,8 +522,7 @@ function CV_8UC3: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
// const
|
||||
// CV_32SC2 = CV_MAKETYPE(CV_32S, 2);
|
||||
{$EXTERNALSYM CV_32SC2}
|
||||
function CV_32SC2: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function CV_32SC2: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
(*
|
||||
const
|
||||
CV_32SC3 = CV_MAKETYPE(CV_32S, 3);
|
||||
@ -546,9 +540,9 @@ function CV_32SC2: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
CV_32FC1 = CV_MAKETYPE(CV_32F, 1);
|
||||
{$EXTERNALSYM CV_32FC1}
|
||||
*)
|
||||
function CV_32FC2: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_32FC2: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
{$EXTERNALSYM CV_32FC2}
|
||||
function CV_32FC3: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_32FC3: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
{$EXTERNALSYM CV_32FC3}
|
||||
(*
|
||||
const
|
||||
@ -560,11 +554,11 @@ function CV_32FC3: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
CV_32FC(n)CV_MAKETYPE(CV_32F, (n));
|
||||
*)
|
||||
|
||||
function CV_64FC1: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_64FC1: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
{$EXTERNALSYM CV_64FC1}
|
||||
function CV_64FC2: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_64FC2: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
{$EXTERNALSYM CV_64FC2}
|
||||
function CV_64FC3: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_64FC3: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
{$EXTERNALSYM CV_64FC3}
|
||||
(*
|
||||
const
|
||||
@ -578,7 +572,7 @@ function CV_64FC3: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
// * get reference to pixel at (col,row),
|
||||
// for multi-channel images (col) should be multiplied by number of channels */
|
||||
function CV_IMAGE_ELEM(image: pIplImage; size_elemtype, row, col: Integer): Pointer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_IMAGE_ELEM(image: pIplImage; size_elemtype, row, col: Integer): Pointer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
// (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)])
|
||||
|
||||
const
|
||||
@ -780,7 +774,7 @@ type
|
||||
z: Single;
|
||||
end;
|
||||
|
||||
function cvPoint3D32f(const x, y, z: Double): TCvPoint3D32f; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function cvPoint3D32f(const x, y, z: Single): TCvPoint3D32f; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
|
||||
Type
|
||||
TCvPoint2D64f = record
|
||||
@ -1277,16 +1271,14 @@ const
|
||||
/// / >> Following declaration is a macro definition!
|
||||
|
||||
// CV_IS_SEQ_CLOSED(seq)(((seq)^.flags and CV_SEQ_FLAG_CLOSED) <> 0);
|
||||
function CV_IS_SEQ_CLOSED(const Seq: pCvSeq): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function CV_IS_SEQ_CLOSED(const Seq: pCvSeq): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
/// / >> Following declaration is a macro definition!
|
||||
// const
|
||||
// CV_IS_SEQ_CONVEX(seq)0;
|
||||
|
||||
// Following declaration is a macro definition!
|
||||
// CV_IS_SEQ_HOLE(seq)(((seq)^.flags and CV_SEQ_FLAG_HOLE) <> 0);
|
||||
function CV_IS_SEQ_HOLE(const Seq: pCvSeq): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function CV_IS_SEQ_HOLE(const Seq: pCvSeq): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
/// / >> Following declaration is a macro definition!
|
||||
// const
|
||||
// CV_IS_SEQ_SIMPLE(seq)1;
|
||||
@ -1370,11 +1362,11 @@ type
|
||||
cvGetSeqElem( (CvSeq*)(seq), (index) )))
|
||||
}
|
||||
{$IFDEF VER15P}
|
||||
function CV_SEQ_ELEM(Seq: pCvSeq; const size_of_elem: Integer; index: Integer): Pointer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
{#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) )}
|
||||
function CV_GET_SEQ_ELEM(const size_of_elem: Integer; Seq: pCvSeq; index: Integer): Pointer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
{$ENDIF VER15P}
|
||||
|
||||
function CV_SEQ_ELEM(Seq: pCvSeq; const size_of_elem: Integer; index: Integer): Pointer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
{#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) )}
|
||||
function CV_GET_SEQ_ELEM(const size_of_elem: Integer; Seq: pCvSeq; index: Integer): Pointer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
{$ENDIF VER15P}
|
||||
// (* Add element to sequence: *)
|
||||
// // >> Following declaration is a macro definition!
|
||||
// const CV_WRITE_SEQ_ELEM_VAR(elem_ptr, writer);
|
||||
@ -1388,8 +1380,7 @@ function CV_GET_SEQ_ELEM(const size_of_elem: Integer; Seq: pCvSeq; index: Intege
|
||||
// Assert((writer).ptr <= (writer).block_max - SizeOf(elem));
|
||||
// memcpy((writer).ptr, and (elem), SizeOf(elem)); (writer).ptr := mod +SizeOf(elem) then; end;
|
||||
|
||||
function CV_CAST_8U(t: Integer): uchar; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function CV_CAST_8U(t: Integer): uchar; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
(*
|
||||
/* Move reader position forward: */
|
||||
#define CV_NEXT_SEQ_ELEM( elem_size, reader ) \
|
||||
@ -1418,7 +1409,8 @@ procedure CV_NEXT_SEQ_ELEM(const elem_size: Integer; const Reader: TCvSeqReader)
|
||||
CV_NEXT_SEQ_ELEM( sizeof(elem), reader ) \
|
||||
}
|
||||
*)
|
||||
procedure CV_READ_SEQ_ELEM(const Elem: Pointer; const Reader: TCvSeqReader; const SizeOfElem: Integer); // {$IFDEF VER9P}inline;{$ENDIF}
|
||||
procedure CV_READ_SEQ_ELEM(const Elem: Pointer; const Reader: TCvSeqReader; const SizeOfElem: Integer);
|
||||
// {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
|
||||
// (* Read element and move read position backward: *)
|
||||
@ -1607,7 +1599,7 @@ const
|
||||
{$EXTERNALSYM CV_NODE_TYPE_MASK}
|
||||
// >> Following declaration is a macro definition!
|
||||
// CV_NODE_TYPE(flags)((flags) and CV_NODE_TYPE_MASK);
|
||||
function CV_NODE_TYPE(const flags: Integer): Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_NODE_TYPE(const flags: Integer): Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
|
||||
const
|
||||
(*file node flags*)
|
||||
@ -1620,13 +1612,12 @@ const
|
||||
CV_NODE_NAMED = 64;
|
||||
{$EXTERNALSYM CV_NODE_NAMED}
|
||||
// CV_NODE_IS_INT(flags) (CV_NODE_TYPE(flags) == CV_NODE_INT)
|
||||
function CV_NODE_IS_INT(const flags: Integer): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_NODE_IS_INT(const flags: Integer): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
// CV_NODE_IS_REAL(flags) (CV_NODE_TYPE(flags) == CV_NODE_REAL)
|
||||
function CV_NODE_IS_REAL(const flags: Integer): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function CV_NODE_IS_REAL(const flags: Integer): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
// const CV_NODE_IS_INT(flags)(CV_NODE_TYPE(flags) = CV_NODE_INT)
|
||||
// const CV_NODE_IS_REAL(flags) (CV_NODE_TYPE(flags) = CV_NODE_REAL)
|
||||
function CV_NODE_IS_STRING(const flags: Integer): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_NODE_IS_STRING(const flags: Integer): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
// (CV_NODE_TYPE(flags) = CV_NODE_STRING)
|
||||
// const CV_NODE_IS_SEQ(flags) (CV_NODE_TYPE(flags) = CV_NODE_SEQ)
|
||||
// const CV_NODE_IS_MAP(flags) (CV_NODE_TYPE(flags) = CV_NODE_MAP)
|
||||
@ -1725,10 +1716,10 @@ type
|
||||
(* End of file.*)
|
||||
|
||||
// #define CV_SWAP(a,b,t) ((t) = (a), (a) = (b), (b) = (t))
|
||||
procedure CV_SWAP(var a, b, t: pIplImage); {$IFDEF VER9P}inline;{$ENDIF} overload;
|
||||
procedure CV_SWAP(var a, b, t: pCvPoint2D32f); {$IFDEF VER9P}inline;{$ENDIF} overload;
|
||||
procedure CV_SWAP(var a, b, t: pCvMat); {$IFDEF VER9P}inline;{$ENDIF} overload;
|
||||
procedure CV_SWAP(var a, b, t: Pointer); {$IFDEF VER9P}inline;{$ENDIF} overload;
|
||||
procedure CV_SWAP(var a, b, t: pIplImage); {$IFDEF VER9P}inline; {$ENDIF} overload;
|
||||
procedure CV_SWAP(var a, b, t: pCvPoint2D32f); {$IFDEF VER9P}inline; {$ENDIF} overload;
|
||||
procedure CV_SWAP(var a, b, t: pCvMat); {$IFDEF VER9P}inline; {$ENDIF} overload;
|
||||
procedure CV_SWAP(var a, b, t: Pointer); {$IFDEF VER9P}inline; {$ENDIF} overload;
|
||||
|
||||
// {$IFNDEF MIN}
|
||||
// {$HPPEMIT '# define MIN(a,b) ((a) > (b) ? (b) : (a))'}
|
||||
@ -1930,8 +1921,7 @@ procedure CV_SWAP(var a, b, t: Pointer); {$IFDEF VER9P}inline;{$ENDIF} overload;
|
||||
//
|
||||
// const CV_IS_MASK_ARR(mat)(((mat)^.cType and (CV_MAT_TYPE_MASK and ~ CV_8SC1)) = 0)
|
||||
|
||||
function CV_ARE_TYPES_EQ(const mat1, mat2: pCvMat): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function CV_ARE_TYPES_EQ(const mat1, mat2: pCvMat): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
// const CV_ARE_CNS_EQ(mat1, mat2)((((mat1)^.cType xor (mat2)^.cType) and CV_MAT_CN_MASK) = 0)
|
||||
//
|
||||
// const CV_ARE_DEPTHS_EQ(mat1, mat2)((((mat1)^.cType xor (mat2)^.cType) and CV_MAT_DEPTH_MASK) = 0)
|
||||
@ -2034,12 +2024,9 @@ function cvIplDepth(_type: Integer): Integer; // {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
// (* ****************************** CvPoint and variants ********************************** *)
|
||||
|
||||
function CvPoint2D32f(x, y: Double): TCvPoint2D32f; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function cvPointTo32f(point: TCvPoint): TCvPoint2D32f; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function cvPointFrom32f(point: TCvPoint2D32f): TCvPoint; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function CvPoint2D32f(x, y: Single): TCvPoint2D32f; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function cvPointTo32f(point: TCvPoint): TCvPoint2D32f; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function cvPointFrom32f(point: TCvPoint2D32f): TCvPoint; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
// CV_INLINE CvPoint3D32f CvPoint3D32f(Double x, Double y, Double z)
|
||||
//
|
||||
// begin
|
||||
@ -2116,8 +2103,7 @@ function cvPointFrom32f(point: TCvPoint2D32f): TCvPoint; {$IFDEF VER9P}inline;{$
|
||||
// return scalar;
|
||||
// }
|
||||
|
||||
function cvRealScalar(val0: Double): TCvScalar; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function cvRealScalar(val0: Double): TCvScalar; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
// (*************************************************************************************** *)
|
||||
// (* Dynamic Data structures *)
|
||||
// (*************************************************************************************** *)
|
||||
@ -2138,8 +2124,7 @@ function cvRealScalar(val0: Double): TCvScalar; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
// (* ********************************** CvTermCriteria ************************************ *)
|
||||
// (* CV_INLINE CvTermCriteria CvTermCriteria(Integer cType, Integer max_iter, Double epsilon)
|
||||
function CvTermCriteria(_type: Integer; max_iter: Integer; epsilon: Double): TCvTermCriteria; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
|
||||
function CvTermCriteria(_type: Integer; max_iter: Integer; epsilon: Double): TCvTermCriteria; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
(*
|
||||
CV_INLINE int cvFloor( double value )
|
||||
{
|
||||
@ -2164,13 +2149,14 @@ function CvTermCriteria(_type: Integer; max_iter: Integer; epsilon: Double): TCv
|
||||
#endif
|
||||
}
|
||||
*)
|
||||
function cvFloor(value: Double): Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function cvScalarAll(val0123: Double): TCvScalar; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CvPoint(const x, y: Integer): TCvPoint; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CvSize(const width, height: Integer): TCvSize; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CvScalar(const val0: Double; const val1: Double = 0; const val2: Double = 0; const val3: Double = 0): TCvScalar; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function cvRandInt(Var rng: TCvRNG): Cardinal; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CvRect(Const x, y, width, height: Integer): TCvRect; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function cvFloor(value: Double): Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function cvScalarAll(val0123: Double): TCvScalar; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function CvPoint(const x, y: Integer): TCvPoint; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function CvSize(const width, height: Integer): TCvSize; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function CvScalar(const val0: Double; const val1: Double = 0; const val2: Double = 0; const val3: Double = 0): TCvScalar;
|
||||
{$IFDEF VER9P}inline; {$ENDIF}
|
||||
function cvRandInt(Var rng: TCvRNG): Cardinal; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function CvRect(Const x, y, width, height: Integer): TCvRect; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function cvRound(value: Double): Integer;
|
||||
|
||||
const
|
||||
@ -2206,30 +2192,32 @@ function CV_MAT_TYPE(const flags: Integer): Integer;
|
||||
function CV_ELEM_SIZE1(const _type: Integer): Integer;
|
||||
function CV_ELEM_SIZE(const _type: Integer): Integer;
|
||||
function CV_MAT_CN(const flags: Integer): Integer;
|
||||
function CV_32FC1: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_32SC1: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_MAKETYPE(depth, cn: Integer): Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_32FC1: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function CV_32SC1: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function CV_MAKETYPE(depth, cn: Integer): Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
// #define CV_MAT_ELEM( mat, elemtype, row, col )
|
||||
// (*(elemtype*)CV_MAT_ELEM_PTR_FAST( mat, row, col, sizeof(elemtype)))
|
||||
function CV_MAT_ELEM(const mat: TCvMat; const elemsize: Integer; const row, col: Integer): Pointer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_MAT_ELEM(const mat: TCvMat; const elemsize: Integer; const row, col: Integer): Pointer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
// #define CV_MAT_ELEM_PTR_FAST( mat, row, col, pix_size )
|
||||
// (assert( (unsigned)(row) < (unsigned)(mat).rows &&
|
||||
// (unsigned)(col) < (unsigned)(mat).cols ),
|
||||
// (mat).data.ptr + (size_t)(mat).step*(row) + (pix_size)*(col))
|
||||
function CV_MAT_ELEM_PTR_FAST(const mat: TCvMat; const row, col, pix_size: Integer): Pointer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_MAT_ELEM_PTR_FAST(const mat: TCvMat; const row, col, pix_size: Integer): Pointer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
function iif(const Conditional: Boolean; const ifTrue, ifFalse: Variant): Variant; {$IFDEF VER9P}inline; {$ENDIF} overload;
|
||||
function iif(const Conditional: Boolean; const ifTrue, ifFalse: Pointer): Pointer; {$IFDEF VER9P}inline; {$ENDIF} overload;
|
||||
|
||||
function iif(const Conditional: Boolean; const ifTrue, ifFalse: Variant): Variant; {$IFDEF VER9P}inline;{$ENDIF} overload;
|
||||
function iif(const Conditional: Boolean; const ifTrue, ifFalse: Pointer): Pointer; {$IFDEF VER9P}inline;{$ENDIF} overload;
|
||||
function CvBox2D(const cX, cY, width, height, angle: Single): TCvBox2D;
|
||||
function CvSize2D32f(const width, height: Single): TCvSize2D32f;
|
||||
|
||||
implementation
|
||||
|
||||
uses
|
||||
ocv.core_c,
|
||||
{$IFDEF VER15P}
|
||||
{$IFDEF VER15P}
|
||||
System.SysUtils;
|
||||
{$ELSE}
|
||||
SysUtils;
|
||||
{$ENDIF VER15P}
|
||||
{$ELSE}
|
||||
SysUtils;
|
||||
{$ENDIF VER15P}
|
||||
|
||||
function strdup(const str: pCVChar): pCVChar;
|
||||
begin
|
||||
@ -2383,7 +2371,7 @@ begin
|
||||
Result := Round(value);
|
||||
end;
|
||||
|
||||
function iif(const Conditional: Boolean; const ifTrue, ifFalse: Variant): Variant; {$IFDEF VER9P}inline;{$ENDIF} overload;
|
||||
function iif(const Conditional: Boolean; const ifTrue, ifFalse: Variant): Variant; {$IFDEF VER9P}inline; {$ENDIF} overload;
|
||||
begin
|
||||
if Conditional then
|
||||
Result := ifTrue
|
||||
@ -2391,7 +2379,7 @@ begin
|
||||
Result := ifFalse;
|
||||
end;
|
||||
|
||||
function iif(const Conditional: Boolean; const ifTrue, ifFalse: Pointer): Pointer; {$IFDEF VER9P}inline;{$ENDIF} overload;
|
||||
function iif(const Conditional: Boolean; const ifTrue, ifFalse: Pointer): Pointer; {$IFDEF VER9P}inline; {$ENDIF} overload;
|
||||
begin
|
||||
if Conditional then
|
||||
Result := ifTrue
|
||||
@ -2417,12 +2405,13 @@ begin
|
||||
Result := CV_NODE_TYPE(flags) = CV_NODE_REAL;
|
||||
end;
|
||||
|
||||
function CV_NODE_IS_STRING(const flags: Integer): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_NODE_IS_STRING(const flags: Integer): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
Result := CV_NODE_TYPE(flags) = CV_NODE_STRING
|
||||
end;
|
||||
|
||||
procedure CV_READ_SEQ_ELEM(const Elem: Pointer; const Reader: TCvSeqReader; const SizeOfElem: Integer); // {$IFDEF VER9P}inline;{$ENDIF}
|
||||
procedure CV_READ_SEQ_ELEM(const Elem: Pointer; const Reader: TCvSeqReader; const SizeOfElem: Integer);
|
||||
// {$IFDEF VER9P}inline;{$ENDIF}
|
||||
begin
|
||||
// assert( (reader).seq->elem_size == sizeof(elem));
|
||||
Assert(Reader.Seq^.elem_size = SizeOfElem);
|
||||
@ -2480,7 +2469,7 @@ begin
|
||||
Result.y := y;
|
||||
end;
|
||||
|
||||
function cvPoint3D32f(const x, y, z: Double): TCvPoint3D32f; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function cvPoint3D32f(const x, y, z: Single): TCvPoint3D32f; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
Result.x := x;
|
||||
Result.y := y;
|
||||
@ -2525,13 +2514,14 @@ begin
|
||||
end;
|
||||
|
||||
{$IFDEF VER15P}
|
||||
|
||||
function CV_GET_SEQ_ELEM;
|
||||
begin
|
||||
{#define CV_GET_SEQ_ELEM( elem_type, seq, index ) CV_SEQ_ELEM( (seq), elem_type, (index) )}
|
||||
Result := CV_SEQ_ELEM(Seq, size_of_elem, index);
|
||||
end;
|
||||
|
||||
function CV_SEQ_ELEM(Seq: pCvSeq; const size_of_elem: Integer; index: Integer): Pointer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_SEQ_ELEM(Seq: pCvSeq; const size_of_elem: Integer; index: Integer): Pointer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
// assert(sizeof((seq)->first[0]) == sizeof(CvSeqBlock) && (seq)->elem_size == sizeof(elem_type))
|
||||
Assert(Assigned(Seq^.first) and (SizeOf(Seq^.first[0]) = SizeOf(TCvSeqBlock)) and (Seq^.elem_size = size_of_elem));
|
||||
@ -2545,7 +2535,7 @@ begin
|
||||
end;
|
||||
{$ENDIF VER15P}
|
||||
|
||||
function CV_8UC1: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_8UC1: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
Result := CV_MAKETYPE(CV_8U, 1);
|
||||
end;
|
||||
@ -2555,7 +2545,7 @@ begin
|
||||
Result := CV_MAKETYPE(CV_32F, 2);
|
||||
end;
|
||||
|
||||
function CV_32FC3: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_32FC3: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
Result := CV_MAKETYPE(CV_32F, 3);
|
||||
end;
|
||||
@ -2570,7 +2560,7 @@ begin
|
||||
Result := CV_MAKETYPE(CV_64F, 2);
|
||||
end;
|
||||
|
||||
function CV_64FC3: Integer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_64FC3: Integer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
Result := CV_MAKETYPE(CV_64F, 3);
|
||||
end;
|
||||
@ -2586,13 +2576,14 @@ begin
|
||||
Result := Assigned(ptr) and (pCvSetElem(ptr)^.flags >= 0);
|
||||
end;
|
||||
|
||||
function CV_IMAGE_ELEM(image: pIplImage; size_elemtype, row, col: Integer): Pointer; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_IMAGE_ELEM(image: pIplImage; size_elemtype, row, col: Integer): Pointer; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
// (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)])
|
||||
Result := {$IFDEF D7}Pointer({$ENDIF D7}{$IFDEF VER9P}pByte{$ELSE}Integer{$ENDIF}(image^.imageData) + image^.widthStep * row + col * size_elemtype{$IFDEF D7}){$ENDIF D7};
|
||||
Result := {$IFDEF D7}Pointer({$ENDIF D7}{$IFDEF VER9P}pByte{$ELSE}Integer{$ENDIF}(image^.imageData) + image^.widthStep * row +
|
||||
col * size_elemtype{$IFDEF D7}){$ENDIF D7};
|
||||
end;
|
||||
|
||||
function cvRealScalar(val0: Double): TCvScalar; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function cvRealScalar(val0: Double): TCvScalar; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
Result.val[0] := val0;
|
||||
Result.val[1] := 0;
|
||||
@ -2600,7 +2591,7 @@ begin
|
||||
Result.val[3] := 0;
|
||||
end;
|
||||
|
||||
function cvRNG(seed: int64 = -1): TCvRNG; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function cvRNG(seed: int64 = -1): TCvRNG; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
// CvRNG rng = seed ? (uint64)seed : (uint64)(int64)-1;
|
||||
Result := iif(seed > 0, seed, uint64(int64(-1)));
|
||||
@ -2623,24 +2614,37 @@ begin
|
||||
depth := CV_MAT_DEPTH(_type);
|
||||
Result := CV_ELEM_SIZE1(depth) * 8;
|
||||
if (depth = CV_8S) or (depth = CV_16S) or (depth = CV_32S) then
|
||||
Result := Result or IPL_DEPTH_SIGN;
|
||||
Result := Result or Integer(IPL_DEPTH_SIGN);
|
||||
end;
|
||||
|
||||
function CV_ARE_TYPES_EQ(const mat1, mat2: pCvMat): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_ARE_TYPES_EQ(const mat1, mat2: pCvMat): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
Result := ((((mat1)^._type xor (mat2)^._type) and CV_MAT_TYPE_MASK) = 0);
|
||||
end;
|
||||
|
||||
function CV_IS_SEQ_CLOSED(const Seq: pCvSeq): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_IS_SEQ_CLOSED(const Seq: pCvSeq): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
Result := (Seq^.flags and CV_SEQ_FLAG_CLOSED) <> 0;
|
||||
end;
|
||||
|
||||
function CV_IS_SEQ_HOLE(const Seq: pCvSeq): Boolean; {$IFDEF VER9P}inline;{$ENDIF}
|
||||
function CV_IS_SEQ_HOLE(const Seq: pCvSeq): Boolean; {$IFDEF VER9P}inline; {$ENDIF}
|
||||
begin
|
||||
Result := (Seq^.flags and CV_SEQ_FLAG_HOLE) <> 0;
|
||||
end;
|
||||
|
||||
function CvBox2D(const cX, cY, width, height, angle: Single): TCvBox2D;
|
||||
begin
|
||||
Result.center := CvPoint2D32f(cX, cY);
|
||||
Result.size := CvSize2D32f(width, height);
|
||||
Result.angle := angle;
|
||||
end;
|
||||
|
||||
function CvSize2D32f(const width, height: Single): TCvSize2D32f;
|
||||
begin
|
||||
Result.width := width;
|
||||
Result.height := height;
|
||||
end;
|
||||
|
||||
initialization
|
||||
|
||||
CV_SEQ_ELTYPE_POINT := CV_32SC2;
|
||||
|
Loading…
Reference in New Issue
Block a user