فهرست منبع

1. 添加 获取 Nvr 与 UTC 之间的插曲接口
2. 修复 球机聚焦接口存在的错误
3. 修复 PTZ 跳转到指定位置 Action 参数标准海康接口下无效的问题,以及无法设置Z值
4. 移除 GetBallCameraByName
5. 添加 PointPair 配置文件结构

王帅锟 10 ماه پیش
والد
کامیت
002d24e2b0
7فایلهای تغییر یافته به همراه40 افزوده شده و 35 حذف شده
  1. 3 4
      Hikvision.go
  2. 21 21
      Type.go
  3. 1 0
      include/library.h
  4. 5 0
      library.cpp
  5. 7 6
      src/HIKBallCamera.cpp
  6. 2 3
      src/HIKNvr.cpp
  7. 1 1
      src/HIKNvr.h

+ 3 - 4
Hikvision.go

@@ -163,13 +163,12 @@ func (h *HIKBallCamera) PTZ2FullView() (Point, error) {
 	if !h.PTZGet(&ptz.P, &ptz.T, &ptz.Z) {
 		return Point{}, fmt.Errorf("PTZ Get Error")
 	}
-	h.WarpingPtByHomography(h.BallCameraCfg.Matrix.InvMatrix, Point{
+	return h.WarpingPtByHomography(h.BallCameraCfg.Matrix.InvMatrix, Point{
 		X: h.mapping(h.BallCameraCfg.Matrix.PStart, h.BallCameraCfg.Matrix.PMax, float64(ptz.P), h.BallCameraCfg.Matrix.PPositiveDirection, ""),
-		Y: h.mapping(h.BallCameraCfg.Matrix.TStart, h.BallCameraCfg.Matrix.TMax, float64(ptz.T), h.BallCameraCfg.Matrix.TPositiveDirection, "")})
-	return Point{}, nil
+		Y: h.mapping(h.BallCameraCfg.Matrix.TStart, h.BallCameraCfg.Matrix.TMax, float64(ptz.T), h.BallCameraCfg.Matrix.TPositiveDirection, "")}), nil
 }
 
-func (hikBC *HIKBallCamera) invert3x3() bool {
+func (hikBC *HIKBallCamera) Invert3x3() bool {
 
 	a := hikBC.BallCameraCfg.Matrix.Matrix[0]
 	b := hikBC.BallCameraCfg.Matrix.Matrix[1]

+ 21 - 21
Type.go

@@ -3,25 +3,25 @@ package HikNetSDK
 import "encoding/json"
 
 type HikCfg struct {
-	Nvr        []Nvr        `json:"Nvr"`
-	BallCamera []BallCamera `json:"BallCamera"`
+	Nvr        map[string]Nvr        `json:"Nvr"`
+	BallCamera map[string]BallCamera `json:"BallCamera"`
 }
 
 type Nvr struct {
-	Name     string `json:"name"`
-	Ip       string `json:"ip"`
-	Port     string `json:"port"`
-	User     string `json:"user"`
+	Name     string `json:"Name"`
+	Ip       string `json:"Ip"`
+	Port     string `json:"Port"`
+	User     string `json:"User"`
 	Password string `json:"Password"`
 	Channel  int    `json:"Channel"`
 }
 
 type BallCamera struct {
 	Type     string `json:"Type"`
-	Name     string `json:"name"`
-	Ip       string `json:"ip"`
-	Port     string `json:"port"`
-	User     string `json:"user"`
+	Name     string `json:"Name"`
+	Ip       string `json:"Ip"`
+	Port     string `json:"Port"`
+	User     string `json:"User"`
 	Password string `json:"Password"`
 	RtspUrl  string `json:"RtspUrl"`
 	Matrix   Matrix `json:"Matrix"`
@@ -37,8 +37,17 @@ type Matrix struct {
 	TPositiveDirection string    `json:"T_Positive_Direction"`
 	Matrix             []float64 `json:"Matrix"`
 	InvMatrix          []float64 `json:"InvMatrix"`
+	PointSet           map[string]PointPair `json:"PointSet"`
 }
 
+type PointPair struct {
+	X float64 `json:"X"`
+	Y float64 `json:"Y"`
+	P float64 `json:"P"`
+	T float64 `json:"T"`
+}
+
+
 type PTZ struct {
 	P float32 `json:"P"`
 	T float32 `json:"T"`
@@ -50,8 +59,8 @@ type MoveCfg struct {
 	Direction int `json:"Direction"`
 }
 type Point struct {
-	X float64 `json:"x"`
-	Y float64 `json:"y"`
+	X float64 `json:"X"`
+	Y float64 `json:"Y"`
 }
 
 func (h *HikCfg) Json() []byte {
@@ -61,12 +70,3 @@ func (h *HikCfg) Json() []byte {
 	}
 	return marshal
 }
-
-func (h *HikCfg) GetBallCameraByName(name string) *BallCamera {
-	for i, camera := range h.BallCamera {
-		if camera.Name == name {
-			return &h.BallCamera[i]
-		}
-	}
-	return nil
-}

+ 1 - 0
include/library.h

@@ -29,6 +29,7 @@ extern "C" {
     Omnimatrix bool InitNvr(void* PtrHIKNvr,char* ip, char* port, char* username, char* password, int channel);
     Omnimatrix char* CheckTimeRegionWithMonth(void* PtrHIKNvr,int year,int month);
     Omnimatrix char* CheckTimeRegionWithDay(void* PtrHIKNvr,int year,int month,int day);
+    Omnimatrix int NvrUTCDiff();
 
 #ifdef __cplusplus
 }

+ 5 - 0
library.cpp

@@ -83,4 +83,9 @@ char* CheckTimeRegionWithDay(void* PtrHIKNvr,int year,int month,int day){
     char* cString = new char[res.size() + 1];
     std::strcpy(cString,res.c_str());
     return cString;
+}
+
+int NvrUTCDiff(void* PtrHIKNvr){
+    auto* HIKNvrObj = (HIKNvr*)PtrHIKNvr;
+    return HIKNvrObj->GetNvrUTCDiff();
 }

+ 7 - 6
src/HIKBallCamera.cpp

@@ -148,7 +148,7 @@ bool HIKBallCamera::PtzControlFocusAdd(int speed,int state){
         SerialSend(PrepareHexString("ff 01 01 00 00 00 02"));
         return true;
     }else{
-        return PtzControl(ZOOM_OUT, state, speed);
+        return PtzControl(FOCUS_FAR, state, speed);
     }
 }
 
@@ -158,7 +158,7 @@ bool HIKBallCamera::PtzControlFocusSub(int speed,int state){
         SerialSend(PrepareHexString("ff 01 00 80 00 00 81"));
         return true;
     }else{
-        return PtzControl(ZOOM_OUT, state, speed);
+        return PtzControl(FOCUS_NEAR, state, speed);
     }
 }
 
@@ -283,7 +283,8 @@ bool HIKBallCamera::PtzGotoPut(int Action, float P, float T, float Z)
         NET_DVR_PTZPOS ptzPosCurrent;
         ptzPosCurrent.wPanPos = DEC2HEX(P);
         ptzPosCurrent.wTiltPos = DEC2HEX(T);
-        ptzPosCurrent.wAction = 5;
+        ptzPosCurrent.wZoomPos = DEC2HEX(Z);
+        ptzPosCurrent.wAction = Action;
 
         bool b = NET_DVR_SetDVRConfig(LoginID, NET_DVR_SET_PTZPOS, m_Channel, &ptzPosCurrent, sizeof(NET_DVR_PTZPOS));
         return b;
@@ -315,9 +316,9 @@ bool HIKBallCamera::PtzGet(float* posP, float* posT, float* posZ) {
         float P = HEX2DEC(ptzPosCurrent.wPanPos);
         float T = HEX2DEC(ptzPosCurrent.wTiltPos);
         float Z = HEX2DEC(ptzPosCurrent.wZoomPos);
-        posP = &P;
-        posT = &T;
-        posZ = &Z;
+        *posP = P;
+        *posT = T;
+        *posZ = Z;
         return b;
     }
 }

+ 2 - 3
src/HIKNvr.cpp

@@ -27,15 +27,14 @@ bool HIKNvr::InitNvr(std::string ip, std::string port, std::string username, std
     return false;
 }
 
-bool HIKNvr::GetNvrUTCDiff(){
+int HIKNvr::GetNvrUTCDiff(){
     NET_DVR_NETAPPCFG struNAC = {0};
     DWORD ZoneSize = 0;
     NET_DVR_GetDVRConfig(LoginID, NET_DVR_GET_NETAPPCFG, 0, &struNAC, sizeof(NET_DVR_NETAPPCFG), &ZoneSize);
     int nDiffHour = struNAC.struNtpClientParam.cTimeDifferenceH;
     int nDiffMin = struNAC.struNtpClientParam.cTimeDifferenceM;
-
     nDiffTotalMin = (nDiffHour < 0 ? -1 : 1) * (abs(nDiffHour) * 60 + nDiffMin);
-    return true;
+    return (nDiffHour < 0 ? -1 : 1) * (abs(nDiffHour) * 60 + nDiffMin);
 }
 
 /**

+ 1 - 1
src/HIKNvr.h

@@ -42,7 +42,7 @@ public:
     //though input SelectTime get the time region
     bool GetTimeRegion(DateTime select_time,int value ,DateTime &time_start,DateTime &time_end);
 
-    bool GetNvrUTCDiff();
+    int GetNvrUTCDiff();
     int nDiffTotalMin;
 
 public: