if __name__ == u'__main__': print(u'#####################################################') # init Engine pFDWorkMem = CLibrary.malloc(c_size_t(FD_WORKBUF_SIZE)) pFRWorkMem = CLibrary.malloc(c_size_t(FR_WORKBUF_SIZE)) hFDEngine = c_void_p() ret = AFD_FSDK_InitialFaceEngine(APPID, FD_SDKKEY, pFDWorkMem, c_int32(FD_WORKBUF_SIZE), byref(hFDEngine), AFD_FSDK_OPF_0_HIGHER_EXT, 32, MAX_FACE_NUM) if ret != 0: CLibrary.free(pFDWorkMem) print(u'AFD_FSDK_InitialFaceEngine ret 0x{:x}'.format(ret)) exit(0) # print FDEngine version versionFD = AFD_FSDK_GetVersion(hFDEngine) print(u'{} {} {} {}'.format(versionFD.contents.lCodebase, versionFD.contents.lMajor, versionFD.contents.lMinor, versionFD.contents.lBuild)) print(c_char_p(versionFD.contents.Version).value.decode(u'utf-8')) print(c_char_p(versionFD.contents.BuildDate).value.decode(u'utf-8')) print(c_char_p(versionFD.contents.CopyRight).value.decode(u'utf-8')) hFREngine = c_void_p() ret = AFR_FSDK_InitialEngine(APPID, FR_SDKKEY, pFRWorkMem,
def checkFace(path0, path1): if __name__ == u'__main__': print(u'#####################################################') # init Engine pFDWorkMem = CLibrary.malloc(c_size_t(FD_WORKBUF_SIZE)) pFRWorkMem = CLibrary.malloc(c_size_t(FR_WORKBUF_SIZE)) hFDEngine = c_void_p() ret = AFD_FSDK_InitialFaceEngine(APPID, FD_SDKKEY, pFDWorkMem, c_int32(FD_WORKBUF_SIZE), byref(hFDEngine), AFD_FSDK_OPF_0_HIGHER_EXT, 32, MAX_FACE_NUM) if ret != 0: CLibrary.free(pFDWorkMem) print(u'AFD_FSDK_InitialFaceEngine ret 0x{:x}'.format(ret)) exit(0) # print FDEngine version versionFD = AFD_FSDK_GetVersion(hFDEngine) print(u'{} {} {} {}'.format(versionFD.contents.lCodebase, versionFD.contents.lMajor, versionFD.contents.lMinor, versionFD.contents.lBuild)) print(c_char_p(versionFD.contents.Version).value.decode(u'utf-8')) print(c_char_p(versionFD.contents.BuildDate).value.decode(u'utf-8')) print(c_char_p(versionFD.contents.CopyRight).value.decode(u'utf-8')) hFREngine = c_void_p() ret = AFR_FSDK_InitialEngine(APPID, FR_SDKKEY, pFRWorkMem, c_int32(FR_WORKBUF_SIZE), byref(hFREngine)) if ret != 0: AFD_FSDKLibrary.AFD_FSDK_UninitialFaceEngine(hFDEngine) CLibrary.free(pFDWorkMem) CLibrary.free(pFRWorkMem) print(u'AFR_FSDK_InitialEngine ret 0x{:x}'.format(ret)) exit(0) # print FREngine version versionFR = AFR_FSDK_GetVersion(hFREngine) print(u'{} {} {} {}'.format(versionFR.contents.lCodebase, versionFR.contents.lMajor, versionFR.contents.lMinor, versionFR.contents.lBuild)) print(c_char_p(versionFR.contents.Version).value.decode(u'utf-8')) print(c_char_p(versionFR.contents.BuildDate).value.decode(u'utf-8')) print(c_char_p(versionFR.contents.CopyRight).value.decode(u'utf-8')) # load Image Data if bUseYUVFile: filePathA = u'001_640x480_I420.YUV' yuv_widthA = 640 yuv_heightA = 480 yuv_formatA = ASVL_COLOR_FORMAT.ASVL_PAF_I420 filePathB = u'003_640x480_I420.YUV' yuv_widthB = 640 yuv_heightB = 480 yuv_formatB = ASVL_COLOR_FORMAT.ASVL_PAF_I420 inputImgA = loadYUVImage(filePathA, yuv_widthA, yuv_heightA, yuv_formatA) inputImgB = loadYUVImage(filePathB, yuv_widthB, yuv_heightB, yuv_formatB) else: filePathA = u'facedata/1.jpg' filePathB = u'facedata/2.jpg' inputImgA = loadImage(filePathA) inputImgB = loadImage(filePathB) print(u'similarity between faceA and faceB is {0}'.format( compareFaceSimilarity(hFDEngine, hFREngine, inputImgA, inputImgB))) # release Engine AFD_FSDK_UninitialFaceEngine(hFDEngine) AFR_FSDK_UninitialEngine(hFREngine) CLibrary.free(pFDWorkMem) CLibrary.free(pFRWorkMem) print(u'#####################################################')
return inputImg if __name__ == u'__main__': print(u'#####################################################') # init Engine pFDWorkMem = CLibrary.malloc(c_size_t(FD_WORKBUF_SIZE)) pFRWorkMem = CLibrary.malloc(c_size_t(FR_WORKBUF_SIZE)) hFDEngine = c_void_p() ret = AFD_FSDK_InitialFaceEngine( APPID, FD_SDKKEY, pFDWorkMem, c_int32(FD_WORKBUF_SIZE), byref(hFDEngine), AFD_FSDK_OPF_0_HIGHER_EXT, 16, MAX_FACE_NUM) if ret != 0: CLibrary.free(pFDWorkMem) print(u'AFD_FSDK_InitialFaceEngine ret 0x{:x}'.format(ret)) exit(0) # print FDEngine version versionFD = AFD_FSDK_GetVersion(hFDEngine) hFREngine = c_void_p() ret = AFR_FSDK_InitialEngine(APPID, FR_SDKKEY, pFRWorkMem, c_int32(FR_WORKBUF_SIZE), byref(hFREngine)) if ret != 0: AFD_FSDKLibrary.AFD_FSDK_UninitialFaceEngine(hFDEngine) CLibrary.free(pFDWorkMem) CLibrary.free(pFRWorkMem) print(u'AFR_FSDK_InitialEngine ret 0x{:x}'.format(ret))