Reason for this document:


 When calling the ScanFaceEx function, some user wants to save or view the WARPED image directly (to verify that FACE has been saved after ScanFace)




How to use & sample code :


The image is stored in that path in {0}-{1}.jpg format.

if (Util.IsYes())
            {
              Console.WriteLine("How many faceEx would you like to register?");
                Console.Write(">> ");
              int numOfFace = Util.GetInput(1);
              if (0 < numOfFace)
              {
                        int structSize = Marshal.SizeOf(typeof(BS2FaceExWarped));
                        BS2FaceExWarped[] faceEx = Util.AllocateStructureArray<BS2FaceExWarped>(1);
                userBlob[0].faceExObjs = Marshal.AllocHGlobal(structSize * numOfFace);
                        IntPtr curFaceExObjs = userBlob[0].faceExObjs;
                        cbFaceOnReadyToScan = new API.OnReadyToScan(ReadyToScanForFace);

                for (int index = 0; index < numOfFace;)
                {
                  sdkResult = (BS2ErrorCode)API.BS2_ScanFaceEx(sdkContext, deviceID, faceEx, (byte)BS2FaceEnrollThreshold.THRESHOLD_DEFAULT, cbFaceOnReadyToScan);
                  if (BS2ErrorCode.BS_SDK_SUCCESS != sdkResult)
                    Console.WriteLine("BS2_ScanFaceEx call failed: %d", sdkResult);
                  else
                  {
                                Console.WriteLine("Do you want to save warpped image? [y/n]");
                                Console.Write(">> ");
                                if (Util.IsYes())
                                {
                                    int written = 0;
                                    int size = (int)faceEx[0].imageLen;
                                    IntPtr imgPtr = Marshal.AllocHGlobal(size);
                                    Marshal.Copy(faceEx[index].imageData, 0, imgPtr, size);
                                    FileStream file = new FileStream(String.Format("{0}-{1}.jpg", userID, index), FileMode.Create, FileAccess.Write);
                                    WriteFile(file.Handle, imgPtr, (int)faceEx[index].imageLen, out written, IntPtr.Zero);
                                    file.Close();
                                }
                                userBlob[0].user.numFaces++;
                    index++;
                                faceEx[0].faceIndex = (byte)index;
                                Marshal.StructureToPtr(faceEx[0], curFaceExObjs, false);
                                curFaceExObjs += structSize;

                                Thread.Sleep(100);
                  }
                }

                        cbFaceOnReadyToScan = null;
              }
            }



Result:

 

Please download the attached file and refer to this sample code.