차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 | 마지막 판 양쪽 다음 판 | ||
ko:bs2_scanface [2020/10/22 09:42] kkshin |
ko:bs2_scanface [2022/05/25 17:05] mark [반환값] |
||
---|---|---|---|
줄 25: | 줄 25: | ||
성공적으로 수행될 경우 ''BS_SDK_SUCCESS''를 반환하고, 에러가 발생할 경우 상응하는 에러 코드를 반환합니다. | 성공적으로 수행될 경우 ''BS_SDK_SUCCESS''를 반환하고, 에러가 발생할 경우 상응하는 에러 코드를 반환합니다. | ||
\\ | \\ | ||
+ | ==== 샘플코드 ==== | ||
+ | C++ | ||
+ | <code cpp> | ||
+ | if (faceScanSupported) | ||
+ | { | ||
+ | if (Utility::isYes("Do you want to scan face?")) | ||
+ | { | ||
+ | uint32_t numFace = Utility::getInput<uint32_t>("How many face would you like to register?"); | ||
+ | BS2Face* ptrFace = new BS2Face[numFace]; | ||
+ | if (ptrFace) | ||
+ | { | ||
+ | userBlob.faceObjs = ptrFace; | ||
+ | for (uint32_t index = 0; index < numFace;) | ||
+ | { | ||
+ | sdkResult = BS2_ScanFace(context_, id, &ptrFace[index], BS2_FACE_ENROLL_THRESHOLD_DEFAULT, onReadyToScanFace); | ||
+ | if (BS_SDK_SUCCESS != sdkResult) | ||
+ | TRACE("BS2_ScanFace call failed: %d", sdkResult); | ||
+ | else | ||
+ | { | ||
+ | user.numFaces++; | ||
+ | index++; | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | } | ||
+ | BS2_ReleaseObject(uidObj); | ||
+ | </code> | ||
+ | C# | ||
+ | <code cpp> | ||
+ | private API.OnReadyToScan cbFaceOnReadyToScan = null; | ||
+ | if (faceScanSupported) | ||
+ | { | ||
+ | int numOfFace = 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(context, deviceId, faceEx, (byte)BS2FaceEnrollThreshold.THRESHOLD_DEFAULT, cbFaceOnReadyToScan); | ||
+ | if (BS2ErrorCode.BS_SDK_SUCCESS != sdkResult) | ||
+ | Console.WriteLine("BS2_ScanFaceEx call failed: %d", sdkResult); | ||
+ | else | ||
+ | { | ||
+ | userBlob[0].user.numFaces++; | ||
+ | index++; | ||
+ | faceEx[0].faceIndex = (byte)index; | ||
+ | Marshal.StructureToPtr(faceEx[0], curFaceExObjs, false); | ||
+ | curFaceExObjs += structSize; | ||
+ | |||
+ | Thread.Sleep(100); | ||
+ | } | ||
+ | } | ||
+ | |||
+ | cbFaceOnReadyToScan = null; | ||
+ | } | ||
+ | } | ||
+ | BS2_ReleaseObject(uidObj); | ||
+ | </code> |