【Multi-Target-Type Detection】Setting Multiple Callback Functions To Receive Different Alarms Events In Arming Mode

サンプルプログラム

//
// Device Network SDK (Multi-Target-Type Detection)
// NET_DVR_SetDVRMessageCallBack_V50
//
// Sample Code of Setting Multiple Callback Functions to Receive Different Alarms/Events in Arming Mode
//
#include <stdio.h>
#include <iostream>
#include “Windows.h”
#include “HCNetSDK.h”
using namespace std;

int iNum=0;
void CALLBACK MessageCallbackNo1(LONG lCommand, NET_DVR_ALARMER *pAlarmer, char *pAlarmInfo, DWORD dwBufLen, void* pUser)
{
int i=0;
char filename[100];
FILE *fSnapPic=NULL;
FILE *fSnapPicPlate=NULL;

//This sample code is for reference only. Actually, it is not recommended to process the data and save file in the callback function directly.
//You’d better process the data in the message response funcion via message mode (PostMessage).

switch(lCommand)
{
case COMM_ALARM:
{
NET_DVR_ALARMINFO struAlarmInfo;
memcpy(&struAlarmInfo, pAlarmInfo, sizeof(NET_DVR_ALARMINFO));
switch (struAlarmInfo.dwAlarmType)
{
case 3: //Motion detection alarm
for (i=0; i<16; i++) //#define MAX_CHANNUM 16 //The maximum number of channels
{
if (struAlarmInfo.dwChannel[i] == 1)
{
printf(“Channel Number with Motion Detection Alarm %d\n”, i+1);
}
}
break;
default:
break;
}
break;
}

case COMM_UPLOAD_PLATE_RESULT:
{
NET_DVR_PLATE_RESULT struPlateResult={0};
memcpy(&struPlateResult, pAlarmInfo, sizeof(struPlateResult));
printf(“License Plate Number: %s\n”, struPlateResult.struPlateInfo.sLicense);//License plate number

switch(struPlateResult.struPlateInfo.byColor)//License plate color
{
case VCA_BLUE_PLATE:
printf(“Vehicle Color: Blue\n”);
break;
case VCA_YELLOW_PLATE:
printf(“Vehicle Color: Yellow\n”);
break;
case VCA_WHITE_PLATE:
printf(“Vehicle Color: White\n”);
break;
case VCA_BLACK_PLATE:
printf(“Vehicle Color: Black\n”);
break;
default:
break;
}

//Scene picture
if (struPlateResult.dwPicLen != 0 && struPlateResult.byResultType == 1 )
{
sprintf(filename,”testpic_%d.jpg”,iNum);

関連記事