From 7460b006c922a92a733d55277564579703da191b Mon Sep 17 00:00:00 2001
From: heyujie <516346543@qq.com>
Date: 星期四, 14 十月 2021 11:26:41 +0800
Subject: [PATCH] .c文件
---
hikptz.go | 17 --------
hikptz.h | 14 +++++++
hikptz.c | 62 +++++++++++++++++++++++++++++++
3 files changed, 77 insertions(+), 16 deletions(-)
diff --git a/hikptz.c b/hikptz.c
new file mode 100644
index 0000000..0db4181
--- /dev/null
+++ b/hikptz.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <iostream>
+#include "Windows.h"
+#include "HCNetSDK.h"
+#include <time.h>
+using namespace std;
+
+void PtzTrack(char *ip, char *userName, char *password, char *port ,int channel ,int xBottom ,int xTop ,int yBottom ,int yTop )
+{
+ // 鍒濆鍖�
+ NET_DVR_Init();
+ //璁剧疆杩炴帴鏃堕棿涓庨噸杩炴椂闂�
+ NET_DVR_SetConnectTime(2000, 1);
+ NET_DVR_SetReconnect(10000, true);
+
+ //---------------------------------------
+ //璁剧疆寮傚父娑堟伅鍥炶皟鍑芥暟
+ NET_DVR_SetExceptionCallBack_V30(0, NULL,g_ExceptionCallBack, NULL);
+
+ //---------------------------------------
+ // 娉ㄥ唽璁惧
+ LONG lUserID;
+ //鐧诲綍鍙傛暟锛屽寘鎷澶囧湴鍧�銆佺櫥褰曠敤鎴枫�佸瘑鐮佺瓑
+ NET_DVR_USER_LOGIN_INFO struLoginInfo = {0};
+ struLoginInfo.bUseAsynLogin = 0; //鍚屾鐧诲綍鏂瑰紡
+ strcpy(struLoginInfo.sDeviceAddress, ip); //璁惧IP鍦板潃
+ struLoginInfo.wPort = port; //璁惧鏈嶅姟绔彛
+ strcpy(struLoginInfo.sUserName, userName); //璁惧鐧诲綍鐢ㄦ埛鍚�
+ strcpy(struLoginInfo.sPassword, password); //璁惧鐧诲綍瀵嗙爜
+
+ //璁惧淇℃伅, 杈撳嚭鍙傛暟
+ NET_DVR_DEVICEINFO_V40 struDeviceInfoV40 = {0};
+
+ lUserID = NET_DVR_Login_V40(&struLoginInfo, &struDeviceInfoV40);
+ if (lUserID < 0)
+ {
+ printf("Login failed, error code: %d\n", NET_DVR_GetLastError());
+ NET_DVR_Cleanup();
+ return;
+ }
+ NET_DVR_POINT_FRAME zoneInfo = {0};
+ struLoginInfo.xTop = xTop; //
+ struLoginInfo.yTop = yTop; //
+ struLoginInfo.xBottom = xBottom; //
+ struLoginInfo.yBottom = yBottom; //
+ int iChannel = channel;//璁惧閫氶亾鍙�
+ if(!NET_DVR_PTZSelZoomIn_EX(lUserID, iChannel,zoneInfo))
+ {
+ printf("PAN_LEFT start failed, error code: %d\n", NET_DVR_GetLastError());
+ NET_DVR_Logout(lUserID);
+ NET_DVR_Cleanup();
+ return;
+ }
+ //娉ㄩ攢鐢ㄦ埛
+ NET_DVR_Logout(lUserID);
+
+ //閲婃斁SDK璧勬簮
+ NET_DVR_Cleanup();
+
+ return;
+}
+
diff --git a/hikptz.go b/hikptz.go
index 91b57fd..c260f34 100644
--- a/hikptz.go
+++ b/hikptz.go
@@ -7,25 +7,10 @@
#cgo LDFLAGS: -ldl -lm
#include <stdlib.h>
-#include "Voice.h"
+#include "hikptz.h"
*/
import "C"
-// type PtzDevice struct {
-// IpAddr string `form:"ipAddr" json:"ipAddr"`
-// Port string `form:"port" json:"port"`
-// UserName string `form:"userName" json:"userName"`
-// Password string `form:"password" json:"password"`
-// }
-
-// type PtzZoneService struct {
-// UserName string `form:"userName" json:"userName"`
-// Channel string `form:"channel" json:"channel"`
-// XTop string `form:"xTop" json:"xTop"`
-// YTop string `form:"yTop" json:"yTop"`
-// XBottom string `form:"xBottom" json:"xBottom"`
-// YBottom string `form:"yBottom" json:"yBottom"`
-// }
// SendVoice Send Voice
diff --git a/hikptz.h b/hikptz.h
new file mode 100644
index 0000000..ea700ad
--- /dev/null
+++ b/hikptz.h
@@ -0,0 +1,14 @@
+#ifndef _HIKPTZ_H
+#define _HIKPTZ_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int PtzTrack(char *ip, char *userName, char *password, char *port);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
--
Gitblit v1.8.0