使用设备网络sdk修改osd后页面不更新,前往网页中的‘配置-常用配置-OSD配置’页面查看字符叠加下对应的字符内容是正常更新的,点击该页面下的保存按钮才会更新视频中的OSD。
下面是我使用C#调用相应功能的代码
#region OSD
/// <summary>/// 获取OSD/// </summary>/// <param name="device_num"></param>private NET_DVR_SHOWSTRING_V30 getOSD(int i_lUserID){
//获取球机位置信息结构体大小
int size = Marshal.SizeOf(typeof(NET_DVR_SHOWSTRING_V30));
//设置指针空间大小
IntPtr ptrOSD = Marshal.AllocHGlobal(size);
uint result = 0;
NET_DVR_GetDVRConfig(i_lUserID, 1030, 1, ptrOSD, (uint)size, ref result);
NET_DVR_SHOWSTRING_V30 dVR_OSDPOS = (NET_DVR_SHOWSTRING_V30)Marshal.PtrToStructure(ptrOSD, typeof(NET_DVR_SHOWSTRING_V30));
return dVR_OSDPOS;
}
/// <summary>/// 设置OSD/// </summary>/// <param name="device_num"></param>private void setOSD(int i_lUserID, NET_DVR_SHOWSTRING_V30 structure){
int size = Marshal.SizeOf(typeof(NET_DVR_SHOWSTRING_V30));
byte[] buffer = new byte[size];
IntPtr bufferIntPtr = Marshal.AllocHGlobal(size);
try
{
Marshal.StructureToPtr(structure, bufferIntPtr, true);
Marshal.Copy(bufferIntPtr, buffer, 0, size);
}
finally
{
Marshal.FreeHGlobal(bufferIntPtr);
}
IntPtr imgPtr = Marshal.AllocHGlobal(buffer.Length);
Marshal.Copy(buffer, 0, imgPtr, buffer.Length);
if (!NET_DVR_SetDVRConfig(i_lUserID, 1031, 1, imgPtr, (uint)size))
{
Console.WriteLine("osd没改上:" + NET_DVR_GetLastError());
}
}
#endregion OSD
private void osd_button_Click(object sender, EventArgs e){
NET_DVR_SHOWSTRING_V30 osds = getOSD(real_PlayPOJOs[0].I_lUserID);
Console.WriteLine("===================================================================================");
for (int i1 = 0; i1 < osds.struStringInfo.Length; i1++)
{
/*
Console.WriteLine("预览的图象上是否显示字符,0-不显示,1-显示 区域大小704*576,单个字符的大小为32*3");
Console.WriteLine("wShowString:" + dVR_OSDPOS.struStringInfo[i1].wShowString);
Console.WriteLine(" 该行字符的长度,不能大于44个字符");
Console.WriteLine("wStringSize:" + dVR_OSDPOS.struStringInfo[i1].wStringSize);
Console.WriteLine("字符显示位置的x坐标");
Console.WriteLine("wShowStringTopLeftX:" + dVR_OSDPOS.struStringInfo[i1].wShowStringTopLeftX);
Console.WriteLine("字符名称显示位置的y坐标");
Console.WriteLine("wShowStringTopLeftY:" + dVR_OSDPOS.struStringInfo[i1].wShowStringTopLeftY);
Console.WriteLine("要显示的字符内容");
*/
Console.WriteLine("sString:" + i1 + osds.struStringInfo[i1].sString + "asdhujgkasdhukj");
//osds.struStringInfo[0].sString = "CH4:" + 50 + "ppm.m";
}
osds.struStringInfo[0].wShowString = 1;
osds.struStringInfo[0].sString += "C";
// Console.WriteLine("===================================================================================");
setOSD(real_PlayPOJOs[0].I_lUserID, osds);
}