三、設置字幕疊 加
一般用於顯示公司LOGO和日期,下圖黃色區域所示
VC ++ Code:
方法OnSettings()
USHORT Format1[40] = {48, 16, 'H','I','K','V', 'I','S','I','O','N', '\0'};
USHORT Format2[40] = {24, 50, _OSD_YEAR4, '-',_OSD_MONTH2,'-',_OSD_DAY,'-', _OSD_HOUR24, ':', _OSD_MINUTE,':', _OSD_SECOND, '\0'};
//其他代碼
for(i = 0; i < GetTotalDSPs(); i++){
SetOsdDisplayMode(ChannelHandle[i], 255, TRUE, 0, Format1, Format2);
SetOsd(ChannelHandle[i], TRUE);
}
C# Code:
private const ushort _OSD_BASE = 0x9000;
private const ushort _OSD_YEAR4 = _OSD_BASE + 0;
private const ushort _OSD_YEAR2 = _OSD_BASE + 1;
private const ushort _OSD_MONTH3 = _OSD_BASE + 2;
private const ushort _OSD_MONTH2 = _OSD_BASE + 3;
private const ushort _OSD_DAY = _OSD_BASE + 4;
private const ushort _OSD_WEEK3 = _OSD_BASE + 5;
private const ushort _OSD_CWEEK1 = _OSD_BASE + 6;
private const ushort _OSD_HOUR24 = _OSD_BASE + 7;
private const ushort _OSD_HOUR12 = _OSD_BASE + 8;
private const ushort _OSD_MINUTE = _OSD_BASE + 9;
private const ushort _OSD_SECOND = _OSD_BASE + 10;
/// <summary>
/// 設置Osd
/// </summary>
/// <param name="ChannelHandle"></param>
/// <param name="setValue"></param>
public void SetOsd(IntPtr[] ChannelHandle, bool setValue)
{
if (setValue)
{
ushort[] Format1 = new ushort[]{ 48, 16, 'H', 'I', 'K', 'V', 'I', 'S', 'I', 'O', 'N', '\0' };
ushort[] Format2 = new ushort[]{ 24, 50, _OSD_YEAR4, '-', _OSD_MONTH2, '-', _OSD_DAY, '-', _OSD_HOUR24, ':', _OSD_MINUTE, ':', _OSD_SECOND, '\0' };
for (int i = 0; i < ChannelHandle.Length; i++)
{
HikVisionSDK.SetOsdDisplayMode(ChannelHandle[i], 255, true, 0, Format1, Format2);
HikVisionSDK.SetOsd(ChannelHandle[i], true);
}
}
else
{
for (int i = 0; i < ChannelHandle.Length; i++)
{
HikVisionSDK.SetOsd(ChannelHandle[i], false);
}
}
}
代碼說明:
1.注意設置中文字符有問題,暫時沒有解決。
2.關於時間顯示可以翻閱API文檔,說明得很詳細。