차이
문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 | |||
ko:bs2_enrollusersmallex [2021/12/29 11:30] mark [반환값] |
ko:bs2_enrollusersmallex [2021/12/29 15:09] (현재) mark [샘플코드] |
||
---|---|---|---|
줄 34: | 줄 34: | ||
C# | C# | ||
<code cpp> | <code cpp> | ||
- | List<BS2User> userList = new List<BS2User>(); | + | if (dbHandler.GetUserBlobEx(ref deviceInfo, ref user, ref userBlob[0])) |
- | if (dbHandler.GetUserList(ref deviceInfo, ref userList)) | + | { |
- | { | + | Console.WriteLine("Trying to enroll user."); |
- | if (userList.Count > 0) | + | BS2ErrorCode result = (BS2ErrorCode)API.BS2_EnrollUserSmallEx(sdkContext, deviceID, userBlob, 1, 1); |
- | { | + | if (result != BS2ErrorCode.BS_SDK_SUCCESS) |
- | Console.WriteLine("+----------------------------------------------------------------------------------------------------------+"); | + | { |
- | for (int idx = 0; idx < userList.Count; ++idx) | + | Console.WriteLine("Got error({0}).", result); |
- | { | + | } |
- | Console.Write("[{0:000}] ==> ", idx); | + | |
- | print(userList[idx]); | + | |
- | } | + | |
- | Console.WriteLine("+----------------------------------------------------------------------------------------------------------+"); | + | |
- | Console.WriteLine("Please, choose the index of the user which you want to enroll."); | + | |
- | Console.Write(">>>> "); | + | |
- | Int32 selection = Util.GetInput(); | + | if (userBlob[0].cardObjs != IntPtr.Zero) |
- | if (selection >= 0) | + | { |
- | { | + | Marshal.FreeHGlobal(userBlob[0].cardObjs); |
- | if (selection < userList.Count) | + | } |
- | { | + | if (userBlob[0].fingerObjs != IntPtr.Zero) |
- | BS2User user = userList[selection]; | + | { |
- | BS2UserSmallBlobEx[] userBlob = Util.AllocateStructureArray<BS2UserSmallBlobEx>(1); | + | Marshal.FreeHGlobal(userBlob[0].fingerObjs); |
- | if (dbHandler.GetUserBlobEx(ref deviceInfo, ref user, ref userBlob[0])) | + | } |
- | { | + | if (userBlob[0].faceObjs != IntPtr.Zero) |
- | Console.WriteLine("Trying to enroll user."); | + | { |
- | //BS2ErrorCode result = (BS2ErrorCode)API.BS2_EnrolUserEx(sdkContext, deviceID, userBlob, 1, 1); | + | Marshal.FreeHGlobal(userBlob[0].faceObjs); |
- | BS2ErrorCode result = (BS2ErrorCode)API.BS2_EnrollUserSmallEx(sdkContext, deviceID, userBlob, 1, 1); | + | } |
- | if (result != BS2ErrorCode.BS_SDK_SUCCESS) | + | if (userBlob[0].user_photo_obj != IntPtr.Zero) |
- | { | + | { |
- | Console.WriteLine("Got error({0}).", result); | + | Marshal.FreeHGlobal(userBlob[0].user_photo_obj); |
- | } | + | } |
- | + | } | |
- | if (userBlob[0].cardObjs != IntPtr.Zero) | + | |
- | { | + | |
- | Marshal.FreeHGlobal(userBlob[0].cardObjs); | + | |
- | } | + | |
- | + | ||
- | if (userBlob[0].fingerObjs != IntPtr.Zero) | + | |
- | { | + | |
- | Marshal.FreeHGlobal(userBlob[0].fingerObjs); | + | |
- | } | + | |
- | + | ||
- | if (userBlob[0].faceObjs != IntPtr.Zero) | + | |
- | { | + | |
- | Marshal.FreeHGlobal(userBlob[0].faceObjs); | + | |
- | } | + | |
- | + | ||
- | if (userBlob[0].user_photo_obj != IntPtr.Zero) | + | |
- | { | + | |
- | Marshal.FreeHGlobal(userBlob[0].user_photo_obj); | + | |
- | } | + | |
- | } | + | |
- | } | + | |
- | else | + | |
- | { | + | |
- | Console.WriteLine("Invalid selection[{0}]", selection); | + | |
- | } | + | |
- | } | + | |
- | else | + | |
- | { | + | |
- | Console.WriteLine("Invalid user index"); | + | |
- | } | + | |
- | } | + | |
- | else | + | |
- | { | + | |
- | Console.WriteLine("There is no user."); | + | |
- | } | + | |
- | } | + | |
- | else | + | |
- | { | + | |
- | Console.WriteLine("An error occurred while attempting to retrieve user list."); | + | |
- | } | + | |
</code> | </code> | ||