请问海康监控卡的OSD如何解决,SOS...在线等待(100分)

  • 主题发起人 主题发起人 rzqcjwrz
  • 开始时间 开始时间
R

rzqcjwrz

Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.BitBtn3Click(Sender: TObject); //取LOGO
var
format1,format2:array[0..13] of word;
begin
Format1[0] := 24;
Format1[1] := 24;
Format1[2] := _OSD_YEAR4;
Format1[3] := ord('-');
Format1[4] := _OSD_MONTH2;
Format1[5] := ord('-');
Format1[6] := _OSD_DAY;
Format1[7] := ord('-');
Format1[8] := _OSD_HOUR24;
Format1[9] := ord(':');
Format1[10] := _OSD_MINUTE;
Format1[11] := ord(':');
Format1[12] := _OSD_SECOND;
Format1[13] :=ord(#0);
Format2[0] := 24;
Format2[1] := 250;
Format2[2] := _OSD_YEAR4;
Format2[3] := ord('-');
Format2[4] := _OSD_MONTH2;
Format2[5] := ord('-');
Format2[6] := _OSD_DAY;
Format2[7] := ord('-');
Format2[8] := _OSD_HOUR24;
Format2[9] := ord(':');
Format2[10] := _OSD_MINUTE;
Format2[11] := ord(':');
Format2[12] := _OSD_SECOND;
Format2[13] :=ord(#0);

SetOsdDisplayMode(chanl,255, true,1, @Format1, @Format2);
// SetOsd(chanl,true);//设置OSD显示与否
end;
为什么不能在屏幕上显示?错在什么地方?
 
熟悉海康卡的高手们如何解决?
为什么不能在屏幕上显示?错在什么地方?
 
我正想用海康卡做监控,但不知OSD是指的什么?
 
OSD是指:On Screen Display,中文意指“在屏幕上显示”。
海康卡不错,我一直选它,目前已开发到HC+了。
 
SetLength(OsdInfo.Format1,14);
OsdInfo.Format1[0]:=SpinEdit12.Value;
OsdInfo.Format1[1]:=SpinEdit13.Value;
OsdInfo.Format1[2]:=_OSD_YEAR2;
OsdInfo.Format1[3]:=Word('-');
OsdInfo.Format1[4]:=_OSD_MONTH2;
OsdInfo.Format1[5]:=Word('-');
OsdInfo.Format1[6]:=_OSD_DAY;
OsdInfo.Format1[7]:=Word('-');
OsdInfo.Format1[8]:= _OSD_HOUR24;
OsdInfo.Format1[9]:=Word(':');
OsdInfo.Format1[10]:=_OSD_MINUTE;
OsdInfo.Format1[11]:=Word(':');
OsdInfo.Format1[12]:=_OSD_SECOND;
OsdInfo.Format1[13]:=0;
 
SetLength(OsdInfo.Format1,14);
不正确的类型,报错.
 
var
format1,format2:array of word;
我改成动态数组的定义后,不报错,但不能显示OSD,请指教.
 
unit CapDiskConfig;

interface

uses
Windows, SysUtils, Config, Classes, CapDiskApplication, Controls,
StrUtils, CapDiskCommon, Forms;

type
TCapDiskConfig = class(TComponent)
private
FApplication: TCapDiskApplication;
CForm: TCForm;
FAutoConfigSet: Boolean;
procedure SetApplication(const Value: TCapDiskApplication);
procedure SetAutoConfigSet(const Value: Boolean);
function GetEnabledOsd(ChannelIndex: Integer): Boolean;
procedure SetEnabledOsd(ChannelIndex: Integer; const Value: Boolean);
{ Private declarations }
protected
{ Protected declarations }
public
Constructor Create(Owner:TComponent);override;
Destructor Destroy;override;

procedure Config;
procedure ConfigOsd(OsdParams:Array of Word; ChannelIndex,OsdIndex:Integer; WriteIni:Boolean=true);

property EnabledOsd[ChannelIndex:Integer]:Boolean read GetEnabledOsd write SetEnabledOsd;
procedure Init;

procedure ConfigSet;overload;
procedure ConfigSet(ChannelInfo:PChannelInfo);overload;

procedure LoadFromIni(ChannelInfo: PChannelInfo);
procedure SaveToIni(ChannelInfo: PChannelInfo);
{ Public declarations }
published

property Application:TCapDiskApplication read FApplication write SetApplication;
property AutoConfigSet:Boolean read FAutoConfigSet write SetAutoConfigSet;
{ Published declarations }
end;

procedure Register;

implementation

uses DataType, tmsdk;

procedure Register;
begin
RegisterComponents('CapDisk', [TCapDiskConfig]);
end;

{ TCapDiskConfig }

procedure TCapDiskConfig.Config;
Var
i,j,Index:Integer;
StrList:TStringList;
Words:Array of Word;
Info:PChannelInfo;
begin
if Not Assigned(FApplication) then
Exit;
if Not FApplication.Init then
Exit;
CForm.Application:=FApplication;
if CForm.ShowModal=mrok then
begin
With CForm do
begin
For i:=0 to CheckListBox1.Items.Count-1 do
begin
if Not CheckListBox1.Checked then
Continue;
if i>=FApplication.MaxChannelCount then
Exit;
Info:=FApplication.ChannelInfo;
With Info.ChannelConfigInfo do
begin
LogoLeft:=SpinEdit10.Value;
LogoTop:=SpinEdit11.Value;
bAlertSave:=RadioButton8.Checked;
bNormalSave:=RadioButton9.Checked;
MotionDetect:=CheckBox2.Checked;
Osd:=CheckBox4.Checked;
Logo:=CheckBox3.Checked;
CopyFile(PChar(LabeledEdit5.Text),PChar(ExtractFilePath(Forms.Application.ExeName)+'Logo.bmp'),false);

StrPCopy(AVSavePath,GetFormatPath(LabeledEdit2.Text));
AVFileSize:=SpinEdit2.Value;
Preview:=CheckBox5.Checked;
Key_Frames_Intervals:=SpinEdit3.Value;
Frame_Rate:=SpinEdit5.Value;
QuantInfo.IVal:=SpinEdit4.Value;
QuantInfo.PVal:=SpinEdit6.Value;
QuantInfo.BVal:=SpinEdit7.Value;
Montion_Detect_Precision:=SpinEdit8.Value;
if RadioButton1.Checked then
StreamType:=1
else if RadioButton2.Checked then
StreamType:=2
else if RadioButton3.Checked then
StreamType:=3;
MaxBps:=SpinEdit9.Value;
if CheckBox1.Checked then
BitrateControlType:=brCBR
else
BitrateControlType:=brVBR;

if RadioButton4.Checked then
EncodeType:= ENC_DCIF_FORMAT
else if RadioButton5.Checked then
EncodeType:= ENC_2CIF_FORMAT
else if RadioButton6.Checked then
EncodeType:= ENC_CIF_FORMAT
else if RadioButton7.Checked then
EncodeType:= ENC_QCIF_FORMAT
else
EncodeType:= ENC_CIF_FORMAT;
bAlertSave:=RadioButton8.Checked;
SubChannel0EncodeType:=ENC_CIF_FORMAT;
SubChanel1EncodeType:=ENC_QCIF_FORMAT;

StrList:=TStringList.Create;
Try

Case ComboBox1.ItemIndex of
//_OSD_YEAR2, '-',_OSD_MONTH2,'-',_OSD_DAY,'-', _OSD_HOUR24, ':', _OSD_MINUTE,':', _OSD_SECOND, 0 {
0:
begin
SetLength(OsdInfo.Format1,14);
OsdInfo.Format1[0]:=SpinEdit12.Value;
OsdInfo.Format1[1]:=SpinEdit13.Value;
OsdInfo.Format1[2]:=_OSD_YEAR2;
OsdInfo.Format1[3]:=Word('-');
OsdInfo.Format1[4]:=_OSD_MONTH2;
OsdInfo.Format1[5]:=Word('-');
OsdInfo.Format1[6]:=_OSD_DAY;
OsdInfo.Format1[7]:=Word('-');
OsdInfo.Format1[8]:= _OSD_HOUR24;
OsdInfo.Format1[9]:=Word(':');
OsdInfo.Format1[10]:=_OSD_MINUTE;
OsdInfo.Format1[11]:=Word(':');
OsdInfo.Format1[12]:=_OSD_SECOND;
OsdInfo.Format1[13]:=0;
end;
1:
begin
StrList.Text:=AnsiReplaceStr(LabeledEdit3.Text,',',#13#10);
SetLength(Words,StrList.Count+3);
Words[0]:=SpinEdit12.Value;
Words[1]:=SpinEdit13.Value;
Index:=2;
For j:=0 to StrList.Count-1 do
begin
if Length(StrList.Strings[j])=1 then
Words[Index]:=Ord(StrList.Strings[j][1])
else
Words[Index]:=MakeWord(Ord(StrList.Strings[j][2]),Ord(StrList.Strings[j][1]));
Inc(Index);
end;
Words[High(Words)]:=0;
ConfigOsd(Words,Info.RunInfo.ChannelIndex,1);
end
else
begin
SetLength(OsdInfo.Format1,4);
OsdInfo.Format1[0]:=0;
OsdInfo.Format1[1]:=0;
OsdInfo.Format1[2]:=$20;
OsdInfo.Format1[3]:=0;
end
end;

Case ComboBox2.ItemIndex of
//_OSD_YEAR2, '-',_OSD_MONTH2,'-',_OSD_DAY,'-', _OSD_HOUR24, ':', _OSD_MINUTE,':', _OSD_SECOND, 0 {
0:
begin
SetLength(OsdInfo.Format2,14);
OsdInfo.Format2[0]:=SpinEdit14.Value;
OsdInfo.Format2[1]:=SpinEdit15.Value;
OsdInfo.Format2[2]:=_OSD_YEAR2;
OsdInfo.Format2[3]:=Word('-');
OsdInfo.Format2[4]:=_OSD_MONTH2;
OsdInfo.Format2[5]:=Word('-');
OsdInfo.Format2[6]:=_OSD_DAY;
OsdInfo.Format2[7]:=Word('-');
OsdInfo.Format2[8]:= _OSD_HOUR24;
OsdInfo.Format2[9]:=Word(':');
OsdInfo.Format2[10]:=_OSD_MINUTE;
OsdInfo.Format2[11]:=Word(':');
OsdInfo.Format2[12]:=_OSD_SECOND;
OsdInfo.Format2[13]:=0;
end;
1:
begin
StrList.Text:=AnsiReplaceStr(LabeledEdit5.Text,',',#13#10);
SetLength(Words,StrList.Count+3);
Words[0]:=SpinEdit12.Value;
Words[1]:=SpinEdit13.Value;
Index:=2;
For j:=0 to StrList.Count-1 do
begin
if Length(StrList.Strings[j])=1 then
Words[Index]:=Ord(StrList.Strings[j][1])
else
Words[Index]:=MakeWord(Ord(StrList.Strings[j][2]),Ord(StrList.Strings[j][1]));
Inc(Index);
end;
Words[High(Words)]:=0;
ConfigOsd(Words,Info.RunInfo.ChannelIndex,2);
end
else
begin
SetLength(OsdInfo.Format2,4);
OsdInfo.Format2[0]:=0;
OsdInfo.Format2[1]:=0;
OsdInfo.Format2[2]:=$20;
OsdInfo.Format2[3]:=0;
end
end;
Finally
StrList.Free;
end;
end;
end;
end;
if FAutoConfigSet then
ConfigSet;
end;
end;

procedure TCapDiskConfig.ConfigSet;
Var
i:Integer;
begin
For i:=0 to FApplication.MaxChannelCount-1 do
begin
ConfigSet(FApplication.ChannelInfo);
end;
end;

procedure TCapDiskConfig.ConfigOsd(OsdParams: Array of Word; ChannelIndex,OsdIndex:Integer; WriteIni:Boolean);
Var
i,Index:Integer;
Info:PChannelInfo;
begin
Index:=0;
Info:=FApplication.ChannelInfo[ChannelIndex];
Case OsdIndex of
1:
begin
SetLength(Info.ChannelConfigInfo.OsdInfo.Format1,Length(OsdParams));
For i:=Low(OsdParams) to High(OsdParams) do
begin
Info.ChannelConfigInfo.OsdInfo.Format1[Index]:=OsdParams;
Inc(Index);
end;
end;
2:
begin
SetLength(Info.ChannelConfigInfo.OsdInfo.Format2,Length(OsdParams));
For i:=Low(OsdParams) to High(OsdParams) do
begin
Info.ChannelConfigInfo.OsdInfo.Format2[Index]:=OsdParams;
Inc(Index);
end;
end;
end;

if WriteIni then
SaveToIni(Info);
end;

procedure TCapDiskConfig.ConfigSet(ChannelInfo: PChannelInfo);
Var
W,H:Integer;
Buff:Pointer;
Tmp:String;
begin
With ChannelInfo.ChannelConfigInfo do
begin


if Osd then
begin
SetOsdDisplayMode(ChannelInfo.RunInfo.ChannelHandle, 255, TRUE, 1, PWord(OsdInfo.Format1), PWord(OsdInfo.Format2));
SetOsd(ChannelInfo.RunInfo.ChannelHandle, TRUE);
end
else
begin
SetOsd(ChannelInfo.RunInfo.ChannelHandle, FALSE);
end;

if (Key_Frames_Intervals>30) or (Frame_Rate<=0) then
Frame_Rate:=30;
SetIBPMode(ChannelInfo.RunInfo.ChannelHandle,Key_Frames_Intervals, 2, 1, Frame_Rate);
SetDefaultQuant(ChannelInfo.RunInfo.ChannelHandle,QuantInfo.IVal,QuantInfo.PVal,QuantInfo.BVal);

SetStreamType(ChannelInfo.RunInfo.ChannelHandle, StreamType);

if MaxBps>10000 then
begin
SetupBitrateControl(ChannelInfo.RunInfo.ChannelHandle, MaxBps);
end
else
SetupBitrateControl(ChannelInfo.RunInfo.ChannelHandle, 0);
SetBitrateControlMode(ChannelInfo.RunInfo.ChannelHandle, BitrateControlType);

SetEncoderPictureFormat(ChannelInfo.RunInfo.ChannelHandle,EncodeType);

if Logo then
begin
Buff:=AllocMem(128 * 128 * 2);
Try
LoadYUVFromBmpFile(PChar(ExtractFilePath(Forms.Application.ExeName)+'Logo.bmp'),
Buff, 128 * 128 * 2, W, H);
SetLogoDisplayMode(ChannelInfo.RunInfo.ChannelHandle, RGB(0,0,0),TRUE, 0);
SetLogo(ChannelInfo.RunInfo.ChannelHandle, LogoLeft, LogoTop, 128, 128, Buff);
Finally
FreeMem(Buff);
end;
end
else
begin
StopLogo(ChannelInfo.RunInfo.ChannelHandle);
end;

//SubChannel0EncodeType:=ENC_CIF_FORMAT;
//SubChanel1EncodeType:=ENC_QCIF_FORMAT;

end;

With ChannelInfo.ChannelConfigInfo do
begin
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'bNormalSave',bNormalSave);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'bAlertSave',bAlertSave);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'MotionDetect',MotionDetect);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Osd',Osd);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Logo',Logo);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoLeft',LogoLeft);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoTop',LogoTop);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'AVFileSize',AVFileSize);
Tmp:=LogoFileName;
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoFileName',Tmp);
Tmp:=AVSavePath;
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'AVSavePath',Tmp);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Preview',Preview);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Key_Frames_Intervals',Key_Frames_Intervals);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Frame_Rate',Frame_Rate);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'IVal',QuantInfo.IVal);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'PVal',QuantInfo.PVal);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'BVal',QuantInfo.BVal);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Montion_Detect_Precision',Montion_Detect_Precision);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'StreamType',StreamType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'MaxBps',MaxBps);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'BitrateControlType',BitrateControlType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'EncodeType',EncodeType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'SubChannel0EncodeType',SubChannel0EncodeType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'SubChanel1EncodeType',SubChanel1EncodeType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Format1',FApplication.OsdFormatToString(OsdInfo.Format1));
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Format2',FApplication.OsdFormatToString(OsdInfo.Format2));
end;

end;


procedure TCapDiskConfig.LoadFromIni(ChannelInfo: PChannelInfo);
Var
Tmp:String;
begin
With ChannelInfo.ChannelConfigInfo do
begin
bNormalSave:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'bNormalSave',bNormalSave);
bAlertSave:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'bAlertSave',bAlertSave);
MotionDetect:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'MotionDetect',MotionDetect);
Osd:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Osd',Osd);
Logo:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Logo',Logo);
LogoLeft:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoLeft',LogoLeft);
LogoTop:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoTop',LogoTop);
AVFileSize:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'AVFileSize',AVFileSize);
Tmp:=LogoFileName;
StrPCopy(LogoFileName,IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoFileName',Tmp));
Tmp:=AVSavePath;
StrPCopy(AVSavePath,IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'AVSavePath',Tmp));
Preview:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Preview',Preview);
Key_Frames_Intervals:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Key_Frames_Intervals',Key_Frames_Intervals);
Frame_Rate:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Frame_Rate',Frame_Rate);
QuantInfo.IVal:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'IVal',QuantInfo.IVal);
QuantInfo.PVal:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'PVal',QuantInfo.PVal);
QuantInfo.BVal:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'BVal',QuantInfo.BVal);
Montion_Detect_Precision:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Montion_Detect_Precision',Montion_Detect_Precision);
StreamType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'StreamType',StreamType);
MaxBps:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'MaxBps',MaxBps);
BitrateControlType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'BitrateControlType',BitrateControlType);
EncodeType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'EncodeType',EncodeType);
SubChannel0EncodeType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'SubChannel0EncodeType',SubChannel0EncodeType);
SubChanel1EncodeType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'SubChanel1EncodeType',SubChanel1EncodeType);
FApplication.StringToOsdFormat(OsdInfo.Format1,IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Format1',FApplication.OsdFormatToString(OsdInfo.Format1)));
FApplication.StringToOsdFormat(OsdInfo.Format2,IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Format2',FApplication.OsdFormatToString(OsdInfo.Format2)));
OsdInfo.Format1[High(OsdInfo.Format1)]:=Word(#0);
end;
end;

procedure TCapDiskConfig.SaveToIni(ChannelInfo: PChannelInfo);
Var
Tmp:String;
begin
With ChannelInfo.ChannelConfigInfo do
begin
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'bNormalSave',bNormalSave);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'bAlertSave',bAlertSave);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'MotionDetect',MotionDetect);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Osd',Osd);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Logo',Logo);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoLeft',LogoLeft);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoTop',LogoTop);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'AVFileSize',AVFileSize);
Tmp:=LogoFileName;
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoFileName',Tmp);
Tmp:=AVSavePath;
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'AVSavePath',Tmp);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Preview',Preview);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Key_Frames_Intervals',Key_Frames_Intervals);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Frame_Rate',Frame_Rate);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'IVal',QuantInfo.IVal);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'PVal',QuantInfo.PVal);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'BVal',QuantInfo.BVal);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Montion_Detect_Precision',Montion_Detect_Precision);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'StreamType',StreamType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'MaxBps',MaxBps);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'BitrateControlType',BitrateControlType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'EncodeType',EncodeType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'SubChannel0EncodeType',SubChannel0EncodeType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'SubChanel1EncodeType',SubChanel1EncodeType);
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Format1',FApplication.OsdFormatToString(OsdInfo.Format1));
IniOper.Write('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Format2',FApplication.OsdFormatToString(OsdInfo.Format2));
end;

end;

constructor TCapDiskConfig.Create(Owner:TComponent);
begin
Inherited;
FApplication:=nil;
if Not (csDesigning in ComponentState) then
begin
CForm:=TCForm.Create(nil);
end;
end;

destructor TCapDiskConfig.Destroy;
begin
if Not (csDesigning in ComponentState) then
begin
CForm.Free;
end;
inherited;
end;

procedure TCapDiskConfig.Init;
Var
i:Integer;
Tmp:String;
ChannelInfo:PChannelInfo;
begin
For i:=0 to FApplication.MaxChannelCount-1 do
begin
ChannelInfo:=FApplication.ChannelInfo;
With ChannelInfo.ChannelConfigInfo do
begin
bNormalSave:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'bNormalSave',bNormalSave);
bAlertSave:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'bAlertSave',bAlertSave);
MotionDetect:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'MotionDetect',MotionDetect);
Osd:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Osd',Osd);
Logo:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Logo',Logo);
LogoLeft:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoLeft',LogoLeft);
LogoTop:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoTop',LogoTop);
AVFileSize:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'AVFileSize',AVFileSize);
Tmp:=LogoFileName;
StrPCopy(LogoFileName,IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'LogoFileName',Tmp));
Tmp:=AVSavePath;
StrPCopy(AVSavePath,IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'AVSavePath',Tmp));
Preview:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Preview',Preview);
Key_Frames_Intervals:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Key_Frames_Intervals',Key_Frames_Intervals);
Frame_Rate:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Frame_Rate',Frame_Rate);
QuantInfo.IVal:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'IVal',QuantInfo.IVal);
QuantInfo.PVal:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'PVal',QuantInfo.PVal);
QuantInfo.BVal:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'BVal',QuantInfo.BVal);
Montion_Detect_Precision:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Montion_Detect_Precision',Montion_Detect_Precision);
StreamType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'StreamType',StreamType);
MaxBps:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'MaxBps',MaxBps);
BitrateControlType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'BitrateControlType',BitrateControlType);
EncodeType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'EncodeType',EncodeType);
SubChannel0EncodeType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'SubChannel0EncodeType',SubChannel0EncodeType);
SubChanel1EncodeType:=IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'SubChanel1EncodeType',SubChanel1EncodeType);
FApplication.StringToOsdFormat(OsdInfo.Format1,IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Format1',FApplication.OsdFormatToString(OsdInfo.Format1)));
FApplication.StringToOsdFormat(OsdInfo.Format2,IniOper.Read('Config'+IntToStr(ChannelInfo.RunInfo.ChannelIndex),'Format2',FApplication.OsdFormatToString(OsdInfo.Format2)));
OsdInfo.Format1[High(OsdInfo.Format1)]:=Word(#0);
end;
end;

ConfigSet;
end;

procedure TCapDiskConfig.SetApplication(const Value: TCapDiskApplication);
begin
FApplication := Value;
end;

procedure TCapDiskConfig.SetAutoConfigSet(const Value: Boolean);
begin
FAutoConfigSet := Value;
end;

function TCapDiskConfig.GetEnabledOsd(ChannelIndex: Integer): Boolean;
Var
Info:PChannelInfo;
begin
Info:=FApplication.ChannelInfo[ChannelIndex];
Result:=Info.ChannelConfigInfo.Osd;
end;

procedure TCapDiskConfig.SetEnabledOsd(ChannelIndex: Integer;
const Value: Boolean);
Var
Info:PChannelInfo;
begin
Info:=FApplication.ChannelInfo[ChannelIndex];
Info.ChannelConfigInfo.Osd:=Value;
if Info.ChannelConfigInfo.Osd then
begin
SetOsdDisplayMode(Info.RunInfo.ChannelHandle, 255, TRUE, 1, PWord(Info.ChannelConfigInfo.OsdInfo.Format1), PWord(Info.ChannelConfigInfo.OsdInfo.Format2));
SetOsd(Info.RunInfo.ChannelHandle, TRUE);
end
else
begin
SetOsd(Info.RunInfo.ChannelHandle, FALSE);
end;
end;

end.
自己看吧,这个是我两年前的程序,一定可以用。下面那个是定义
 
unit CapDiskCommon;

interface

Uses Windows, Messages, Variants, SysUtils, tmSDK, DataType, Classes, IniFiles, Forms, AlertStreamEx;

Const
WM_DRAWFILEALERT=WM_USER+11000;
Type
TInfoType=(itError,itInformation,itHint,itResult);
TArrayWord=Array of Word;
TChannelPreviewInfo=record
brightness:Integer;
contrast:Integer;
hue:Integer;
saturation:Integer;
end;
PChannelPreviewInfo=^TChannelPreviewInfo;

TStatisticsInfo=record
TotalFrames:Integer;
Fps:Integer;
Bps:Integer;
FramesLost:Integer;
end;
PStatisticsInfo=^TStatisticsInfo;

TQuantInfo=record
IVal,PVal,BVal:Integer;
end;
PQuantInfo=^TQuantInfo;

TOsdInfo=record
Format1,Format2:TArrayWord;
end;
POsdInfo=^TOsdInfo;

TChannelConfigInfo=record
MotionDetect:Boolean;
Osd:Boolean;
Logo:Boolean;
Preview:Boolean;
AVFileSize:Int64;
Key_Frames_Intervals:Integer;
Frame_Rate:Integer;
QuantInfo:TQuantInfo;
Montion_Detect_Precision:Integer;
StreamType:Integer;
MaxBps:Integer;
BitrateControlType:BitrateControlType_t;
AVSavePath:Array[0..255] of Char;
LogoFileName:Array[0..1024] of Char;
EncodeType:PictureFormat_t;
SubChannel0EncodeType,SubChanel1EncodeType:PictureFormat_t;
OsdInfo:TOsdInfo;
DoubleEncode, bAlertSave, bNormalSave:Boolean;
LogoLeft,LogoTop:Integer;
end;
PChannelConfigInfo=^TChannelConfigInfo;

TRunInfo=record
ChannelHandle:THandle;
ChannelIndex:Integer;
PreviewRect:TRect;
PreviewHandle:THandle;
Previewed:Boolean;
AudioPreviewed:Boolean;
Caped:Boolean;
Motioned:Boolean;
OldSignale,IsManual:Boolean;
FileHeader,FileQHeader:Array[0..200] of Char;
FileHeaderLen,FileQHeaderLen,ManualTimeStart,ManualTimeCount:Integer;
Data1Stream, Data2Stream,ManualStream:TFileStream;
AlertStream:TAlertStream;
end;
PRunInfo=^TRunInfo;

TChannelInfo=record
ChannelPreviewInfo:TChannelPreviewInfo;
StatisticsInfo:TStatisticsInfo;
ChannelConfigInfo:TChannelConfigInfo;
RunInfo:TRunInfo;
end;
PChannelInfo=^TChannelInfo;

TChannelInfos=record
ChannelInfo:Array of TChannelInfo;
end;

TIniOper=Class
private
Ini:TIniFile;
FFileName: String;
public
Constructor Create(sFileName:String);
Destructor Destroy;override;

Function Read(Section,Key:String; Default:Variant):Variant;
procedure Write(Section,Key:String; Value:Variant);
Function SectionExists(Section:String):Boolean;
Function KeyExists(Section,Key:String):Boolean;
procedure DeleteKey(Section,Key:String);
procedure DeleteSection(Section:String);

property FileName:String read FFileName;
end;

Var
IniOper:TIniOper;

Function GetFormatPath(Path:String):String;

implementation

Function GetFormatPath(Path:String):String;
begin
Path:=Trim(Path);
if Copy(Path,Length(Path),1)='/' then
Result:=Path
else
Result:=Path+'/';
end;

{ TIniOper }

constructor TIniOper.Create(sFileName:String);
begin
FFileName:=sFileName;
Ini:=TIniFile.Create(sFileName);
end;

destructor TIniOper.Destroy;
begin
Ini.Free;
inherited;
end;

function TIniOper.SectionExists(Section: String): Boolean;
begin
Result:=Ini.SectionExists(Section);
end;

function TIniOper.Read(Section, Key: String; Default:Variant): Variant;
begin
Result:=Ini.ReadString(Section,Key,Default);
end;

procedure TIniOper.Write(Section, Key: String; Value: Variant);
begin
Ini.WriteString(Section,Key,Value);
end;

function TIniOper.KeyExists(Section, Key: String): Boolean;
begin
Result:=Ini.ValueExists(Section,Key);
end;

procedure TIniOper.DeleteKey(Section, Key: String);
begin
Ini.DeleteKey(Section,Key);
end;

procedure TIniOper.DeleteSection(Section: String);
begin
Ini.EraseSection(Section);
end;

Initialization
IniOper:=TIniOper.Create(ExtractFilePath(Application.ExeName)+'Config.ini');

Finalization
IniOper.Free;

end.
 
谢谢您Appfirst!!!
如果谁都象您一样大公无私就好.
 
再次谢谢您Appfirst!!!
同时,请教您能否给一个完整的海康卡的例子,我没有想到海康卡有这么复杂.
我的电子邮件:rzqcjwrz@public.cta.cq.cn
手机:13389656026
 
已发,将海康德所有支持库包括拷贝到系统目录下,否则不能运行
 
谢谢您,我已收到.
 
再次感谢appfirst的启发,我已经解决此问题!!!
 

Similar threads

后退
顶部