01304 827609 info@use-ip.co.uk Find us

Retrieve Base64 String From Face Detection Device

Amit

New Member
Messages
1
Points
1
I was going through HikVision video session for face detection on youtube and it used the model ivMS-4200. I do have the scenario how I can use the device though I didn't buy it. But I am doing few research like if the device has any option to retrieve any info of face or finger print detection like base64 string, so I can save it in the database and then transfer it to any devices later. Earlier I used ZKTeco device where it provided the dll required for custom C# app. So it has a class CZKEMClass and it's associated method to do required operations like finger print data transfer to any device of the same brand. Something as follows:

C#:
zkemkeeper.CZKEMClass obj = new zkemkeeper.CZKEMClass();   

if (obj.SSR_SetUserInfo(obj.MachineNumber, userLst[l].Id, userLst[l].UserId, "", 0, true))
{                            {
    obj.SetUserTmpExStr(obj.MachineNumber, userLst[l].UserId, 1, 1, userLst[l].Finger_print); //Transfer to device
}

So using the above, I can do the transfer for any user assigned to the database. Even it has another system that extracts user finger print separately with a custom C# app as base64 string and save it to database. Somehow I collected a sdk of HikVision and tried to run the app with provided files. So here is the interface as below:

c2QRX.png


It has required options though I wanted to use the Set option to set the face recognition data to device, assuming it assigns the data directly to HikVision face detection device. So I tried to debug and got the following snippet:

C#:
//Checks the file path - Image obviously
if (textBoxFilePath.Text=="")
{
    MessageBox.Show("Please choose human Face path");
    return;
}

//Checks if PictureBox contains any value
if (pictureBoxFace.Image != null)
{
    pictureBoxFace.Image.Dispose();
    pictureBoxFace.Image = null;
}

//Assuming this is the required class to obtain face data
CHCNetSDK.NET_DVR_FACE_COND struCond = new CHCNetSDK.NET_DVR_FACE_COND();
struCond.init();

struCond.dwSize = Marshal.SizeOf(struCond);
struCond.dwFaceNum = 1;

int.TryParse(textBoxCardReaderNo.Text.ToString(), out struCond.dwEnableReaderNo);
byte[] byTemp = System.Text.Encoding.UTF8.GetBytes(textBoxCardNo.Text);

for (int i = 0; i < byTemp.Length; i++)
{
    struCond.byCardNo[i] = byTemp[i];
}

int dwInBufferSize=struCond.dwSize;
IntPtr ptrstruCond=Marshal.AllocHGlobal(dwInBufferSize);
Marshal.StructureToPtr(struCond,ptrstruCond,false);

//Assuming this is something to configure the device with ip, though it throws exception with error 17 below in the message box
m_lSetFaceCfgHandle = CHCNetSDK.NET_DVR_StartRemoteConfig(m_UserID, CHCNetSDK.NET_DVR_SET_FACE, ptrstruCond, dwInBufferSize, null, IntPtr.Zero);

if(-1==m_lSetFaceCfgHandle)
{
    Marshal.FreeHGlobal(ptrstruCond);
    MessageBox.Show("NET_DVR_SET_FACE_FAIL, ERROR CODE" + CHCNetSDK.NET_DVR_GetLastError().ToString(), "Error", MessageBoxButtons.OK);
    return;
}
//Well! The error code 17 says wrong ip configuration and I am attaching a link to check it out

HikVision Error Code 17 Though I am not sure how the things are set there yet fully and seems like I require to go deeper to understand the code snippet. Unfortunately I don't have proper documentation on it and if anyone has worked on it earlier, can point out a documentation on code samples or anything beneficial to learn about the sdk. Highly appreciated - Thanks.

**Expected**: Way to extract face data in base64 format and save them in database. Finally send to specific device with ip.
 
Back
Top