When you scan the face and the user has a profile image on the user list in the device.
There are also related functions in the document below. Please refer to BS2 UserPhoto.
https://kb.supremainc.com/kbtest/doku.php?id=en:user_management_api#bs2userfaceexblob
BS2UserPhoto
typedef struct { uint32_t size; uint8_t data[BS2_USER_PHOTO_SIZE]; } BS2UserPhoto;
1. size
Size of the user profile image data.
2. data
Data of the profile image, which can be stored up to 16kb.
Sample code
else if (faceExScanSupported)//BS2UserPhoto
{
Console.WriteLine("Do you want to set profile image? [Y/n]");
Console.Write(">>>> ");
if (Util.IsYes())
{
Console.WriteLine("Enter the jpg file path for this user.");
Console.Write(">>>> ");
string imagePath = Console.ReadLine();
if (!File.Exists(imagePath))
{
Console.WriteLine("Invalid file path");
return;
}
Image profileImage = Image.FromFile(imagePath);
if (!profileImage.RawFormat.Equals(System.Drawing.Imaging.ImageFormat.Jpeg))
{
Console.WriteLine("Invalid image file format");
return;
}
IntPtr imageData = IntPtr.Zero;
UInt32 imageDataLen = 0;
if (Util.LoadBinary(imagePath, out imageData, out imageDataLen))
{
if (imageDataLen == 0)
{
Console.WriteLine("Empty image file");
return;
}
else if (imageDataLen > BS2Environment.BS2_USER_PHOTO_SIZE)
{
Console.WriteLine("The profile image should less than {0} bytes.", BS2Environment.BS2_USER_PHOTO_SIZE);
return;
}
userBlob[0].user_photo_obj = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(BS2UserPhoto)));
IntPtr curObj = userBlob[0].user_photo_obj;
Marshal.WriteInt32(curObj, (Int32)imageDataLen);
curObj += 4;
IntPtr curDest = curObj;
IntPtr curSrc = imageData;
for (int idx = 0; idx < Math.Min((int)imageDataLen, BS2Environment.BS2_USER_PHOTO_SIZE); ++idx)
{
Marshal.WriteByte(curDest, Marshal.ReadByte(curSrc));
curDest += 1;
curSrc += 1;
}
curObj += BS2Environment.BS2_USER_PHOTO_SIZE;
Marshal.FreeHGlobal(imageData);
}
}
}