From 03f0316ede495bc4391b041232a982aa52e5d649 Mon Sep 17 00:00:00 2001
From: ‘liusuyi’ <1951119284@qq.com>
Date: 星期五, 15 十二月 2023 11:58:19 +0800
Subject: [PATCH] 增加海康sdk获取高精度ptz
---
ard-work/src/main/java/com/ruoyi/utils/sdk/hiksdk/service/impl/HikvisionSDK.java | 64 ++++++++++++++++++++++++++++---
1 files changed, 57 insertions(+), 7 deletions(-)
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 8bf60c2..55f7de1 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
@@ -57,7 +57,7 @@
@Resource
private QueueHandler queueHandler;
- public Object _lock=new Object();
+ public Object _lock = new Object();
public static HCNetSDK hCNetSDK = HCNetSDK.hCNetSDK;
private static HCNetSDK.FExceptionCallBack fExceptionCallBack;//寮傚父鍥炶皟
@@ -278,7 +278,7 @@
//鍒涘缓寮曞闃熷垪
private void createGuideQueue(ArdCameras camera) {
- if(camera.getCamAlarmGuideEnable()!=null) {
+ if (camera.getCamAlarmGuideEnable() != null) {
if (camera.getCamAlarmGuideEnable() == 1) {
if (!GuidePriorityQueue.cameraQueueMap.containsKey(camera.getId())) {
Comparator<GuideTask> comparator = GuidePriorityQueue.getComparator();
@@ -290,6 +290,7 @@
}
}
}
+
//娣诲姞鍒版祦濯掍綋
private void addVtdu(ArdCameras camera) {
try {
@@ -888,8 +889,7 @@
* @鍒涘缓鏃堕棿 2023/1/17 16:36
* @淇敼浜哄拰鍏跺畠淇℃伅
*/
- @Override
- public Map<String, Object> getPtz(CameraCmd cmd) {
+ public Map<String, Object> getPtz1(CameraCmd cmd) {
String cameraId = cmd.getCameraId();
Integer channelNum = cmd.getChanNo();
if (!GlobalVariable.loginMap.containsKey(cameraId)) {
@@ -927,6 +927,57 @@
log.error("鎺у埗澶辫触,璇风◢鍚庨噸璇�" + code);
return new HashMap<>();
}
+ }
+
+ /**
+ * @鎻忚堪 鑾峰彇楂樼簿搴tz淇℃伅
+ * @鍙傛暟 [userId, chanNo]
+ * @杩斿洖鍊� boolean
+ * @鍒涘缓浜� 鍒樿嫃涔�
+ * @鍒涘缓鏃堕棿 2023/1/17 16:36
+ * @淇敼浜哄拰鍏跺畠淇℃伅
+ */
+ @Override
+ public Map<String, Object> getPtz(CameraCmd cmd) {
+ Map<String, Object> ptzMap = new HashMap<>();
+ try {
+ String cameraId = cmd.getCameraId();
+ Integer chanNo = cmd.getChanNo();
+ if (!GlobalVariable.loginMap.containsKey(cameraId)) {
+ return new HashMap<>();
+ }
+ IntByReference pchannel = new IntByReference(chanNo);
+ Pointer pChannelNum = pchannel.getPointer();
+ Integer lUserID = (Integer) GlobalVariable.loginMap.get(cameraId);
+ HCNetSDK.NET_DVR_STD_CONFIG lpConfigParam6696 = new HCNetSDK.NET_DVR_STD_CONFIG();
+ HCNetSDK.NET_DVR_PTZABSOLUTEEX_CFG lpPTZAbsoluteEX_cfg = new HCNetSDK.NET_DVR_PTZABSOLUTEEX_CFG();
+ lpConfigParam6696.lpCondBuffer = pChannelNum;
+ lpConfigParam6696.dwCondSize = 4;
+ lpConfigParam6696.lpInBuffer = null;
+ lpConfigParam6696.dwInSize = 0;
+ lpConfigParam6696.lpOutBuffer = lpPTZAbsoluteEX_cfg.getPointer();
+ lpConfigParam6696.dwOutSize = lpPTZAbsoluteEX_cfg.size();
+ lpConfigParam6696.write();
+ boolean res = hCNetSDK.NET_DVR_GetSTDConfig(lUserID, HCNetSDK.NET_DVR_GET_PTZABSOLUTEEX, lpConfigParam6696);
+ if (!res) {
+ log.error("鑾峰彇楂樼簿搴TZ缁濆浣嶇疆閰嶇疆澶辫触锛岄敊璇彿锛�" + hCNetSDK.NET_DVR_GetLastError());
+ } else {
+ lpPTZAbsoluteEX_cfg.read();
+ //log.debug("P锛�" + lpPTZAbsoluteEX_cfg.struPTZCtrl.fPan + " T锛�" + lpPTZAbsoluteEX_cfg.struPTZCtrl.fTilt + " Z锛�" + lpPTZAbsoluteEX_cfg.struPTZCtrl.fZoom
+ // + " 鑱氱劍鍙傛暟锛�" + lpPTZAbsoluteEX_cfg.struPTZCtrl.dwFocus + " 鑱氱劍鑼冨洿锛�" + lpPTZAbsoluteEX_cfg.dwFocalLen + " 姘村钩杞姩閫熷害锛�" + lpPTZAbsoluteEX_cfg.fHorizontalSpeed
+ // + " 鍨傜洿杞姩閫熷害锛�" + lpPTZAbsoluteEX_cfg.fVerticalSpeed + " 闀滃ご鍙樺�嶉厤缃被鍨嬶細" + lpPTZAbsoluteEX_cfg.byZoomType);
+ float p = lpPTZAbsoluteEX_cfg.struPTZCtrl.fPan;
+ float fTilt = lpPTZAbsoluteEX_cfg.struPTZCtrl.fTilt;
+ float t = fTilt < 0 ? fTilt + 360 : fTilt;
+ float z = lpPTZAbsoluteEX_cfg.struPTZCtrl.fZoom;
+ ptzMap.put("p", p);
+ ptzMap.put("t", t);
+ ptzMap.put("z", z);
+ }
+ } catch (Exception ex) {
+ log.error("鑾峰彇楂樼簿搴TZ缁濆浣嶇疆寮傚父:" + ex.getMessage());
+ }
+ return ptzMap;
}
/**
@@ -1021,9 +1072,8 @@
}
return bool;
- }catch (Exception ex)
- {
- log.error("璁剧疆楂樼簿搴TZ鍙傛暟寮傚父",ex);
+ } catch (Exception ex) {
+ log.error("璁剧疆楂樼簿搴TZ鍙傛暟寮傚父", ex);
return false;
}
}
--
Gitblit v1.9.3