示例#1
0
    def setUpClass(cls):
        # set up self.client for tests
        cls.client = Face(os.environ['OXFORD_FACE_API_KEY'])

        # detect two faces
        cls.knownFaceIds = [];
        cls.localFilePrefix = os.path.join(rootDirectory, 'tests', 'images')
        face1 = cls.client.detect({'path': os.path.join(cls.localFilePrefix, 'face1.jpg')})
        face2 = cls.client.detect({'path': os.path.join(cls.localFilePrefix, 'face2.jpg')})
        cls.knownFaceIds.append(face1[0]['faceId'])
        cls.knownFaceIds.append(face2[0]['faceId'])
示例#2
0
    def setUpClass(cls):
        # set up client for tests
        cls.client = Face(os.environ['OXFORD_FACE_API_KEY'])

        # detect two faces
        cls.knownFaceIds = []
        localFilePrefix = os.path.join(rootDirectory, 'tests', 'images')
        face1 = cls.client.detect(
            {'path': os.path.join(localFilePrefix, 'face1.jpg')})
        face2 = cls.client.detect(
            {'path': os.path.join(localFilePrefix, 'face2.jpg')})
        cls.knownFaceIds.append(face1[0]['faceId'])
        cls.knownFaceIds.append(face2[0]['faceId'])

        # create a person group
        cls.personGroupId = str(uuid.uuid4())
        cls.client.personGroup.create(cls.personGroupId, 'test-person-group')
示例#3
0
    def setUpClass(cls):
        # set up self.client for tests
        cls.client = Face(os.environ['OXFORD_FACE_API_KEY'])

        # detect two faces
        cls.knownFaceIds = []
        cls.localFilePrefix = os.path.join(rootDirectory, 'tests', 'images')
        face1 = cls.client.detect(
            {'path': os.path.join(cls.localFilePrefix, 'face1.jpg')})
        face2 = cls.client.detect(
            {'path': os.path.join(cls.localFilePrefix, 'face2.jpg')})
        cls.knownFaceIds.append(face1[0]['faceId'])
        cls.knownFaceIds.append(face2[0]['faceId'])

        # set common detect options
        cls.detectOptions = {
            'returnFaceLandmarks': True,
            'returnFaceAttributes': 'age,gender,headPose,smile,facialHair'
        }
示例#4
0
import cv2

from oxford.face import Face

parser = argparse.ArgumentParser()
parser.add_argument('--image', required=True, help='Image to interact with.')
parser.add_argument('--apikey', help='Face API license key')
parser.add_argument('--facelistid', help='Face List Id to search against')

args = parser.parse_args()

window_name = 'Oxford Demo'
img = None
faces = []

client = Face(args.apikey)

if args.facelistid is None:
    face_lists = client.faceList.list()
    face_list_id = face_lists[0]['faceListId']
else:
    face_list_id = args.facelistid
print "Face List: %s" % face_list_id

face_list = client.faceList.get(face_list_id)
print "Number of Faces: %d" % len(face_list['persistedFaces'])

def find_face(x,y):
    sx = x / width_scale
    sy = y / height_scale
    print "X: %d Y: %d -> SX: %d SY: %d" % (x, y, sx, sy)
示例#5
0
from oxford.facelist import FaceList

parser = argparse.ArgumentParser()
parser.add_argument('--source',
                    required=True,
                    help='Directory of images or a single image to load.')
parser.add_argument('--apikey', required=True, help='Face API license key')
parser.add_argument('--facelist',
                    help='Basename for facelist.',
                    default='facelist')
parser.add_argument('--dryrun', action='store_true')

args = parser.parse_args()

facelist = FaceList(args.apikey)
face = Face(args.apikey)

facelist_count = 0
facelist_id = "%s-%d" % (args.facelist, facelist_count)
facelist_name = "Face List %d" % facelist_count
facelist_count += 1

try:
    logger.info("Making facelist.")
    facelist.create(facelist_id, facelist_name)
    logger.info("Finished making facelist.")
except Exception as e:
    logger.error("Problem creating facelist: %s" % e)

face_result = []
if os.path.exists(args.source):