【People Counting】Receiving Alarm Event In Listening Mode

サンプルプログラム

//
// Device Network SDK (People Counting)
// Alarm and Event Receiving
// Receive Alarm/Event in Listening Mode
// Sample Code of Receiving Alarm/Event in Listening Mode
//
#include <stdio.h>
#include <iostream>
#include “Windows.h”
#include “HCNetSDK.h”
using namespace std;

void main() {
//—————————————
// Initialize
NET_DVR_Init();
//Set connection time and reconnection time
NET_DVR_SetConnectTime(2000, 1);
NET_DVR_SetReconnect(10000, true);
//—————————————
// Log in to device
LONG lUserID;
NET_DVR_DEVICEINFO_V30 struDeviceInfo;
lUserID = NET_DVR_Login_V30(“172.0.0.100”, 8000, “admin”, “12345”, &struDeviceInfo);
if (lUserID < 0)
{
printf(“Login error, %d\n”, NET_DVR_GetLastError());
NET_DVR_Cleanup();
return;
}

//Enable listening
LONG lHandle;
lHandle = NET_DVR_StartListen_V30(NULL,7200, MessageCallback, NULL);
if (lHandle < 0)
{
printf(“NET_DVR_StartListen_V30 error, %d\n”, NET_DVR_GetLastError());
NET_DVR_Logout(lUserID);
NET_DVR_Cleanup();
return;
}

Sleep(5000);
//Disable listening
if (!NET_DVR_StopListen_V30(lHandle))
{
printf(“NET_DVR_StopListen_V30 error, %d\n”, NET_DVR_GetLastError());
NET_DVR_Logout(lUserID);
NET_DVR_Cleanup();
return;
}

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

関連記事