Luxophia

Форк
0
/
LUX.Vision.OpenCV.Capture.pas 
243 строки · 7.7 Кб
1
unit LUX.Vision.OpenCV.Capture;
2

3
interface //#################################################################### ■
4

5
uses ocv.core.types_c, ocv.highgui_c,
6
     LUX.Vision.OpenCV;
7

8
type //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【型】
9

10
     //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
11

12
     //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
13

14
     //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvCapture
15

16
     TocvCapture = class abstract
17
     private
18
     protected
19
       _Frame :TocvImage3;
20
       _Core  :pCvCapture;
21
       ///// アクセス
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;
37
     public
38
       constructor Create;
39
       destructor Destroy; override;
40
       ///// プロパティ
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;
51
       ///// メソッド
52
       procedure QueryFrame;
53
     end;
54

55
     //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvVideo
56

57
     TocvVideo = class( TocvCapture )
58
     private
59
     protected
60
       _FileName :AnsiString;
61
     public
62
       constructor Create( const FileName_:AnsiString );
63
       ///// プロパティ
64
       property FileName :AnsiString read _FileName;
65
     end;
66

67
     //%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvCamera
68

69
     TocvCamera = class( TocvCapture )
70
     private
71
     protected
72
       _CameraI :Integer;
73
     public
74
       constructor Create( const CameraI_:Integer = 0 );
75
       ///// プロパティ
76
       property CameraI :Integer read _CameraI;
77
     end;
78

79
//const //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【定数】
80

81
//var //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【変数】
82

83
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
84

85
implementation //############################################################### ■
86

87
uses System.SysUtils;
88

89
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【レコード】
90

91
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【クラス】
92

93
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvCapture
94

95
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
96

97
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
98

99
/////////////////////////////////////////////////////////////////////// アクセス
100

101
function TocvCapture.GetPosMsec :Double;
102
begin
103
     Result := cvGetCaptureProperty( _Core, CV_CAP_PROP_POS_MSEC );
104
end;
105

106
procedure TocvCapture.SetPosMsec( const PosMsec_:Double );
107
begin
108
     cvSetCaptureProperty( _Core, CV_CAP_PROP_POS_MSEC, PosMsec_ );
109
end;
110

111
function TocvCapture.GetPosFrames :Integer;
112
begin
113
     Result := Round( cvGetCaptureProperty( _Core, CV_CAP_PROP_POS_FRAMES ) );
114
end;
115

116
procedure TocvCapture.SetPosFrames( const PosFrames_:Integer );
117
begin
118
     cvSetCaptureProperty( _Core, CV_CAP_PROP_POS_FRAMES, PosFrames_ );
119
end;
120

121
function TocvCapture.GetPosAviRatio :Double;
122
begin
123
     Result := cvGetCaptureProperty( _Core, CV_CAP_PROP_POS_AVI_RATIO );
124
end;
125

126
procedure TocvCapture.SetPosAviRatio( const PosAviRatio_:Double );
127
begin
128
     cvSetCaptureProperty( _Core, CV_CAP_PROP_POS_AVI_RATIO, PosAviRatio_ );
129
end;
130

131
function TocvCapture.GetFrameWidth :Integer;
132
begin
133
     Result := Round( cvGetCaptureProperty( _Core, CV_CAP_PROP_FRAME_WIDTH ) );
134
end;
135

136
procedure TocvCapture.SetFrameWidth( const FrameWidth_:Integer );
137
begin
138
     cvSetCaptureProperty( _Core, CV_CAP_PROP_FRAME_WIDTH, FrameWidth_ );
139
end;
140

141
function TocvCapture.GetFrameHeight :Integer;
142
begin
143
     Result := Round( cvGetCaptureProperty( _Core, CV_CAP_PROP_FRAME_HEIGHT ) );
144
end;
145

146
procedure TocvCapture.SetFrameHeight( const FrameHeight_:Integer );
147
begin
148
     cvSetCaptureProperty( _Core, CV_CAP_PROP_FRAME_HEIGHT, FrameHeight_ );
149
end;
150

151
function TocvCapture.GetFPS :Double;
152
begin
153
     Result := cvGetCaptureProperty( _Core, CV_CAP_PROP_FPS );
154
end;
155

156
procedure TocvCapture.SetFPS( const FPS_:Double );
157
begin
158
     cvSetCaptureProperty( _Core, CV_CAP_PROP_FPS, FPS_ );
159
end;
160

161
function TocvCapture.GetFourCC :String;
162
begin
163
     Result := cvGetCaptureProperty( _Core, CV_CAP_PROP_FOURCC ).ToString;
164
end;
165

166
procedure TocvCapture.SetFourCC( const FourCC_:String );
167
begin
168
     cvSetCaptureProperty( _Core, CV_CAP_PROP_FOURCC, FourCC_.ToDouble );
169
end;
170

171
function TocvCapture.GetFrameCount :Integer;
172
begin
173
     Result := Round( cvGetCaptureProperty( _Core, CV_CAP_PROP_FRAME_COUNT ) );
174
end;
175

176
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
177

178
constructor TocvCapture.Create;
179
begin
180
     inherited;
181

182
     _Frame := TocvImage3.Create;
183
end;
184

185
destructor TocvCapture.Destroy;
186
begin
187
     cvReleaseCapture( _Core );
188

189
     _Frame.Free;
190

191
     inherited;
192
end;
193

194
/////////////////////////////////////////////////////////////////////// メソッド
195

196
procedure TocvCapture.QueryFrame;
197
begin
198
     _Frame.Core := cvQueryFrame( _Core );
199
end;
200

201
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvVideo
202

203
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
204

205
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
206

207
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
208

209
constructor TocvVideo.Create( const FileName_:AnsiString );
210
begin
211
     inherited Create;
212

213
     _FileName := FileName_;
214

215
     _Core := cvCreateFileCapture( PAnsiChar( _FileName ) );
216
end;
217

218
//%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% TocvCamera
219

220
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& private
221

222
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& protected
223

224
//&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& public
225

226
constructor TocvCamera.Create( const CameraI_:Integer = 0 );
227
begin
228
     inherited Create;
229

230
     _CameraI := CameraI_;
231

232
     _Core := cvCreateCameraCapture( _CameraI );
233
end;
234

235
//$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$【ルーチン】
236

237
//############################################################################## □
238

239
initialization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 初期化
240

241
finalization //$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ 最終化
242

243
end. //######################################################################### ■
244

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.