차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
ko:bs2_scanface [2022/05/25 17:05] mark [반환값] |
ko:bs2_scanface [2024/05/28 19:44] (현재) kkshin |
||
|---|---|---|---|
| 줄 5: | 줄 5: | ||
| ===== BS2_ScanFace===== | ===== BS2_ScanFace===== | ||
| - | ''FaceStation2'' 장치에서 얼굴을 스캔하고 템플릿 데이터와 이미지 데이터를 추출합니다. | + | ''IR Face 기반'' 장치에서 얼굴을 스캔하고 템플릿 데이터와 이미지 데이터를 추출합니다. |
| ==== 함수 ==== | ==== 함수 ==== | ||
| <code cpp> | <code cpp> | ||
| 줄 39: | 줄 39: | ||
| for (uint32_t index = 0; index < numFace;) | for (uint32_t index = 0; index < numFace;) | ||
| { | { | ||
| - | sdkResult = BS2_ScanFace(context_, id, &ptrFace[index], BS2_FACE_ENROLL_THRESHOLD_DEFAULT, onReadyToScanFace); | + | sdkResult = BS2_ScanFace(context_, id, &ptrFace[index], BS2_FACE_ENROLL_THRESHOLD_DEFAULT, |
| + | onReadyToScanFace); | ||
| if (BS_SDK_SUCCESS != sdkResult) | if (BS_SDK_SUCCESS != sdkResult) | ||
| TRACE("BS2_ScanFace call failed: %d", sdkResult); | TRACE("BS2_ScanFace call failed: %d", sdkResult); | ||
| 줄 55: | 줄 56: | ||
| C# | C# | ||
| <code cpp> | <code cpp> | ||
| - | private API.OnReadyToScan cbFaceOnReadyToScan = null; | ||
| if (faceScanSupported) | if (faceScanSupported) | ||
| { | { | ||
| - | int numOfFace = 1; | + | Console.WriteLine("Do you want to scan face? [y/n]"); |
| - | if (0 < numOfFace) | + | Console.Write(">> "); |
| + | if (Util.IsYes()) | ||
| { | { | ||
| - | int structSize = Marshal.SizeOf(typeof(BS2FaceExWarped)); | + | Console.WriteLine("How many face would you like to register?"); |
| - | BS2FaceExWarped[] faceEx = Util.AllocateStructureArray<BS2FaceExWarped>(1); | + | Console.Write(">> "); |
| - | userBlob[0].faceExObjs = Marshal.AllocHGlobal(structSize * numOfFace); | + | int numOfFace = Util.GetInput(1); |
| - | IntPtr curFaceExObjs = userBlob[0].faceExObjs; | + | if (0 < numOfFace) |
| - | cbFaceOnReadyToScan = new API.OnReadyToScan(ReadyToScanForFace); | + | |
| - | + | ||
| - | for (int index = 0; index < numOfFace;) | + | |
| { | { | ||
| - | sdkResult = (BS2ErrorCode)API.BS2_ScanFaceEx(context, deviceId, faceEx, (byte)BS2FaceEnrollThreshold.THRESHOLD_DEFAULT, cbFaceOnReadyToScan); | + | int structSize = Marshal.SizeOf(typeof(BS2Face)); |
| - | if (BS2ErrorCode.BS_SDK_SUCCESS != sdkResult) | + | BS2Face[] face = Util.AllocateStructureArray<BS2Face>(1); |
| - | Console.WriteLine("BS2_ScanFaceEx call failed: %d", sdkResult); | + | userBlob[0].faceObjs = Marshal.AllocHGlobal(structSize * numOfFace); |
| - | else | + | IntPtr curFaceObjs = userBlob[0].faceObjs; |
| - | { | + | cbFaceOnReadyToScan = new API.OnReadyToScan(ReadyToScanForFace); |
| - | userBlob[0].user.numFaces++; | + | |
| - | index++; | + | |
| - | faceEx[0].faceIndex = (byte)index; | + | |
| - | Marshal.StructureToPtr(faceEx[0], curFaceExObjs, false); | + | |
| - | curFaceExObjs += structSize; | + | |
| - | Thread.Sleep(100); | + | for (int index = 0; index < numOfFace;) |
| - | } | + | { |
| - | } | + | sdkResult = (BS2ErrorCode)API.BS2_ScanFace(sdkContext, deviceID, face, (byte)BS2FaceEnrollThreshold.THRESHOLD_DEFAULT, cbFaceOnReadyToScan); |
| + | if (BS2ErrorCode.BS_SDK_SUCCESS != sdkResult) | ||
| + | Console.WriteLine("BS2_ScanFace call failed: %d", sdkResult); | ||
| + | else | ||
| + | { | ||
| + | userBlob[0].user.numFaces++; | ||
| + | index++; | ||
| + | face[0].faceIndex = (byte)index; | ||
| + | Marshal.StructureToPtr(face[0], curFaceObjs, false); | ||
| + | curFaceObjs += structSize; | ||
| - | cbFaceOnReadyToScan = null; | + | Thread.Sleep(100); |
| - | } | + | } |
| + | } | ||
| + | |||
| + | cbFaceOnReadyToScan = null; | ||
| + | } | ||
| + | } | ||
| } | } | ||
| - | BS2_ReleaseObject(uidObj); | ||
| </code> | </code> | ||