示例#1
0
def loadOnlineFaceDatebase(users):
    # 存放特征库
    retzs = {}
    if (len(users) > 0):
        for user in users:
            img = faceUtil.IM()
            img.filePath = user.imgUrl
            print(img.filePath)
            im = faceUtil.loadImage(img)
            res, faces1 = faceUtil.asfDetectFaces(im, 0x201)
            if res == 0:
                print(im.filePath, res, faces1.faceNum, faces1.faceRect)
                res1 = faceUtil.asfFaceFeatureExtract(
                    im, 0x201, faceUtil.getSingleFaceInfo(faces1, 0))
                if res1[0] == 0:
                    print('人脸获取特征成功')
                    retzs[img.filePath] = res1[1]
                else:
                    print(
                        error.BaseException(
                            img.filePath + '人脸获取特征失败:' +
                            configUtil.getValue('error_code', str(res1[0]))))
            else:
                print(
                    error.BaseException(
                        img.filePath + '人脸检测失败:' +
                        configUtil.getValue('error_code', str(res))))
    return retzs
示例#2
0
def loadLocalFaceDatebase(path):
    images = os.listdir(path)
    # 存放特征库
    retzs = {}
    if (len(images) > 0):
        for image in images:
            img = faceUtil.IM()
            img.filePath = os.path.join(path, image)
            print(img.filePath)
            im = faceUtil.loadImage(img)
            res, faces1 = faceUtil.asfDetectFaces(im, 0x201)
            if res == 0:
                print(im.filePath, res, faces1.faceNum, faces1.faceRect)
                res1 = faceUtil.asfFaceFeatureExtract(
                    im, 0x201, faceUtil.getSingleFaceInfo(faces1, 0))
                if res1[0] == 0:
                    print('人脸获取特征成功')
                    retzs[img.filePath] = res1[1]
                else:
                    print(
                        error.BaseException(
                            img.filePath + '人脸获取特征失败:' +
                            configUtil.getValue('error_code', str(res1[0]))))
            else:
                print(
                    error.BaseException(
                        img.filePath + '人脸检测失败:' +
                        configUtil.getValue('error_code', str(res))))
    return retzs
示例#3
0
def getFacesRET(frame):
    retz = {}
    img = faceUtil.IM()
    img.filePath = ""
    img.data = frame
    im = faceUtil.loadImage(img)
    res, faces1 = faceUtil.asfDetectFaces(im, 0x201)
    if res == 0:
        print(im.filePath, res, faces1.faceNum, faces1.faceRect)
        for i in range(faces1.faceNum):
            res1 = faceUtil.asfFaceFeatureExtract(
                im, 0x201, faceUtil.getSingleFaceInfo(faces1, i))
            if res1[0] == 0:
                print('人脸获取特征成功')
                retz[i] = (faces1.faceRect[i], res1[1])
            else:
                print(
                    error.BaseException(
                        img.filePath + '人脸获取特征失败:' +
                        configUtil.getValue('error_code', str(res1[0]))))
    else:
        print(
            error.BaseException(img.filePath + '人脸检测失败:' +
                                configUtil.getValue('error_code', str(res))))
    return retz
示例#4
0
def getFacesProperty(path):
    retz = {}
    img = faceUtil.IM()
    img.filePath = path
    im = faceUtil.loadImage(img)
    res, faces1 = faceUtil.asfDetectFaces(im, 0x201)
    if res == 0:
        print(im.filePath, res, faces1.faceNum, faces1.faceRect)
        res1 = faceUtil.asfProcess(im, 0x201, faces1, 56)
        if res1 == 0:
            for i in range(faces1.faceNum):
                print(faceUtil.asfGetAge()[1].ageArray[i])
                print(faceUtil.asfGetGender()[1].genderArray[i])
                print(faceUtil.asfGetFace3DAngle()[1].roll[i])
        else:
            print(
                error.BaseException(
                    img.filePath + '人脸屬性检测失败:' +
                    configUtil.getValue('error_code', str(res1))))
    else:
        print(
            error.BaseException(img.filePath + '人脸检测失败:' +
                                configUtil.getValue('error_code', str(res))))
示例#5
0
#!/usr/bin/env python
#! -*- coding:utf-8 -*-
#!@Author: faple
#!@Time: 2019/4/1 10:59
from arcsoft_all.lib import face_dll, face_detect_sdk, face_property_sdk
from arcsoft_all.util import faceUtil

APP_ID = b'4fEUb81MxFozpgncw2k8a7ZAEArfvNGZjvvo8jZDLgkn'
SDK_KEY = b'7ewepBAnhYgQdsGyJ9aqDchQ9aZGy8U8sYdHMHehx9ps'

# Appkey = b'4fEUb81MxFozpgncw2k8a7ZAEArfvNGZjvvo8jZDLgkn'
# SDKey = b'7ewepBAnhYgQdsGyJ9aqDchQ9aZGy8U8sYdHMHehx9ps'

img1 = faceUtil.IM()
img2 = faceUtil.IM()

# img1.filePath = 'E:/PycharmProjects/face_recognition_test/arcsoft_all/3.jpg'
# img2.filePath = 'E:/PycharmProjects/face_recognition_test/arcsoft_all/6.jpg'

# 激活设备
res = faceUtil.asfActivation(APP_ID, SDK_KEY)
if res == 0 or res == 90114:
    print("激活成功!", res)
else:
    print("激活失败!", res)

# 0xFFFFFFFF, 0x1, 16, 50, 5, byref(Handle))
res, faceEngine = faceUtil.asfInitEngine(0xFFFFFFFF, 0x5, 16, 50, 61)
if res == 0:
    print("初始化成功!", res)
else: