最近需要做一个C#版本的控制终端,控制摄像头,获取摄像头的水平角度和垂直角度

获取当前摄像头的角度,需要调用一个名为NET_DVR_GetDVRConfig的bool类型的函数

在C++中,函数定义:NET_DVR_GetDVRConfig(LONG lUserID, DWORD dwCommand,LONG lChannel, LPVOID lpOutBuffer, DWORD dwOutBufferSize, LPDWORD lpBytesReturned)

在C#封装过程中,函数改为:

[DllImport(@"HCNetSDK.dll")]
public static extern bool NET_DVR_GetDVRConfig(int lUserID, uint dwCommand, int lChannel, IntPtr lpOutBuffer, uint dwOutBufferSize, ref uint lpBytesReturned);

在调用的过程中,主要是第四个参数的转换遇到了问题

首先看一下C++Demo里面的函数用法:

 1  NET_DVR_PTZPOS m_ptzPos = {0};
 2     DWORD dwReturned;
 3     BOOL bRet = NET_DVR_GetDVRConfig(m_lUserID[m_struSlaveCameraCond.byID], NET_DVR_GET_PTZPOS, 0, &m_ptzPos, sizeof(NET_DVR_PTZPOS), &dwReturned);
 4     if (!bRet)
 5     {
 6         g_pMainDlg->AddLog(m_iDeviceIndex, OPERATION_FAIL_T, "NET_DVR_GET_PTZPOS");
 7         return;
 8     }
 9 
10     int m_iPara1 = HexToDecMa(m_ptzPos.wPanPos);
11     int m_iPara2 = HexToDecMa(m_ptzPos.wTiltPos);
12     int m_iPara3 = HexToDecMa(m_ptzPos.wZoomPos);
C++获取角度

相关文章:

  • 2021-06-22
  • 2022-01-16
  • 2021-12-05
  • 2021-05-02
  • 2021-04-26
  • 2022-01-25
  • 2021-08-03
  • 2021-06-07
猜你喜欢
  • 2022-12-23
  • 2022-01-02
  • 2021-10-08
  • 2022-01-17
  • 2022-12-23
  • 2022-01-13
  • 2021-04-26
相关资源
相似解决方案