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