unitno2.pas
来自「智能监控delphi源码, 操作说明 1. 在两台微机上分别运行文件夹中的可」· PAS 代码 · 共 144 行
PAS
144 行
unit UnitNo2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, Videocap;
type
TFormNo2 = class(TForm)
grp1: TGroupBox;
btnStartGet2: TButton;
btnStopMoniter2: TButton;
tmr1: TTimer;
VideoCap2: TVideoCap;
tmr2: TTimer;
Timer2: TTimer;
Shape2: TShape;
procedure btnStopMoniter2Click(Sender: TObject);
procedure btnStartGet2Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
private
{ Private declarations }
procedure Flash2;
public
{ Public declarations }
end;
var
FormNo2: TFormNo2;
implementation
uses UnitMain, UnitFormRec;
{$R *.dfm}
procedure TFormNo2.Flash2;
begin
if FlashN2 = '0' then
begin
Shape2.Brush.Color := clRed;
FlashN2 := '1';
Exit;
end;
if FlashN2 = '1' then
begin
Shape2.Brush.Color := clBtnFace;
FlashN2 := '0';
Exit;
end;
end;
procedure TFormNo2.btnStartGet2Click(Sender: TObject);
begin
//处理方式和前面相同;
SSRec2 := not SSRec2;
if SSRec2 then
begin
rec2 := true; //录像标志为1,表示开始录像;
//以下程序处理的是一些显示问题;
btnStartGet2.Caption := '停止录象';
FormMain.NStartGet2.Enabled := not FormMain.NStartGet2.Enabled; //使主窗体的按钮处于不可操作状态;
FormMain.NStopGet2.Enabled := not FormMain.NStopGet2.Enabled;
end
else
begin
rec2 := False; //还原录像标志;
btnStartGet2.Caption := '开始录象';
FormMain.NStartGet2.Enabled := True;
FormMain.NStopGet2.Enabled := False;
end;
FormMain.btnStartGet2.Caption := btnStartGet2.Caption; //同步显示;
//以下是处理avi文件的程序;
if rec2 then
begin
Timer2.Enabled := True;
nn2 := nn2 + 1; //文件存盘编号自动加1;
strn2 := IntToStr(nn2); //将文件存盘编号变成字符串;
AssignFile(f2, '.\Inf\n2.txt'); //在Inf文件夹中创建n1.txt,记录n1值;
Rewrite(f2);
Writeln(f2, IntToStr(nn2));
CloseFile(f2);
VideoCap2.CapTimeLimit := 0;
VideoCap2.VideoFileName := FormMain.GetAviDir(2) + '\' + FormMain.FIntToStr(strn2) + '.avi';
VideoCap2.StartCapture;
VideoCap2.DlgVCompression;
FormMain.WriteDB(Date + Time, VideoCap2.VideoFileName, '2#摄像头出现异常情况'); //将有关的信息写入数据库
FormRec.tmrRefresh.Enabled := True; //每录完一次刷新一下数据库
end;
if not rec2 then
begin
Timer2.Enabled := False;
Shape2.Brush.Color := clBtnFace;
VideoCap2.StopCapture;
end;
end;
//1#摄像头监控窗体中btnStopMoniter1按下,此时可以控制打开和停止监控;
procedure TFormNo2.btnStopMoniter2Click(Sender: TObject);
begin
OCMon2 := not OCMon2;
if not OCMon2 then
begin
FormMain.NStartGet2.Enabled := True;
btnStopMoniter2.Caption := '关闭监控';
videocap2.DriverIndex := 0; //打开2#摄像头,开始监控;
VideoCap2.DriverOpen := True;
VideoCap2.VideoPreview := True;
VideoCap2.visible := True;
end
else
begin
Timer2.Enabled := False;
Shape2.Brush.Color := clBtnFace;
btnStartGet2.Enabled := False;
btnStopMoniter2.Caption := '打开监控'; //按钮显示内容的修改
VideoCap2.DriverOpen := False; //关闭2#摄像头,停止监控
VideoCap2.VideoPreview := False;
VideoCap2.visible := False;
FormMain.NStartGet2.Enabled := False;
btnStartGet2.Caption := '开始录象';
SSRec2 := False;
OCMon2 := False;
FormMain.btnStartGet2.Enabled := False;
FormMain.btnStopMoniter2.Enabled := True;
FormMain.MoniterNo2.Checked := False;
FormMain.MoniterAll.Checked := True;
FormMain.btnStartGet2.Caption := '开始录像';
FormMain.NStartMoniter2.Enabled := True;
FormMain.Show;
Close;
end;
end;
procedure TFormNo2.Timer2Timer(Sender: TObject);
begin
Flash2;
end;
end.
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?