Exemplo n.º 1
0
def detectHumans():
    """
    Redetect human body on images.
    """
    faceEngine = VLFaceEngine()
    detector = faceEngine.createHumanDetector()

    imageWithOneHuman = VLImage.load(filename=EXAMPLE_O)
    detection = detector.detectOne(imageWithOneHuman, detectLandmarks=False)
    pprint.pprint(detector.redetectOne(image=imageWithOneHuman,
                                       bBox=detection))
    pprint.pprint(
        detector.redetectOne(image=imageWithOneHuman,
                             bBox=detection.boundingBox.rect))

    imageWithSeveralHumans = VLImage.load(filename=EXAMPLE_SEVERAL_FACES)
    severalHumans = detector.detect([imageWithSeveralHumans],
                                    detectLandmarks=False)

    pprint.pprint(
        detector.redetect(images=[
            ImageForRedetection(
                imageWithSeveralHumans,
                [human.boundingBox.rect for human in severalHumans[0]]),
            ImageForRedetection(imageWithOneHuman,
                                [detection.boundingBox.rect]),
            ImageForRedetection(imageWithOneHuman, [Rect(0, 0, 1, 1)]),
        ]))
Exemplo n.º 2
0
def detectHumanBody():
    """
    Detect one human body on an image.
    """
    faceEngine = VLFaceEngine()
    detector = faceEngine.createHumanDetector()

    imageWithOneHuman = VLImage.load(filename=EXAMPLE_O)
    pprint.pprint(
        detector.detectOne(imageWithOneHuman, detectLandmarks=False).asDict())
    imageWithSeveralHumans = VLImage.load(filename=EXAMPLE_SEVERAL_FACES)
    pprint.pprint(
        detector.detectOne(imageWithSeveralHumans,
                           detectLandmarks=False).asDict())

    severalHumans = detector.detect([imageWithSeveralHumans],
                                    detectLandmarks=True)
    pprint.pprint([human.asDict() for human in severalHumans[0]])

    imageWithoutHuman = VLImage.load(filename=EXAMPLE_WITHOUT_FACES)
    pprint.pprint(
        detector.detectOne(imageWithoutHuman, detectLandmarks=False) is None)

    severalHumans = detector.detect(
        [ImageForDetection(imageWithSeveralHumans, Rect(1, 1, 300.0, 300.0))])
    pprint.pprint(severalHumans)
Exemplo n.º 3
0
def createWarp():
    """
    Create human body warp from human detection.

    """
    faceEngine = VLFaceEngine()
    image = VLImage.load(filename=EXAMPLE_O)
    detector = faceEngine.createHumanDetector()
    humanDetection = detector.detectOne(image)
    warper = faceEngine.createHumanWarper()
    warp = warper.warp(humanDetection)
    pprint.pprint(warp.warpedImage.rect)
Exemplo n.º 4
0
async def asyncDetectHumanBody():
    """
    Async detect one human body on an image.
    """
    faceEngine = VLFaceEngine()
    detector = faceEngine.createHumanDetector()

    imageWithOneHuman = VLImage.load(filename=EXAMPLE_O)
    pprint.pprint(detector.detectOne(imageWithOneHuman, detectLandmarks=False).asDict())
    imageWithSeveralHumans = VLImage.load(filename=EXAMPLE_SEVERAL_FACES)
    human = await detector.detectOne(imageWithSeveralHumans, detectLandmarks=False, asyncEstimate=True)
    pprint.pprint(human.asDict())

    task1 = detector.detect([imageWithSeveralHumans], detectLandmarks=True, asyncEstimate=True)
    task2 = detector.detect([imageWithSeveralHumans], detectLandmarks=True, asyncEstimate=True)
    for task in (task1, task2):
        pprint.pprint(task.get())
Exemplo n.º 5
0
def estimateAttributes():
    """
    Estimate human descriptor.
    """
    image = VLImage.load(filename=EXAMPLE_SEVERAL_FACES)
    faceEngine = VLFaceEngine()
    detector = faceEngine.createHumanDetector()
    humanDetection = detector.detect([image])
    warper = faceEngine.createHumanWarper()
    warp1 = warper.warp(humanDetection[0][0])
    warp2 = warper.warp(humanDetection[0][1])

    estimator = faceEngine.createBodyAttributesEstimator()

    pprint.pprint(estimator.estimate(warp1.warpedImage).asDict())
    pprint.pprint(
        estimator.estimateBatch([warp1.warpedImage, warp2.warpedImage]))
    aggregated = estimator.aggregate(
        estimator.estimateBatch([warp1.warpedImage, warp2.warpedImage]))
    pprint.pprint(aggregated)
Exemplo n.º 6
0
async def asyncEstimateDescriptor():
    """
    Async estimate face descriptor.
    """
    image = VLImage.load(filename=EXAMPLE_O)
    faceEngine = VLFaceEngine()
    detector = faceEngine.createHumanDetector()
    humanDetection = detector.detectOne(image)
    warper = faceEngine.createHumanWarper()
    warp = warper.warp(humanDetection)

    extractor = faceEngine.createHumanDescriptorEstimator()

    pprint.pprint(await extractor.estimateDescriptorsBatch(
        [warp.warpedImage, warp.warpedImage], asyncEstimate=True))
    # run tasks and get results
    task1 = extractor.estimate(warp.warpedImage, asyncEstimate=True)
    task2 = extractor.estimate(warp.warpedImage, asyncEstimate=True)
    for task in (task1, task2):
        pprint.pprint(task.get().asDict())
def estimateDescriptor():
    """
    Estimate human descriptor.
    """
    image = VLImage.load(filename=EXAMPLE_O)
    faceEngine = VLFaceEngine()
    detector = faceEngine.createHumanDetector()
    humanDetection = detector.detectOne(image)
    warper = faceEngine.createHumanWarper()
    warp = warper.warp(humanDetection)

    extractor = faceEngine.createHumanDescriptorEstimator()

    pprint.pprint(extractor.estimate(warp.warpedImage))
    pprint.pprint(
        extractor.estimateDescriptorsBatch(
            [warp.warpedImage, warp.warpedImage]))
    batch, aggregateDescriptor = extractor.estimateDescriptorsBatch(
        [warp.warpedImage, warp.warpedImage], aggregate=True)
    pprint.pprint(batch)
    pprint.pprint(aggregateDescriptor)