以下功能实现需要完成设备初始化,注册,监听和布防的操作,详见CSDNhttps://mp.csdn.net/mp_blog/creation/editor/121543529
//设备登录_V40
public void Login_V40() {
//注册
HCNetSDK.NET_DVR_USER_LOGIN_INFO m_strLoginInfo = new HCNetSDK.NET_DVR_USER_LOGIN_INFO();//设备登录信息
HCNetSDK.NET_DVR_DEVICEINFO_V40 m_strDeviceInfo = new HCNetSDK.NET_DVR_DEVICEINFO_V40();//设备信息
String m_sDeviceIP = "10.17.36.27";//设备ip地址
m_strLoginInfo.sDeviceAddress = new byte[HCNetSDK.NET_DVR_DEV_ADDRESS_MAX_LEN];
System.arraycopy(m_sDeviceIP.getBytes(), 0, m_strLoginInfo.sDeviceAddress, 0, m_sDeviceIP.length());
String m_sUsername = "admin";//设备用户名
m_strLoginInfo.sUserName = new byte[HCNetSDK.NET_DVR_LOGIN_USERNAME_MAX_LEN];
System.arraycopy(m_sUsername.getBytes(), 0, m_strLoginInfo.sUserName, 0, m_sUsername.length());
String m_sPassword = "hik12345";//设备密码
m_strLoginInfo.sPassword = new byte[HCNetSDK.NET_DVR_LOGIN_PASSWD_MAX_LEN];
System.arraycopy(m_sPassword.getBytes(), 0, m_strLoginInfo.sPassword, 0, m_sPassword.length());
m_strLoginInfo.wPort = 8000;
m_strLoginInfo.bUseAsynLogin = false; //是否异步登录:0- 否,1- 是
m_strLoginInfo.write();
lUserID = hCNetSDK.NET_DVR_Login_V40(m_strLoginInfo, m_strDeviceInfo);
if (lUserID == -1) {
System.out.println("登录失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
return;
} else {
System.out.println("登录成功!");
}
}
public void BindPort() {
HCNetSDK.NET_DVR_LOCAL_TCP_PORT_BIND_CFG strLocalTcpBind = new HCNetSDK.NET_DVR_LOCAL_TCP_PORT_BIND_CFG();
strLocalTcpBind.read();
strLocalTcpBind.wLocalBindTcpMinPort = 30000;
strLocalTcpBind.wLocalBindTcpMaxPort = 30200;
strLocalTcpBind.write();
Pointer pStrLocalTcoBind = strLocalTcpBind.getPointer();
if (hCNetSDK.NET_DVR_SetSDKLocalCfg(0, pStrLocalTcoBind) == false) {
System.out.println("绑定失败,错误码为" + hCNetSDK.NET_DVR_GetLastError());
}
System.out.println("绑定成功");
}
//获取设备的基本参数
public void GetCfg() {
HCNetSDK.NET_DVR_DEVICECFG_V40 m_strDeviceCfg = new HCNetSDK.NET_DVR_DEVICECFG_V40();
m_strDeviceCfg.dwSize = m_strDeviceCfg.size();
m_strDeviceCfg.write();
Pointer pStrDeviceCfg = m_strDeviceCfg.getPointer();
IntByReference pInt = new IntByReference(0);
boolean b_GetCfg = hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_DEVICECFG_V40,
0Xffffffff, pStrDeviceCfg, m_strDeviceCfg.dwSize, pInt);
if (b_GetCfg == false) {
System.out.println("获取参数失败 错误码:" + hCNetSDK.NET_DVR_GetLastError());
}
System.out.println("获取参数成功");
m_strDeviceCfg.read();
System.out.println("设备名称:" + new String(m_strDeviceCfg.sDVRName).trim() + "设备序列号:" + new String(m_strDeviceCfg.sSerialNumber));
System.out.println("模拟通道个数" + m_strDeviceCfg.byChanNum);
}
public void SetPTZcfg()
{
HCNetSDK.NET_DVR_PTZPOS struPtTZPos=new HCNetSDK.NET_DVR_PTZPOS();
IntByReference pUsers=new IntByReference(1);
boolean b_GetPTZ=hCNetSDK.NET_DVR_GetDVRConfig(lUserID,HCNetSDK.NET_DVR_GET_PTZPOS,1,struPtTZPos.getPointer(),struPtTZPos.size(),pUsers);
if (b_GetPTZ==false){
System.out.println("获取PTZ坐标信息失败,错误码:" + hCNetSDK.NET_DVR_GetLastError());
}else {
struPtTZPos.read();
String p=Integer.toHexString(struPtTZPos.wPanPos);
String t=Integer.toHexString(struPtTZPos.wTiltPos);
String z=Integer.toHexString(struPtTZPos.wZoomPos);
System.out.println("P参数:"+p+"\n");
System.out.println("T参数:"+t+"\n");
System.out.println("Z参数:"+z+"\n");
}
public void CAMERAPARAMCFG()
{
HCNetSDK.NET_DVR_CAMERAPARAMCFG_EX struCameraParam=new HCNetSDK.NET_DVR_CAMERAPARAMCFG_EX();
Pointer pstruCameraParam=struCameraParam.getPointer();
IntByReference ibrBytesReturned = new IntByReference(0);
boolean b_GetCameraParam=hCNetSDK.NET_DVR_GetDVRConfig(lUserID,3368,1,pstruCameraParam,struCameraParam.size(),ibrBytesReturned);
if (!b_GetCameraParam) {
System.out.println("获取前端参数失败,错误码:" + hCNetSDK.NET_DVR_GetLastError());
}
struCameraParam.read();
System.out.println("是否开启旋转:"+struCameraParam.struCorridorMode.byEnableCorridorMode);
struCameraParam.struCorridorMode.byEnableCorridorMode=1;
struCameraParam.write();
boolean b_SetCameraParam=hCNetSDK.NET_DVR_SetDVRConfig(lUserID,3369,1,pstruCameraParam,struCameraParam.size());
if (!b_SetCameraParam) {
System.out.println("设置前端参数失败,错误码:" + hCNetSDK.NET_DVR_GetLastError());
}
struCameraParam.read();
System.out.println("设置成功");
}
public void GetFocusMode()
{
HCNetSDK.NET_DVR_FOCUSMODE_CFG struFocusMode = new HCNetSDK.NET_DVR_FOCUSMODE_CFG();
struFocusMode.read();
struFocusMode.dwSize=struFocusMode.size();
struFocusMode.write();
Pointer pFocusMode=struFocusMode.getPointer();
IntByReference ibrBytesReturned = new IntByReference(0);
boolean b_GetCameraParam=hCNetSDK.NET_DVR_GetDVRConfig(lUserID,3305,1,pFocusMode,struFocusMode.size(),ibrBytesReturned);
if (!b_GetCameraParam) {
System.out.println("获取快球聚焦模式失败,错误码:" + hCNetSDK.NET_DVR_GetLastError());
}
struFocusMode.read();
System.out.println("聚焦模式:"+struFocusMode.byFocusMode);
struFocusMode.byFocusMode=0;
struFocusMode.byFocusDefinitionDisplay=1;
struFocusMode.byFocusSpeedLevel=3;
struFocusMode.write();
boolean b_SetCameraParam=hCNetSDK.NET_DVR_SetDVRConfig(lUserID,3306,1,pFocusMode,struFocusMode.size());
if (!b_SetCameraParam) {
System.out.println("设置快球聚焦模式失败,错误码:" + hCNetSDK.NET_DVR_GetLastError());
}
struFocusMode.read();
System.out.println("设置成功");
}
public void GetIPPARACFG()
{ IntByReference ibrBytesReturned = new IntByReference(0);//获取IP接入配置参数
HCNetSDK.NET_DVR_IPPARACFG_V40 m_strIpparaCfg = new HCNetSDK.NET_DVR_IPPARACFG_V40();
m_strIpparaCfg.write();
//lpIpParaConfig 接收数据的缓冲指针
Pointer lpIpParaConfig = m_strIpparaCfg.getPointer();
boolean bRet = hCNetSDK.NET_DVR_GetDVRConfig(lUserID, HCNetSDK.NET_DVR_GET_IPPARACFG_V40, 0, lpIpParaConfig, m_strIpparaCfg.size(), ibrBytesReturned);
m_strIpparaCfg.read();
System.out.println("其实数字通道号:"+m_strIpparaCfg.dwStartDChan);
}
海康威视设备 JAVA SDK SpringBoot实现人脸、车辆、门禁图片抓取_灵活的硕硕的博客-CSDN博客实现设备抓拍功能之前,需要完成设备初始化,注册,监听和布防的操作,详见CSDNhttps://mp.csdn.net/mp_blog/creation/editor/121543529创建类FMSGCallBack_V30 并实现FMSGCallBackpublic class FMSGCallBack_V30 implements HCNetSDK.FMSGCallBack {实现抽象方法 @Override public void invoke(int lComm.https://blog.csdn.net/qq_24981615/article/details/123060744