IPC Face Target Configuration Management Face target management: including the issuance, modification, query and deletion of personnel information such as personnel number, card number, face, telephone, name, password, etc.
Interface Overview interface Name Functional Description NET_SDK_GetDeviceSupportFunction Determine whether it supports face matching by getting the ipc capability set NET_SDK_FaceMatchOperate Face comparison related operations, including the addition, deletion, and modification of face information.
Process Description ---
title: IPC Face Target Configuration
---
flowchart TD
A(Device SDK initialization <br><strong>NET_SDK_Init</strong>)
B(User registration device <br><strong>NET_SDK_Login</strong> or <br><strong>NET_SDK_LoginEx</strong>)
C{Support matching?}
D(Call interface <br><strong>NET_SDK_FaceMatchOperate</strong>)
C0(Query face list <br><strong>NET_SDK_GET_FACE_INFO_LIST</strong><hr>Add face <br><strong>NET_SDK_ADD_FACE_INFO</strong><hr>Modify face <br><strong>NET_SDK_SET_FACE_INFO</strong><hr>Delete face <br><strong>NET_SDK_DEL_FACE_INFO</strong>)
E(User business logic<br>...)
F(Log out of device<br><strong>NET_SDK_Logout</strong>)
G(Release SDK resources<br><strong>NET_SDK_Cleanup</strong>)
A --> B --> C ---> |Yes| D --> |Command| C0 --> E --> F --> G
C -- No --> F Initialization Interface NET_SDK_Init Called at the beginning of a program, a program only needs to be called once.
User registration means login the device, calling NET_SDK_Login Interface, only one login per device.
Face target management, including creation, modification, deletion, query, search, etc. Related interfaces: NET_SDK_FaceMatchOperate ,Related commands:
After configuring the relevant parameters and linkage mode, the device will automatically detect according to the configured rules, and the SDK can obtain the identification results uploaded by the device through the alarm arming method. The configuration interface may be different for different devices.
Called when exiting the program NET_SDK_Logout Log off the device.
Call NET_SDK_Cleanup Release all resources of the SDK.
Sample Code Whether The Device Supports Face Matching Add Face Delete Face Edit Face Query Target Face
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
using namespace std;
/*
support face and unsupport
*/
BOOL IsSupportTargetFace ()
{
// device info
CString username = "admin" ;
CString password = "123456" ;
CString device_ip = "10.80.1.138" ;
DWORD device_port = 9008 ;
// init sdk
NET_SDK_Init();
// device login
NET_SDK_DEVICEINFO device_info;
memset(& device_info, 0 , sizeof (NET_SDK_DEVICEINFO));
int userid = NET_SDK_Login(device_ip.GetBuffer(), device_port, username.GetBuffer(), password.GetBuffer(), & device_info);
if (userid > 0 )
{
cout << "Login successful: " << userid << endl;
}
else
{
cout << "Login failed: " << userid << endl;
return FALSE;
}
DWORD SUPPORT = 0 ;
DWORD lpBytesReturned = 0 ;
BOOL ret = NET_SDK_FaceMatchOperate(m_userID, NET_SDK_GET_FACE_MATCH_SUPPORT, NULL , 0 , & SUPPORT, sizeof (DWORD), & lpBytesReturned);
if (ret && SUPPORT == 1 )
{
cout << " support vfd " << endl;
NET_SDK_Logout(userid);
NET_SDK_Cleanup();
return TRUE;
}
else
{
cout << " unsupport vfd " << endl;
NET_SDK_Logout(userid);
NET_SDK_Cleanup();
return FALSE;
}
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
using namespace std;
BOOL AddTargetFace ()
{
// device info
CString username = "admin" ;
CString password = "123456" ;
CString device_ip = "10.80.1.138" ;
DWORD device_port = 9008 ;
// init sdk
NET_SDK_Init();
// device login
NET_SDK_DEVICEINFO device_info;
memset(& device_info, 0 , sizeof (NET_SDK_DEVICEINFO));
int userid = NET_SDK_Login(device_ip.GetBuffer(), device_port, username.GetBuffer(), password.GetBuffer(), & device_info);
if (userid > 0 )
{
cout << "Login successful: " << userid << endl;
}
else
{
cout << "Login failed: " << userid << endl;
return FALSE;
}
char * tempBuf = new char [1024 * 1024 ];
memset(tempBuf, 0 , 1024 * 1024 );
NET_SDK_IVE_FACE_MATCH_ADD_ALBUM_INFO * itemToAdd = (NET_SDK_IVE_FACE_MATCH_ADD_ALBUM_INFO * )tempBuf;
itemToAdd-> iType = 0 ; // strangerList
memcpy(itemToAdd-> szName, "test" , sizeof (itemToAdd-> szName));
itemToAdd-> iMale = 0 ; // female
itemToAdd-> iAge = 20 ;
memcpy(itemToAdd-> szIdentifyNum, "123456" , sizeof (itemToAdd-> szIdentifyNum));
memcpy(itemToAdd-> szTel, "123456" , sizeof (itemToAdd-> szTel));
char * imgData = tempBuf + sizeof (NET_SDK_IVE_FACE_MATCH_ADD_ALBUM_INFO);
// Face image is only supported in jpg format.
FILE * fp = fopen("./face.jpg" , "rb" );
path.ReleaseBuffer();
int length = 0 ;
if (fp)
{
fseek(fp, 0 , SEEK_END);
length = ftell(fp);
fseek(fp, 0 , SEEK_SET);
int readLen = fread(imgData, length, 1 , fp);
fclose(fp);
}
itemToAdd-> iPicSize = length;
DWORD lpBytesReturned = 0 ;
unsigned char * rret = new unsigned char [1024 ];
BOOL ret = NET_SDK_FaceMatchOperate(m_userID, NET_SDK_ADD_FACE_IPC, tempBuf, sizeof (NET_SDK_IVE_FACE_MATCH_ADD_ALBUM_INFO) + length, rret, 1024 , & lpBytesReturned);
if (ret)
{
if (lpBytesReturned >= sizeof (NET_SDK_IVE_FACE_MATCH_ADD_FACE_REPLY_T))
{
NET_SDK_IVE_FACE_MATCH_ADD_FACE_REPLY_T * preply = (NET_SDK_IVE_FACE_MATCH_ADD_FACE_REPLY_T * )rret;
cout << "NET_SDK_ADD_FACE_IPC success faceId=" << preply-> iPersonId;
}
}
else
{
cout << " NET_SDK_ADD_FACE_IPC faild!" ;
}
delete [] rret;
delete [] tempBuf;
rret = NULL ;
tempBuf = NULL ;
NET_SDK_Logout(userid);
NET_SDK_Cleanup();
return FALSE;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
using namespace std;
BOOL DelTargetFace ()
{
// device info
CString username = "admin" ;
CString password = "123456" ;
CString device_ip = "10.80.1.138" ;
DWORD device_port = 9008 ;
// init sdk
NET_SDK_Init();
// device login
NET_SDK_DEVICEINFO device_info;
memset(& device_info, 0 , sizeof (NET_SDK_DEVICEINFO));
int userid = NET_SDK_Login(device_ip.GetBuffer(), device_port, username.GetBuffer(), password.GetBuffer(), & device_info);
if (userid > 0 )
{
cout << "Login successful: " << userid << endl;
}
else
{
cout << "Login failed: " << userid << endl;
return FALSE;
}
NET_SDK_IVE_FACE_MATCH_DELE_ALBUM_INFO delInfo = {};
delInfo.bUseKeyFilter = true ;
delInfo.iKey = 1722898532 ;
DWORD lpBytesReturned = 0 ;
BOOL ret = NET_SDK_FaceMatchOperate(m_userID, NET_SDK_DEL_FACE_IPC, & delInfo, sizeof (NET_SDK_IVE_FACE_MATCH_DELE_ALBUM_INFO), NULL , 0 , & lpBytesReturned);
if (! ret)
{
cout << " faild!" ;
}
else
{
cout << "NET_SDK_DEL_FACE_IPC success!" ;
}
NET_SDK_Logout(userid);
NET_SDK_Cleanup();
return FALSE;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
using namespace std;
BOOL EditTargetFace ()
{
// device info
CString username = "admin" ;
CString password = "123456" ;
CString device_ip = "10.80.1.138" ;
DWORD device_port = 9008 ;
// init sdk
NET_SDK_Init();
// device login
NET_SDK_DEVICEINFO device_info;
memset(& device_info, 0 , sizeof (NET_SDK_DEVICEINFO));
int userid = NET_SDK_Login(device_ip.GetBuffer(), device_port, username.GetBuffer(), password.GetBuffer(), & device_info);
if (userid > 0 )
{
cout << "Login successful: " << userid << endl;
}
else
{
cout << "Login failed: " << userid << endl;
return FALSE;
}
char * tempBuf = new char [1024 * 1024 ];
memset(tempBuf, 0 , 1024 * 1024 );
NET_SDK_IVE_FACE_MATCH_MODIFY_ALBUM_INFO_T * modiFyInfo = (NET_SDK_IVE_FACE_MATCH_MODIFY_ALBUM_INFO_T * )tempBuf;
modiFyInfo-> iKey = 1722898532 ;
modiFyInfo-> stBaseInfo.iType = 1 ; // whiteList
modiFyInfo-> stBaseInfo.iAge = 28 ;
memcpy(modiFyInfo-> stBaseInfo.szIdentifyNum, "111111" , sizeof (modiFyInfo-> stBaseInfo.szIdentifyNum));
memcpy(modiFyInfo-> stBaseInfo.szTel, "155456456456" , sizeof (modiFyInfo-> stBaseInfo.szTel));
modiFyInfo-> stBaseInfo.iMale = 1 ; // male
memcpy(modiFyInfo-> stBaseInfo.szName, "test01" , sizeof (modiFyInfo-> stBaseInfo.szName));
DWORD lpBytesReturned = 0 ;
char * imgData = tempBuf + sizeof (NET_SDK_IVE_FACE_MATCH_MODIFY_ALBUM_INFO_T);
// Face image is only supported in jpg format. If you don't modify the face image, you don't need to pass this。
FILE * fp = fopen("./face.jpg" , "rb" );
int length = 0 ;
if (fp)
{
fseek(fp, 0 , SEEK_END);
length = ftell(fp);
fseek(fp, 0 , SEEK_SET);
int readLen = fread(imgData, length, 1 , fp);
fclose(fp);
}
modiFyInfo-> stBaseInfo.iPicSize = length;
NET_SDK_NET_REPLY_RESULT res = {};
BOOL ret = NET_SDK_FaceMatchOperate(m_userID, NET_SDK_EDIT_FACE_IPC, tempBuf, sizeof (NET_SDK_IVE_FACE_MATCH_MODIFY_ALBUM_INFO_T) + length, & res, sizeof (NET_SDK_NET_REPLY_RESULT), & lpBytesReturned);
if (! ret)
{
cout << " NET_SDK_EDIT_FACE_IPC faild!" ;
}
else
{
cout << "NET_SDK_EDIT_FACE_IPC success!" ;
}
delete [] tempBuf;
tempBuf = nullptr ;
NET_SDK_Logout(userid);
NET_SDK_Cleanup();
return FALSE;
}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67 #include <iostream>
#include <string>
#include "stdafx.h"
#include "DVR_NET_SDK.h"
#include <iomanip>
#include <sstream>
#include <ctime>
#include <afx.h>
using namespace std;
BOOL GetTargetFace ()
{
// device info
CString username = "admin" ;
CString password = "123456" ;
CString device_ip = "10.80.1.138" ;
DWORD device_port = 9008 ;
// init sdk
NET_SDK_Init();
// device login
NET_SDK_DEVICEINFO device_info;
memset(& device_info, 0 , sizeof (NET_SDK_DEVICEINFO));
int userid = NET_SDK_Login(device_ip.GetBuffer(), device_port, username.GetBuffer(), password.GetBuffer(), & device_info);
if (userid > 0 )
{
cout << "Login successful: " << userid << endl;
}
else
{
cout << "Login failed: " << userid << endl;
return FALSE;
}
NET_SDK_IVE_FACE_MATCH_QUERY_ALBUM_INFO albumInfo = {};
albumInfo.iPageNum = 0 ;
albumInfo.iPageSize = 10 ;
albumInfo.bUseTypeFilter = true ;
albumInfo.iType = 1 ;
const int BUF_SIZE = 1000 * 1024 ;
unique_ptr< char []> buffer = make_unique< char []> (BUF_SIZE);
DWORD lpBytesReturned = 0 ;
BOOL ret = NET_SDK_FaceMatchOperate(m_userID, NET_SDK_GET_FACE_IPC_LIST, & albumInfo, sizeof (NET_SDK_IVE_FACE_MATCH_QUERY_ALBUM_INFO), buffer.get(), BUF_SIZE, & lpBytesReturned);
if (ret && lpBytesReturned > 0 )
{
char * realOutBuf = buffer.get();
int * totalNum = (int * )realOutBuf;
realOutBuf += sizeof (int );
int * currentNum = (int * )realOutBuf;
realOutBuf += sizeof (int );
for (int i = 0 ; i < * currentNum; i++ )
{
NET_SDK_IVE_FACE_MATCH_QUERY_ALBUM_REPLY_INFO * pReplyAlbum = (NET_SDK_IVE_FACE_MATCH_QUERY_ALBUM_REPLY_INFO * )realOutBuf;
realOutBuf += sizeof (NET_SDK_IVE_FACE_MATCH_QUERY_ALBUM_REPLY_INFO);
realOutBuf += pReplyAlbum-> stBaseInfo.iPicSize;
cout << "albumINfo: key:" << pReplyAlbum.iKey;
}
}
NET_SDK_Logout(userid);
NET_SDK_Cleanup();
return FALSE;
}