From a0d9d5ccd33aa09b4624fdfd2dd3269a9b82ba83 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期三, 13 十二月 2023 16:27:54 +0800
Subject: [PATCH] 增加海康sdk设置高精度ptz信息
---
ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/lib/HCNetSDK.java | 5 +-
ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java | 67 +++++++++++++++++++++++++++++++--
2 files changed, 66 insertions(+), 6 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/lib/HCNetSDK.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/lib/HCNetSDK.java
index 671e982..1372e82 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/lib/HCNetSDK.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/lib/HCNetSDK.java
@@ -538,6 +538,7 @@
public static final int NET_DVR_GET_PTZSCOPE = 294;//浜戝彴鑾峰彇PTZ鑼冨洿
public static final int NET_DVR_SET_BASICPARAMCFG = 3271;//璁剧疆PTZ鍩烘湰鍙傛暟淇℃伅
public static final int NET_DVR_COMPLETE_RESTORE_CTRL = 3420; //璁剧疆瀹屽叏鎭㈠鍑哄巶鍊�
+ public static final int NET_DVR_SET_PTZABSOLUTEEX = 6697;//璁剧疆楂樼簿搴TZ缁濆浣嶇疆閰嶇疆
/***************************
* DS9000鏂板鍛戒护(_V30) begin
*****************************/
@@ -953,8 +954,8 @@
public static final int EXCEPTION_SERIALRECONNECT = 0x8007;//閫忔槑閫氶亾閲嶈繛
public static final int EXCEPTION_PLAYBACK = 0x8010;//鍥炴斁寮傚父
public static final int EXCEPTION_DISKFMT = 0x8011;//纭洏鏍煎紡鍖�
- public static final int EXCEPTION_RELOGIN=0x8040;//鐢ㄦ埛閲嶇櫥闄�
- public static final int RELOGIN_SUCCESS=0x8041;//鐢ㄦ埛閲嶇櫥闄嗘垚鍔�
+ public static final int EXCEPTION_RELOGIN = 0x8040;//鐢ㄦ埛閲嶇櫥闄�
+ public static final int RELOGIN_SUCCESS = 0x8041;//鐢ㄦ埛閲嶇櫥闄嗘垚鍔�
/********************
* 棰勮鍥炶皟鍑芥暟
*********************/
diff --git a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
index ac1388b..d822c17 100644
--- a/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
+++ b/ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java
@@ -269,7 +269,7 @@
//娣诲姞鍒版祦濯掍綋
addVtdu(camera);
//鍒涘缓寮曞闃熷垪
- if(camera.getCamAlarmGuideEnable()==1) {
+ if (camera.getCamAlarmGuideEnable() == 1) {
if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
PriorityBlockingQueue<GuideTask> priorityQueue = new PriorityBlockingQueue<>(1000, comparator);
@@ -930,8 +930,8 @@
* @鍒涘缓鏃堕棿 2023/1/17 16:36
* @淇敼浜哄拰鍏跺畠淇℃伅 娉ㄦ剰淇话瑙掑害璐熷�奸渶瑕佸姞涓�360寰楀埌鐨勬鍊艰繘琛岃缃�
*/
- @Override
- public boolean setPtz(CameraCmd cmd) {
+
+ public boolean setPtz1(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
Integer channelNum = cmd.getChanNo();
Map<String, Double> ptz = cmd.getPtzMap();
@@ -953,7 +953,7 @@
boolean bool = hCNetSDK.NET_DVR_SetDVRConfig(userId, NET_DVR_SET_PTZPOS, channelNum, point, m_ptzPosCurrent.size());
if (!bool) {
int code = hCNetSDK.NET_DVR_GetLastError();
- log.error("璁剧疆ptz澶辫触,璇风◢鍚庨噸璇�" + code);
+ log.error("璁剧疆PTZ鍙傛暟澶辫触,璇风◢鍚庨噸璇�:" + code);
}
return bool;
} catch (Exception ex) {
@@ -962,6 +962,65 @@
}
}
+ /**
+ * @鎻忚堪 璁剧疆楂樼簿搴tz淇℃伅
+ * @鍙傛暟 [userId, channelNum]
+ * @杩斿洖鍊� boolean
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/1/17 16:36
+ * @淇敼浜哄拰鍏跺畠淇℃伅 娉ㄦ剰淇话瑙掑害璐熷�煎悜涓嬭礋鍊�
+ */
+ @Override
+ public boolean setPtz(CameraCmd cmd) {
+ try {
+ String cameraId = cmd.getCameraId();
+ Integer chanNo = cmd.getChanNo();
+ Map<String, Double> ptz = cmd.getPtzMap();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return false;
+ }
+ Integer lUserID = (Integer) GlobalVariable.loginMap.get(cameraId);
+ IntByReference pchannel = new IntByReference(chanNo);
+ Pointer pChannelNum = pchannel.getPointer();
+
+ HCNetSDK.NET_DVR_STD_CONFIG lpConfigParam6697 = new HCNetSDK.NET_DVR_STD_CONFIG();
+ HCNetSDK.NET_DVR_PTZABSOLUTEEX_CFG lpPTZAbsoluteEX_cfgInfo = new HCNetSDK.NET_DVR_PTZABSOLUTEEX_CFG();
+ lpConfigParam6697.lpCondBuffer = pChannelNum;
+ lpConfigParam6697.dwCondSize = 4;
+ HCNetSDK.BYTE_ARRAY m_szStatusBuf = new HCNetSDK.BYTE_ARRAY(4096 * 4);
+ lpConfigParam6697.lpStatusBuffer = m_szStatusBuf.getPointer();
+ lpConfigParam6697.dwStatusSize = 4096 * 4;
+ lpPTZAbsoluteEX_cfgInfo.dwSize = lpPTZAbsoluteEX_cfgInfo.size();
+ lpPTZAbsoluteEX_cfgInfo.struPTZCtrl.fPan = new Double(ptz.get("p")).floatValue();
+ float t = new Double(ptz.get("t")).floatValue();
+ float t1 = t > 300 ? (t - 360) : t;
+ BigDecimal bigDecimal = new BigDecimal(t1);
+ float t2 = bigDecimal.setScale(2, BigDecimal.ROUND_HALF_UP).floatValue();
+ lpPTZAbsoluteEX_cfgInfo.struPTZCtrl.fTilt = t2;
+ lpPTZAbsoluteEX_cfgInfo.struPTZCtrl.fZoom = new Double(ptz.get("z")).floatValue();
+ lpPTZAbsoluteEX_cfgInfo.struPTZCtrl.dwFocus = 399;
+ lpPTZAbsoluteEX_cfgInfo.dwFocalLen = 1250;
+ lpPTZAbsoluteEX_cfgInfo.fHorizontalSpeed = (float) 10;
+ lpPTZAbsoluteEX_cfgInfo.fVerticalSpeed = (float) 10;
+ lpPTZAbsoluteEX_cfgInfo.byZoomType = 0;
+ lpPTZAbsoluteEX_cfgInfo.write();
+ lpConfigParam6697.lpInBuffer = lpPTZAbsoluteEX_cfgInfo.getPointer();
+ lpConfigParam6697.dwInSize = lpPTZAbsoluteEX_cfgInfo.dwSize;
+ lpConfigParam6697.write();
+ boolean bool = hCNetSDK.NET_DVR_SetSTDConfig(lUserID, NET_DVR_SET_PTZABSOLUTEEX, lpConfigParam6697);
+ if (!bool) {
+ int code = hCNetSDK.NET_DVR_GetLastError();
+ log.error("璁剧疆楂樼簿搴TZ鍙傛暟澶辫触,璇风◢鍚庨噸璇�:" + code);
+ }
+ return bool;
+
+ }catch (Exception ex)
+ {
+ log.error("璁剧疆楂樼簿搴TZ鍙傛暟寮傚父",ex);
+ return false;
+ }
+ }
+
@Override
public boolean guideTargetPosition(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
--
Gitblit v1.9.3