def doFaceDetection(hFDEngine, inputImg): #对图像中的人脸进行定位 faceInfo = [] pFaceRes = POINTER(AFD_FSDK_FACERES)() ret = AFD_FSDK_StillImageFaceDetection(hFDEngine, byref(inputImg), byref(pFaceRes)) #ret 为0 if ret != 0: print(u'AFD_FSDK_StillImageFaceDetection 0x{0:x}'.format(ret)) return faceInfo faceRes = pFaceRes.contents print('******') facecont = faceRes.nFace #faceRes 是一个对象所以 输出会是一个地址值 而他的一个属性nface是表示的是人脸的个数 print('%d 个人脸' % facecont) if faceRes.nFace > 0: for i in range(0, faceRes.nFace): rect = faceRes.rcFace[i] orient = faceRes.lfaceOrient[i] faceInfo.append( FaceInfo(rect.left, rect.top, rect.right, rect.bottom, orient)) return faceInfo
def doFaceDetection(hFDEngine, inputImg): faceInfo = [] pFaceRes = POINTER(AFD_FSDK_FACERES)() ret = AFD_FSDK_StillImageFaceDetection(hFDEngine, byref(inputImg), byref(pFaceRes)) if ret != 0: print(u'AFD_FSDK_StillImageFaceDetection 0x{0:x}'.format(ret)) return faceInfo faceRes = pFaceRes.contents if faceRes.nFace > 0: for i in range(0, faceRes.nFace): rect = faceRes.rcFace[i] orient = faceRes.lfaceOrient[i] faceInfo.append(FaceInfo(rect.left,rect.top,rect.right,rect.bottom,orient)) print(faceInfo) return faceInfo