【Face Recognition Terminal】Remotely Controlling Door

サンプルプログラム

//
// Device Network SDK (Face Recognition Terminal)
// Manage Face Information
// Remotely Control Door
// Sample Code for Remotely Controlling Door
//
#include <stdio.h>
#include <iostream>
#include <afx.h>
#include “Windows.h”
#include “HCNetSDK.h”

using namespace std;

void main()
{
//—————————————
//Initialize

NET_DVR_Init();

//Set connection timeout and reconnection function
NET_DVR_SetConnectTime(2000, 1);

NET_DVR_SetReconnect(10000, true);

//—————————————
//Initialize

NET_DVR_Init();

//Set connection timeout and reconnection function
NET_DVR_SetConnectTime(2000, 1);

NET_DVR_SetReconnect(10000, true);

//—————————————
//Log in to device
LONG lUserID;
//Login parameters, including device IP address, user name, password, and so on
NET_DVR_USER_LOGIN_INFO struLoginInfo = {0};
struLoginInfo.bUseAsynLogin = 0; //Synchronous login mode
strcpy(struLoginInfo.sDeviceAddress, “192.168.1.64”); //Device IP address
struLoginInfo.wPort = 8000; //Device service port number
strcpy(struLoginInfo.sUserName, “admin”); //User name

strcpy(struLoginInfo.sPassword, “abcd1234”); //Password

//Device information, output parameter
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;

}

//Open door, take door 1 as an example
BOOL bRet;
LONG lGatewayIndex = 1;//Access controller No., starts from 1, -1: control all doors
DWORD dwStaic = 1;//Command No.: 0-Close, 1-Open, 2-Remain Open, 3-Remain Closed
bRet = NET_DVR_ControlGateway(lUserID,lGatewayIndex,dwStaic);
if (!bRet)
{
printf(“NET_DVR_ControlGateway failed, error:%d\n”,NET_DVR_GetLastError());
NET_DVR_Logout(lUserID);
NET_DVR_Cleanup();
return;

}

//—————————————
//Exit

Sleep(5000);

//Log out
NET_DVR_Logout(lUserID);
//Release SDK resource
NET_DVR_Cleanup();
return;
}

関連記事