heyujie
2021-10-14 7460b006c922a92a733d55277564579703da191b
.c文件
2个文件已添加
1个文件已修改
93 ■■■■ 已修改文件
hikptz.c 62 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hikptz.go 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hikptz.h 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
hikptz.c
New file
@@ -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;
}
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
hikptz.h
New file
@@ -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