人脸特征提取

人脸特征提取

一、安装dlib及OPENCV

1. dlib安装

Dlib是一个包含机器学习算法的C++开源工具包。 Dlib可以帮助您创建很多复杂的机器学习方面的软件来帮助解决实际问题。 目前Dlib已经被广泛的用在行业和学术领域,包括机器人,嵌入式设备,移动电话和大型高性能计算环境。
本电脑使用的python版本为3.8,因此直接使用cmd安装:

pip install dlib-19.19.0-cp38-cp38-win_amd64.whl


安装成功:在这里插入图片描述

2. 安装opencv

OpenCV-Python是一个Python绑定库,旨在解决计算机视觉问题.
同样使用pip命令安装:

pip3 install opencv_python

在这里插入图片描述

二、绘制人脸的68个特征点

代码:# -- coding: utf-8 --
“”"
Created on Wed Oct 27 03:15:10 2021

@author: GT72VR
“”"
import numpy as np
import cv2
import dlib
import os
import sys
import random

存储位置

output_dir = ‘E:\QQdownload\Tencent Files’
size = 64

if not os.path.exists(output_dir):
os.makedirs(output_dir)

改变图片的亮度与对比度

def relight(img, light=1, bias=0):
    w = img.shape[1]
    h = img.shape[0]
    # image = []
    for i in range(0, w):
        for j in range(0, h):
            for c in range(3):
                tmp = int(img[j, i, c] * light + bias)
                if tmp > 255:
                    tmp = 255
                elif tmp < 0:
                    tmp = 0
                img[j, i, c] = tmp
    return img


# 使用dlib自带的frontal_face_detector作为我们的特征提取器

```c
detector = dlib.get_frontal_face_detector(
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值