1. 添加 获取 Nvr 与 UTC 之间的插曲接口
2. 修复 球机聚焦接口存在的错误 3. 修复 PTZ 跳转到指定位置 Action 参数标准海康接口下无效的问题,以及无法设置Z值 4. 移除 GetBallCameraByName 5. 添加 PointPair 配置文件结构
This commit is contained in:
@@ -163,13 +163,12 @@ func (h *HIKBallCamera) PTZ2FullView() (Point, error) {
|
|||||||
if !h.PTZGet(&ptz.P, &ptz.T, &ptz.Z) {
|
if !h.PTZGet(&ptz.P, &ptz.T, &ptz.Z) {
|
||||||
return Point{}, fmt.Errorf("PTZ Get Error")
|
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, ""),
|
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, "")})
|
Y: h.mapping(h.BallCameraCfg.Matrix.TStart, h.BallCameraCfg.Matrix.TMax, float64(ptz.T), h.BallCameraCfg.Matrix.TPositiveDirection, "")}), nil
|
||||||
return Point{}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (hikBC *HIKBallCamera) invert3x3() bool {
|
func (hikBC *HIKBallCamera) Invert3x3() bool {
|
||||||
|
|
||||||
a := hikBC.BallCameraCfg.Matrix.Matrix[0]
|
a := hikBC.BallCameraCfg.Matrix.Matrix[0]
|
||||||
b := hikBC.BallCameraCfg.Matrix.Matrix[1]
|
b := hikBC.BallCameraCfg.Matrix.Matrix[1]
|
||||||
|
|||||||
42
Type.go
42
Type.go
@@ -3,25 +3,25 @@ package HikNetSDK
|
|||||||
import "encoding/json"
|
import "encoding/json"
|
||||||
|
|
||||||
type HikCfg struct {
|
type HikCfg struct {
|
||||||
Nvr []Nvr `json:"Nvr"`
|
Nvr map[string]Nvr `json:"Nvr"`
|
||||||
BallCamera []BallCamera `json:"BallCamera"`
|
BallCamera map[string]BallCamera `json:"BallCamera"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Nvr struct {
|
type Nvr struct {
|
||||||
Name string `json:"name"`
|
Name string `json:"Name"`
|
||||||
Ip string `json:"ip"`
|
Ip string `json:"Ip"`
|
||||||
Port string `json:"port"`
|
Port string `json:"Port"`
|
||||||
User string `json:"user"`
|
User string `json:"User"`
|
||||||
Password string `json:"Password"`
|
Password string `json:"Password"`
|
||||||
Channel int `json:"Channel"`
|
Channel int `json:"Channel"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BallCamera struct {
|
type BallCamera struct {
|
||||||
Type string `json:"Type"`
|
Type string `json:"Type"`
|
||||||
Name string `json:"name"`
|
Name string `json:"Name"`
|
||||||
Ip string `json:"ip"`
|
Ip string `json:"Ip"`
|
||||||
Port string `json:"port"`
|
Port string `json:"Port"`
|
||||||
User string `json:"user"`
|
User string `json:"User"`
|
||||||
Password string `json:"Password"`
|
Password string `json:"Password"`
|
||||||
RtspUrl string `json:"RtspUrl"`
|
RtspUrl string `json:"RtspUrl"`
|
||||||
Matrix Matrix `json:"Matrix"`
|
Matrix Matrix `json:"Matrix"`
|
||||||
@@ -37,8 +37,17 @@ type Matrix struct {
|
|||||||
TPositiveDirection string `json:"T_Positive_Direction"`
|
TPositiveDirection string `json:"T_Positive_Direction"`
|
||||||
Matrix []float64 `json:"Matrix"`
|
Matrix []float64 `json:"Matrix"`
|
||||||
InvMatrix []float64 `json:"InvMatrix"`
|
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 {
|
type PTZ struct {
|
||||||
P float32 `json:"P"`
|
P float32 `json:"P"`
|
||||||
T float32 `json:"T"`
|
T float32 `json:"T"`
|
||||||
@@ -50,8 +59,8 @@ type MoveCfg struct {
|
|||||||
Direction int `json:"Direction"`
|
Direction int `json:"Direction"`
|
||||||
}
|
}
|
||||||
type Point struct {
|
type Point struct {
|
||||||
X float64 `json:"x"`
|
X float64 `json:"X"`
|
||||||
Y float64 `json:"y"`
|
Y float64 `json:"Y"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (h *HikCfg) Json() []byte {
|
func (h *HikCfg) Json() []byte {
|
||||||
@@ -61,12 +70,3 @@ func (h *HikCfg) Json() []byte {
|
|||||||
}
|
}
|
||||||
return marshal
|
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
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ extern "C" {
|
|||||||
Omnimatrix bool InitNvr(void* PtrHIKNvr,char* ip, char* port, char* username, char* password, int channel);
|
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* CheckTimeRegionWithMonth(void* PtrHIKNvr,int year,int month);
|
||||||
Omnimatrix char* CheckTimeRegionWithDay(void* PtrHIKNvr,int year,int month,int day);
|
Omnimatrix char* CheckTimeRegionWithDay(void* PtrHIKNvr,int year,int month,int day);
|
||||||
|
Omnimatrix int NvrUTCDiff();
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -84,3 +84,8 @@ char* CheckTimeRegionWithDay(void* PtrHIKNvr,int year,int month,int day){
|
|||||||
std::strcpy(cString,res.c_str());
|
std::strcpy(cString,res.c_str());
|
||||||
return cString;
|
return cString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int NvrUTCDiff(void* PtrHIKNvr){
|
||||||
|
auto* HIKNvrObj = (HIKNvr*)PtrHIKNvr;
|
||||||
|
return HIKNvrObj->GetNvrUTCDiff();
|
||||||
|
}
|
||||||
@@ -148,7 +148,7 @@ bool HIKBallCamera::PtzControlFocusAdd(int speed,int state){
|
|||||||
SerialSend(PrepareHexString("ff 01 01 00 00 00 02"));
|
SerialSend(PrepareHexString("ff 01 01 00 00 00 02"));
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}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"));
|
SerialSend(PrepareHexString("ff 01 00 80 00 00 81"));
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}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;
|
NET_DVR_PTZPOS ptzPosCurrent;
|
||||||
ptzPosCurrent.wPanPos = DEC2HEX(P);
|
ptzPosCurrent.wPanPos = DEC2HEX(P);
|
||||||
ptzPosCurrent.wTiltPos = DEC2HEX(T);
|
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));
|
bool b = NET_DVR_SetDVRConfig(LoginID, NET_DVR_SET_PTZPOS, m_Channel, &ptzPosCurrent, sizeof(NET_DVR_PTZPOS));
|
||||||
return b;
|
return b;
|
||||||
@@ -315,9 +316,9 @@ bool HIKBallCamera::PtzGet(float* posP, float* posT, float* posZ) {
|
|||||||
float P = HEX2DEC(ptzPosCurrent.wPanPos);
|
float P = HEX2DEC(ptzPosCurrent.wPanPos);
|
||||||
float T = HEX2DEC(ptzPosCurrent.wTiltPos);
|
float T = HEX2DEC(ptzPosCurrent.wTiltPos);
|
||||||
float Z = HEX2DEC(ptzPosCurrent.wZoomPos);
|
float Z = HEX2DEC(ptzPosCurrent.wZoomPos);
|
||||||
posP = &P;
|
*posP = P;
|
||||||
posT = &T;
|
*posT = T;
|
||||||
posZ = &Z;
|
*posZ = Z;
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,15 +27,14 @@ bool HIKNvr::InitNvr(std::string ip, std::string port, std::string username, std
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HIKNvr::GetNvrUTCDiff(){
|
int HIKNvr::GetNvrUTCDiff(){
|
||||||
NET_DVR_NETAPPCFG struNAC = {0};
|
NET_DVR_NETAPPCFG struNAC = {0};
|
||||||
DWORD ZoneSize = 0;
|
DWORD ZoneSize = 0;
|
||||||
NET_DVR_GetDVRConfig(LoginID, NET_DVR_GET_NETAPPCFG, 0, &struNAC, sizeof(NET_DVR_NETAPPCFG), &ZoneSize);
|
NET_DVR_GetDVRConfig(LoginID, NET_DVR_GET_NETAPPCFG, 0, &struNAC, sizeof(NET_DVR_NETAPPCFG), &ZoneSize);
|
||||||
int nDiffHour = struNAC.struNtpClientParam.cTimeDifferenceH;
|
int nDiffHour = struNAC.struNtpClientParam.cTimeDifferenceH;
|
||||||
int nDiffMin = struNAC.struNtpClientParam.cTimeDifferenceM;
|
int nDiffMin = struNAC.struNtpClientParam.cTimeDifferenceM;
|
||||||
|
|
||||||
nDiffTotalMin = (nDiffHour < 0 ? -1 : 1) * (abs(nDiffHour) * 60 + nDiffMin);
|
nDiffTotalMin = (nDiffHour < 0 ? -1 : 1) * (abs(nDiffHour) * 60 + nDiffMin);
|
||||||
return true;
|
return (nDiffHour < 0 ? -1 : 1) * (abs(nDiffHour) * 60 + nDiffMin);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public:
|
|||||||
//though input SelectTime get the time region
|
//though input SelectTime get the time region
|
||||||
bool GetTimeRegion(DateTime select_time,int value ,DateTime &time_start,DateTime &time_end);
|
bool GetTimeRegion(DateTime select_time,int value ,DateTime &time_start,DateTime &time_end);
|
||||||
|
|
||||||
bool GetNvrUTCDiff();
|
int GetNvrUTCDiff();
|
||||||
int nDiffTotalMin;
|
int nDiffTotalMin;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|||||||
Reference in New Issue
Block a user