dlib win32

 

 

python3.5 32位下载,可以安装

https://pypi.org/project/dlib/18.17.100/#files

2020.09.29不支持python3.7:

3.7需要自己编译安装

https://blog.csdn.net/qq_35723619/article/details/83042202

不知道为什么python3.7版本安装dlib不能直接用pip,真的超级麻烦。然后看了其他一些博客感觉挺复杂的,boost居然也要设置环境变量,而且问题很多。

我大概花了一天的时间才总算弄好,而且也不是很复杂。

1.先去下载dlib的安装包,网址在这https://pypi.org/project/dlib/#files,然后解压安装包。

2.下载vs,我的vs版本是vs2017,如果没有先装上vs的要先装上喔https://blog.csdn.net/qq_36556893/article/details/79430133。然后设置cl.exe的环境变量(写入Path中,不知道环境变量在哪的去百度就知道了)。https://blog.csdn.net/zhang475546259/article/details/84104368
这里有写到如何设置将vs的cl.exe的环境变量。

3.用win+R打开命令提示符,输入pip install cmake,然后将cmake文件夹中的bin文件的路径写入到环境变量中,同样可参考https://blog.csdn.net/zhang475546259/article/details/84104368。

4.下载boost,用pip install boost。不用设置环境变量。

5.打开dlib解压后的文件,在文件搜索栏中搜索CMakeCache.txt,应该在Release文件夹下面会找到,找到之后,删除掉这个CMakeCache.txt文件(以使缓存失效,否则还是会链接python2.7。)

6.用cd 进入到dlib的路径,然后输入python setup.py install.等待差不多五分钟的安装时间,然后就可以了。

 

 

https://www.jb51.net/softs/543679.html#downintro2

人脸检测

import sys
import os
import dlib
# import glob
import numpy as np
import cv2
import time


cap = cv2.VideoCapture(0)
# fourcc = cv2.VideoWriter_fourcc(*'XVID')

# out = cv2.VideoWriter('output.avi',fourcc, 20.0, (1280, 720))

# predictor_path = 'shape_predictor_81_face_landmarks.dat'
predictor_path = 'shape_predictor_68_face_landmarks.dat'

detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predictor_path)

while(cap.isOpened()):
    ret, frame = cap.read()
    frame=cv2.resize(frame,(400,300))
    # img_gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)
    start = time.time()
    frame = cv2.flip(frame, 1)
    dets = detector(frame, 0)
    for k, point in enumerate(dets):

        shape = predictor(frame, point)
        landmarks = np.matrix([[p.x, p.y] for p in shape.parts()])
        for num in range(shape.num_parts):
            cv2.circle(frame, (shape.parts()[num].x, shape.parts()[num].y), 1, (0,255,0), -1)
    print("time ->", time.time()-start)
    cv2.imshow('frame', frame)
    # out.write(frame)
    if cv2.waitKey(1) & 0xFF == ord('q'):
        print("q pressed")
        break


cap.release()
# out.release()

cv2.destroyAllWindows()



 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

AI算法网奇

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值