Signed-off-by: Laentir Valetov <laex@bk.ru>
This commit is contained in:
Laentir Valetov 2019-03-04 17:29:54 +04:00
parent e8c84f9a6d
commit bf6d45180f
8 changed files with 46 additions and 21 deletions

2
.gitignore vendored
View File

@ -17,7 +17,7 @@ CVAutoInstaller/
#Files #Files
*.exe *.exe
!CheckCVDep.exe !/CheckCVDep/CheckCVDep.exe
#*.dll #*.dll
*.ini *.ini
*.bsc *.bsc

Binary file not shown.

View File

@ -1,7 +1,7 @@
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup> <PropertyGroup>
<ProjectGuid>{9F27EBDE-3B7A-4B88-8E68-90DCA8A35F81}</ProjectGuid> <ProjectGuid>{9F27EBDE-3B7A-4B88-8E68-90DCA8A35F81}</ProjectGuid>
<ProjectVersion>18.2</ProjectVersion> <ProjectVersion>18.6</ProjectVersion>
<FrameworkType>VCL</FrameworkType> <FrameworkType>VCL</FrameworkType>
<MainSource>cCameraCapture.dpr</MainSource> <MainSource>cCameraCapture.dpr</MainSource>
<Base>True</Base> <Base>True</Base>
@ -192,7 +192,7 @@
<Excluded_Packages Name="$(BDSBIN)\dclofficexp200.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages> <Excluded_Packages Name="$(BDSBIN)\dclofficexp200.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
</Excluded_Packages> </Excluded_Packages>
</Delphi.Personality> </Delphi.Personality>
<Deployment Version="2"/> <Deployment Version="3"/>
<Platforms> <Platforms>
<Platform value="Win32">True</Platform> <Platform value="Win32">True</Platform>
<Platform value="Win64">True</Platform> <Platform value="Win64">True</Platform>

View File

@ -24,10 +24,6 @@ object MainForm: TMainForm
VideoSource = ocvmgprtn1 VideoSource = ocvmgprtn1
Frames = <> Frames = <>
Align = alClient Align = alClient
ExplicitLeft = 52
ExplicitTop = 70
ExplicitWidth = 285
ExplicitHeight = 297
end end
object ocvmgprtn1: TocvImageOperation object ocvmgprtn1: TocvImageOperation
VideoSource = ocvcmrsrc1 VideoSource = ocvcmrsrc1

View File

@ -136,7 +136,7 @@ type
constructor Create(AOwner: TComponent); override; constructor Create(AOwner: TComponent); override;
end; end;
TocvResolution = (r160x120, r320x240, r424x240, r640x360, r800x448, r960x544, r1280x720); TocvResolution = (r160x120, r320x240, r424x240, r640x360, r800x448, r960x544, r1280x720, rCustom);
TocvCameraSource = class(TocvCaptureSource) TocvCameraSource = class(TocvCaptureSource)
protected protected
@ -144,6 +144,8 @@ type
private private
FCaptureSource: TocvCameraCaptureSource; FCaptureSource: TocvCameraCaptureSource;
FResolution: TocvResolution; FResolution: TocvResolution;
FCustomHeight: Cardinal;
FCustomWidth: Cardinal;
procedure SetCameraSource(const Value: TocvCameraCaptureSource); procedure SetCameraSource(const Value: TocvCameraCaptureSource);
procedure SetResolution(const Value: TocvResolution); procedure SetResolution(const Value: TocvResolution);
procedure SetCameraResolution; procedure SetCameraResolution;
@ -152,6 +154,8 @@ type
published published
property Camera: TocvCameraCaptureSource read FCaptureSource write SetCameraSource default CAP_ANY; property Camera: TocvCameraCaptureSource read FCaptureSource write SetCameraSource default CAP_ANY;
property Resolution: TocvResolution read FResolution write SetResolution default r160x120; property Resolution: TocvResolution read FResolution write SetResolution default r160x120;
property CustomWidth: Cardinal read FCustomWidth write FCustomWidth default 0;
property CustomHeight: Cardinal read FCustomHeight write FCustomHeight default 0;
end; end;
TocvFileSource = class(TocvCaptureSource) TocvFileSource = class(TocvCaptureSource)
@ -271,7 +275,7 @@ Type
Const Const
CameraResolution: array [TocvResolution] of TCameraResolution = ((cWidth: 160; cHeight: 120), (cWidth: 320; CameraResolution: array [TocvResolution] of TCameraResolution = ((cWidth: 160; cHeight: 120), (cWidth: 320;
cHeight: 240), (cWidth: 424; cHeight: 240), (cWidth: 640; cHeight: 360), (cWidth: 800; cHeight: 448), (cWidth: 960; cHeight: 240), (cWidth: 424; cHeight: 240), (cWidth: 640; cHeight: 360), (cWidth: 800; cHeight: 448), (cWidth: 960;
cHeight: 544), (cWidth: 1280; cHeight: 720)); cHeight: 544), (cWidth: 1280; cHeight: 720), (cWidth: 0; cHeight: 0));
{ TOpenCVCameraThread } { TOpenCVCameraThread }
@ -389,13 +393,27 @@ begin
end; end;
procedure TocvCameraSource.SetCameraResolution; procedure TocvCameraSource.SetCameraResolution;
Var
cR: TCameraResolution;
begin begin
if (FResolution = rCustom) then
begin
if (FCustomWidth > 0) and (FCustomHeight > 0) then
begin
cR.cWidth := FCustomWidth;
cR.cHeight := FCustomHeight;
end
else
cR := CameraResolution[r160x120];
end
else
cR := CameraResolution[FResolution];
{$IFDEF DelphiOCVVersion_30} {$IFDEF DelphiOCVVersion_30}
FCapture.Prop[CV_CAP_PROP_FRAME_WIDTH] := CameraResolution[FResolution].cWidth; FCapture.Prop[CV_CAP_PROP_FRAME_WIDTH] := cR.cWidth;
FCapture.Prop[CV_CAP_PROP_FRAME_HEIGHT] := CameraResolution[FResolution].cHeight; FCapture.Prop[CV_CAP_PROP_FRAME_HEIGHT] := cR.cHeight;
{$ELSE} {$ELSE}
cvSetCaptureProperty(FCapture, CV_CAP_PROP_FRAME_WIDTH, CameraResolution[FResolution].cWidth); cvSetCaptureProperty(FCapture, CV_CAP_PROP_FRAME_WIDTH, cR.cWidth);
cvSetCaptureProperty(FCapture, CV_CAP_PROP_FRAME_HEIGHT, CameraResolution[FResolution].cHeight); cvSetCaptureProperty(FCapture, CV_CAP_PROP_FRAME_HEIGHT, cR.cHeight);
{$ENDIF} {$ENDIF}
end; end;

View File

@ -414,7 +414,7 @@ const
/// ///
{$I haarcascade.inc} {$I haarcascade.inc}
{$R haarcascade.res haarcascade.rc} {$R haarcascade.res haarcascade.rc}
{.$R haarcascade.res} {$R haarcascade.res}
implementation implementation

View File

@ -52,6 +52,14 @@ unit ocv.core.types_c;
interface interface
Uses
{$IFDEF HAS_UNITSCOPE}
Winapi.Windows
{$ELSE}
Windows
{$ENDIF}
;
const const
// Íàèìåíüøåå ÷èñëî äëÿ êîòîðîãî âûïîëíÿåòñÿ óñëîâèå 1.0+DBL_EPSILON <> 1.0 // Íàèìåíüøåå ÷èñëî äëÿ êîòîðîãî âûïîëíÿåòñÿ óñëîâèå 1.0+DBL_EPSILON <> 1.0
DBL_EPSILON = 2.2204460492503131E-016; DBL_EPSILON = 2.2204460492503131E-016;
@ -66,7 +74,7 @@ type
size_t = NativeUInt; size_t = NativeUInt;
pFloat = ^Float; pFloat = ^Float;
ppFloat = ^pFloat; ppFloat = ^pFloat;
pPointer = System.PPointer;//^Pointer; pPointer = System.pPointer; // ^Pointer;
ppvoid = pPointer; ppvoid = pPointer;
TSingleArray1D = array [0 .. 1] of Single; TSingleArray1D = array [0 .. 1] of Single;
@ -78,7 +86,7 @@ type
TCVChar = CVChar; TCVChar = CVChar;
pCVChar = pAnsiChar; pCVChar = pAnsiChar;
TpCVCharArray = array [0 .. 0] of pCVChar; TpCVCharArray = array [0 .. 0] of pCVChar;
ppCVChar = ^TpCVCharArray; ppCVChar = ^TpCVCharArray;
// {$IFNDEF WIN64} // {$IFNDEF WIN64}
// size_t = UInt32; // size_t = UInt32;
// {$ELSE} // {$ELSE}
@ -1636,7 +1644,8 @@ Type
// typedef void* (CV_CDECL *CvReadFunc)( CvFileStorage* storage, CvFileNode* node ); // typedef void* (CV_CDECL *CvReadFunc)( CvFileStorage* storage, CvFileNode* node );
TCvReadFunc = function(storage: pCvFileStorage; node: pCvFileNode): Pointer; cdecl; TCvReadFunc = function(storage: pCvFileStorage; node: pCvFileNode): Pointer; cdecl;
// typedef void (CV_CDECL *CvWriteFunc)( CvFileStorage* storage, const char* name,const void* struct_ptr, CvAttrList attributes ); // typedef void (CV_CDECL *CvWriteFunc)( CvFileStorage* storage, const char* name,const void* struct_ptr, CvAttrList attributes );
TCvWriteFunc = procedure(storage: pCvFileStorage; const name: pCVChar; const struct_ptr: pPointer; attributes: TCvAttrList); cdecl; TCvWriteFunc = procedure(storage: pCvFileStorage; const name: pCVChar; const struct_ptr: pPointer;
attributes: TCvAttrList); cdecl;
// typedef void* (CV_CDECL *CvCloneFunc)( const void* struct_ptr ); // typedef void* (CV_CDECL *CvCloneFunc)( const void* struct_ptr );
TCvCloneFunc = function(const struct_ptr: pPointer): Pointer; cdecl; TCvCloneFunc = function(const struct_ptr: pPointer): Pointer; cdecl;
@ -2273,7 +2282,8 @@ function cvScalarAll(val0123: Double): TCvScalar; {$IFDEF USE_INLINE}inline; {$E
function cvPoint(const x: Integer = 0; const y: Integer = 0): TCvPoint; {$IFDEF USE_INLINE}inline; {$ENDIF} function cvPoint(const x: Integer = 0; const y: Integer = 0): TCvPoint; {$IFDEF USE_INLINE}inline; {$ENDIF}
function CvPoint2f(const x: Single = 0; const y: Single = 0): TcvPoint2f; {$IFDEF USE_INLINE}inline; {$ENDIF} function CvPoint2f(const x: Single = 0; const y: Single = 0): TcvPoint2f; {$IFDEF USE_INLINE}inline; {$ENDIF}
function CvSize(const width, height: Integer): TCvSize; {$IFDEF USE_INLINE}inline; {$ENDIF} function CvSize(const width, height: Integer): TCvSize; {$IFDEF USE_INLINE}inline; {$ENDIF}
function CvScalar(const val0: Double; const val1: Double = 0; const val2: Double = 0; const val3: Double = 0): TCvScalar; function CvScalar(const val0: Double; const val1: Double = 0; const val2: Double = 0; const val3: Double = 0)
: TCvScalar;
{$IFDEF USE_INLINE}inline; {$ENDIF} {$IFDEF USE_INLINE}inline; {$ENDIF}
function cvRandInt(Var rng: TCvRNG): Cardinal; {$IFDEF USE_INLINE}inline; {$ENDIF} function cvRandInt(Var rng: TCvRNG): Cardinal; {$IFDEF USE_INLINE}inline; {$ENDIF}
function CvRect(Const x, y, width, height: Integer): TCvRect; {$IFDEF USE_INLINE}inline; {$ENDIF} function CvRect(Const x, y, width, height: Integer): TCvRect; {$IFDEF USE_INLINE}inline; {$ENDIF}
@ -2428,7 +2438,8 @@ end;
function CV_ELEM_SIZE; function CV_ELEM_SIZE;
begin begin
Result := (CV_MAT_CN(_type) shl ((((SizeOf(NativeInt) div 4 + 1) * (16384 or $3A50)) shr CV_MAT_DEPTH(_type) * 2) and 3)); Result := (CV_MAT_CN(_type) shl ((((SizeOf(NativeInt) div 4 + 1) * (16384 or $3A50)) shr CV_MAT_DEPTH(_type) *
2) and 3));
end; end;
function CV_32SC1: Integer; function CV_32SC1: Integer;
@ -2748,8 +2759,8 @@ end;
function CV_IMAGE_ELEM(image: pIplImage; size_elemtype, row, col: Integer): Pointer; {$IFDEF USE_INLINE}inline; {$ENDIF} function CV_IMAGE_ELEM(image: pIplImage; size_elemtype, row, col: Integer): Pointer; {$IFDEF USE_INLINE}inline; {$ENDIF}
begin begin
// (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)]) // (((elemtype*)((image)->imageData + (image)->widthStep*(row)))[(col)])
Result := {$IFDEF DELPHI7}Pointer({$ENDIF DELPHI7}{$IFDEF DELPHI2005_UP}PByte{$ELSE}Integer{$ENDIF}(image^.imageData) + image^.widthStep * Result := {$IFDEF DELPHI7}Pointer({$ENDIF DELPHI7}{$IFDEF DELPHI2005_UP}PByte{$ELSE}Integer{$ENDIF}(image^.imageData)
row + col * size_elemtype{$IFDEF DELPHI7}){$ENDIF DELPHI7}; + image^.widthStep * row + col * size_elemtype{$IFDEF DELPHI7}){$ENDIF DELPHI7};
end; end;
function cvRealScalar(val0: Double): TCvScalar; {$IFDEF USE_INLINE}inline; {$ENDIF} function cvRealScalar(val0: Double): TCvScalar; {$IFDEF USE_INLINE}inline; {$ENDIF}