1
unit LUX.Vision.OpenCV.Capture;
3
interface //#################################################################### ■
5
uses ocv.core.types_c, ocv.highgui_c,
8
type //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【型】
10
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
12
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
14
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvCapture
16
TocvCapture = class abstract
22
function GetPosMsec :Double;
23
procedure SetPosMsec( const PosMsec_:Double );
24
function GetPosFrames :Integer;
25
procedure SetPosFrames( const PosFrames_:Integer );
26
function GetPosAviRatio :Double;
27
procedure SetPosAviRatio( const PosAviRatio_:Double );
28
function GetFrameWidth :Integer;
29
procedure SetFrameWidth( const FrameWidth_:Integer );
30
function GetFrameHeight :Integer;
31
procedure SetFrameHeight( const FrameHeight_:Integer );
32
function GetFPS :Double;
33
procedure SetFPS( const FPS_:Double );
34
function GetFourCC :String;
35
procedure SetFourCC( const FourCC_:String );
36
function GetFrameCount :Integer;
39
destructor Destroy; override;
41
property Core :pCvCapture read _Core;
42
property Frame :TocvImage3 read _Frame;
43
property PosMsec :Double read GetPosMsec write SetPosMsec;
44
property PosFrames :Integer read GetPosFrames write SetPosFrames;
45
property PosAviRatio :Double read GetPosAviRatio write SetPosAviRatio;
46
property FrameWidth :Integer read GetFrameWidth write SetFrameWidth;
47
property FrameHeight :Integer read GetFrameHeight write SetFrameHeight;
48
property FPS :Double read GetFPS write SetFPS;
49
property FourCC :String read GetFourCC write SetFourCC;
50
property FrameCount :Integer read GetFrameCount;
55
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvVideo
57
TocvVideo = class( TocvCapture )
60
_FileName :AnsiString;
62
constructor Create( const FileName_:AnsiString );
64
property FileName :AnsiString read _FileName;
67
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvCamera
69
TocvCamera = class( TocvCapture )
74
constructor Create( const CameraI_:Integer = 0 );
76
property CameraI :Integer read _CameraI;
79
//const //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【定数】
81
//var //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【変数】
83
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
85
implementation //############################################################### ■
89
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
91
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
93
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvCapture
95
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
97
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
99
/////////////////////////////////////////////////////////////////////// アクセス
101
function TocvCapture.GetPosMsec :Double;
103
Result := cvGetCaptureProperty( _Core, CV_CAP_PROP_POS_MSEC );
106
procedure TocvCapture.SetPosMsec( const PosMsec_:Double );
108
cvSetCaptureProperty( _Core, CV_CAP_PROP_POS_MSEC, PosMsec_ );
111
function TocvCapture.GetPosFrames :Integer;
113
Result := Round( cvGetCaptureProperty( _Core, CV_CAP_PROP_POS_FRAMES ) );
116
procedure TocvCapture.SetPosFrames( const PosFrames_:Integer );
118
cvSetCaptureProperty( _Core, CV_CAP_PROP_POS_FRAMES, PosFrames_ );
121
function TocvCapture.GetPosAviRatio :Double;
123
Result := cvGetCaptureProperty( _Core, CV_CAP_PROP_POS_AVI_RATIO );
126
procedure TocvCapture.SetPosAviRatio( const PosAviRatio_:Double );
128
cvSetCaptureProperty( _Core, CV_CAP_PROP_POS_AVI_RATIO, PosAviRatio_ );
131
function TocvCapture.GetFrameWidth :Integer;
133
Result := Round( cvGetCaptureProperty( _Core, CV_CAP_PROP_FRAME_WIDTH ) );
136
procedure TocvCapture.SetFrameWidth( const FrameWidth_:Integer );
138
cvSetCaptureProperty( _Core, CV_CAP_PROP_FRAME_WIDTH, FrameWidth_ );
141
function TocvCapture.GetFrameHeight :Integer;
143
Result := Round( cvGetCaptureProperty( _Core, CV_CAP_PROP_FRAME_HEIGHT ) );
146
procedure TocvCapture.SetFrameHeight( const FrameHeight_:Integer );
148
cvSetCaptureProperty( _Core, CV_CAP_PROP_FRAME_HEIGHT, FrameHeight_ );
151
function TocvCapture.GetFPS :Double;
153
Result := cvGetCaptureProperty( _Core, CV_CAP_PROP_FPS );
156
procedure TocvCapture.SetFPS( const FPS_:Double );
158
cvSetCaptureProperty( _Core, CV_CAP_PROP_FPS, FPS_ );
161
function TocvCapture.GetFourCC :String;
163
Result := cvGetCaptureProperty( _Core, CV_CAP_PROP_FOURCC ).ToString;
166
procedure TocvCapture.SetFourCC( const FourCC_:String );
168
cvSetCaptureProperty( _Core, CV_CAP_PROP_FOURCC, FourCC_.ToDouble );
171
function TocvCapture.GetFrameCount :Integer;
173
Result := Round( cvGetCaptureProperty( _Core, CV_CAP_PROP_FRAME_COUNT ) );
176
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
178
constructor TocvCapture.Create;
182
_Frame := TocvImage3.Create;
185
destructor TocvCapture.Destroy;
187
cvReleaseCapture( _Core );
194
/////////////////////////////////////////////////////////////////////// メソッド
196
procedure TocvCapture.QueryFrame;
198
_Frame.Core := cvQueryFrame( _Core );
201
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvVideo
203
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
205
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
207
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
209
constructor TocvVideo.Create( const FileName_:AnsiString );
213
_FileName := FileName_;
215
_Core := cvCreateFileCapture( PAnsiChar( _FileName ) );
218
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvCamera
220
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
222
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
224
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
226
constructor TocvCamera.Create( const CameraI_:Integer = 0 );
230
_CameraI := CameraI_;
232
_Core := cvCreateCameraCapture( _CameraI );
235
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
237
//############################################################################## □
239
initialization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 初期化
241
finalization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 最終化
243
end. //######################################################################### ■