python pip安装第三方库老是报错_#python pip 安装dlib一直失败?#python安装dlib错误...
#python pip 安装dlib一直失败?#python安装dlib错误
python dlib 教程2020-10-11 07:52:36人已围观
ubuntu里面怎么安装dlib
下面是在ubuntu下如何Python安装dlib:
1.网dlib官网最新版本的dlib
由于dlib最初是一个C 库,要安装为python第三方库,
2.要下载boost将C 编译为python,还要下载cmake
命令:sudo apt-get install libboost-python-dev cmake11
3.然后切换到 dlib-18.17/python_examples目录
然后运行
./compile_dlib_python_module.bat 11
会生成dlib.so
4.该脚本还要加上可执行权限
这样在dlib-18.17/python_examples目录下就可以导入dlib库,但在其它地方 还不能导入
将dlib.so复制到python第三库的文件夹下
sudo cp dlib.so /usr/local/lib/python2.7/dist-packages/11
这样dlib库就安装好了
谁用过python中的第三方库face recognition
简介
该以通过python或者命令行即可实现识别的。使用dlib深度学习人脸识别技术,在户外脸部检测数据库基准(Labeled Faces in the Wild)上的准确率为99.38%。
在github上有相关的链接和API文档。
在下方为提供的一些相关源码或是文档。当前库的版本是v0.2.0,点击docs可以查看API文档,我们可以查看一些函数相关的说明等。
安装配置
安装配置很简单,按照github上的说明一步一步来就可以了。
根据你的python版本输入指令:
pip install face_recognition11
或者
pip3 install face_recognition11
正常来说,安装过程中会出错,会在安装dlib时出错,可能报错也可能会卡在那不动。因为pip在编译dlib时会出错,所以我们需要手动编译dlib再进行安装。
按照它给出的解决办法:
1、先下载下来dlib的源码。
git clone
2、编译dlib。
cd dlib
mkdir build
cd build
cmake .. -DDLIB_USE_CUDA=0 -DUSE_AVX_INSTRUCTIONS=1
cmake --build1234512345
3、编译并安装python的拓展包。
cd ..
python3 setup.py install --yes USE_AVX_INSTRUCTIONS --no DLIB_USE_CUDA1212
注意:这个安装步骤是默认认为没有GPU的,所以不支持cuda。
在自己手动编译了dlib后,我们可以在python中import dlib了。
之后再重新安装,就可以配置成功了。
根据你的python版本输入指令:
pip install face_recognition11
或者
pip3 install face_recognition11
安装成功之后,我们可以在python中正常import face_recognition了。
编写人脸识别程序
编写py文件:
# -*- coding: utf-8 -*-
#
# 检测人脸
import face_recognition
import cv2
# 读取图片并识别人脸
img = face_recognition.load_image_file("silicon_valley.jpg")
face_locations = face_recognition.face_locations(img)
print face_locations
# 调用opencv函数显示图片
img = cv2.imread("silicon_valley.jpg")
cv2.namedWindow("原图")
cv2.imshow("原图", img)
# 遍历每个人脸,并标注
faceNum = len(face_locations)
for i in range(0, faceNum):
top = face_locations[i][0]
right = face_locations[i][1]
bottom = face_locations[i][2]
left = face_locations[i][3]
start = (left, top)
end = (right, bottom)
color = (55,255,155)
thickness = 3
cv2.rectangle(img, start, end, color, thickness)
# 显示识别结果
cv2.namedWindow("识别")
cv2.imshow("识别", img)
cv2.waitKey(0)
cv2.destroyAllWindows()12345678910111213141516171819202122232425262728293031323334353637381234567891011121314151617181920212223242526272829303132333435363738
注意:这里使用了python-OpenCV,一定要配置好了opencv才能运行成功。
运行结果:
程序会读取当前目录下指定的图片,然后识别其中的人脸,并标注每个人脸。
(使用图片来自美剧硅谷)
编写人脸比对程序
首先,我在目录下放了几张图片:
这里用到的是一张乔布斯的照片和一张奥巴马的照片,和一张未知的照片。
编写程序:
# 识别图片中的人脸
import face_recognition
jobs_image = face_recognition.load_image_file("jobs.jpg");
obama_image = face_recognition.load_image_file("obama.jpg");
unknown_image = face_recognition.load_image_file("unknown.jpg");
jobs_encoding = face_recognition.face_encodings(jobs_image)[0]
obama_encoding = face_recognition.face_encodings(obama_image)[0]
unknown_encoding = face_recognition.face_encodings(unknown_image)[0]
results = face_recognition.compare_faces([jobs_encoding, obama_encoding], unknown_encoding )
labels = ['jobs', 'obama']
print('results:' str(results))
for i in range(0, len(results)):
if results[i] == True:
print('The person is:' labels[i])123456789101112131415161718123456789101112131415161718
运行结果:
识别出未知的那张照片是乔布斯的。
摄像头实时识别
代码:
# -*- coding: utf-8 -*-
import face_recognition
import cv2
video_capture = cv2.VideoCapture(1)
obama_img = face_recognition.load_image_file("obama.jpg")
obama_face_encoding = face_recognition.face_encodings(obama_img)[0]
face_locations = []
face_encodings = []
face_names = []
process_this_frame = True
while True:
ret, frame = video_capture.read()
small_frame = cv2.resize(frame, (0, 0), fx=0.25, fy=0.25)
if process_this_frame:
face_locations = face_recognition.face_locations(small_frame)
face_encodings = face_recognition.face_encodings(small_frame, face_locations)
face_names = []
for face_encoding in face_encodings:
match = face_recognition.compare_faces([obama_face_encoding], face_encoding)
if match[0]:
name = "Barack"
else:
name = "unknown"
face_names.append(name)
process_this_frame = not process_this_frame
for (top, right, bottom, left), name in zip(face_locations, face_names):
top *= 4
right *= 4
bottom *= 4
left *= 4
cv2.rectangle(frame, (left, top), (right, bottom), (0, 0, 255), 2)
cv2.rectangle(frame, (left, bottom - 35), (right, bottom), (0, 0, 255), 2)
font = cv2.FONT_HERSHEY_DUPLEX
cv2.putText(frame, name, (left 6, bottom-6), font, 1.0, (255, 255, 255), 1)
cv2.imshow('Video', frame)
if cv2.waitKey(1)
版权声明:本站所有文章皆为原创,欢迎转载或转发,请保留网站地址和作者信息。
python pip安装第三方库老是报错_#python pip 安装dlib一直失败?#python安装dlib错误...相关推荐
- python pip安装第三方库老是报错_Python使用pip安装第三方库时报错的解决方案
报错1: PermissionError: [WinError 5] 报错2: Command... failed with error code 1 in .. 以上两种报错,解决较为简单,主要是权 ...
- Python在指定环境下安装第三方库的报错解决办法
Python在指定环境下安装第三方库的报错解决办法 在python安装第三方库时,如果直接打开cmd命令提示符,并输入下列安装命令,则会默认安装在base环境下 但base环境下的包新建的虚拟环境是无 ...
- qpython3l手机版安装第三方库总是报错_python编码问题在此终结
1 版本差异概览 1.1 Python 2.X: str(用于8位文本和二进制数据) unicode(用于宽字符文本) 在Python2中,通用的str类型填补了二进制数据的这一角色(特指python ...
- pip安装第三方库,报错 Retrying (Retry(total=4, connect=None, read=None, redirect=None)) after connection brok
错误: 报错原因: 国外镜像源连接问题导致 解决: 改为国内镜像源下载 常用国内源: 清华:https://pypi.tuna.tsinghua.edu.cn/simple/ 阿里云:http://m ...
- 安装32位mysql报错_在CentOS中安装32位或64位MySql报错error: Failed dependencies解决办法...
在CentOS中安装MySql报错error: Failed dependencies解决办法 安装64位MySql报错内容如下: error: Failed dependencies: libaio ...
- Python导入第三方库以及报错 Error..........处理办法
目录 未导入matplotlib这样一个第三方库上网查询了一下PyCharm这个软件第三方库的导入方法: 如果不配置肯定会报错 看了网上有很多方法,博主分享一个自己用的方法并成功了: 还有就是感觉下载 ...
- Python中安装requests库总是报错的解决方法
今天,要安装requests库. 文章上说,直接在终端窗口执行如下命令就行. pip install requests 1 然而我还是失败了. 在电脑前坐了一个小时,找过很多解决方法的博客,都无济于事 ...
- PyCharm安装Twisted库(报错:Microsoft Visual C++ 14.0 is required. Get it with “Build Tools for Visual Stu)
报错信息 解决方案 先安装wheel pip install wheel 去官方找对应的版本:https://www.lfd.uci.edu/~gohlke/pythonlibs/#twisted 以 ...
- 想运行游戏,在Pycharm中安装Pygame库一直报错,我只是忽视了它
问题:本机电脑中已经安装好了Python3.7版本.相应版本的Pygame软件以及pip配置.结果在Pycharm环境中安装Pygame总是报错. 按照常规Pycharm安装Pygame,新建项目Fi ...
最新文章
- populate_dir
- Maven 的41种骨架功能介绍
- Android 使用ViewPager 做的半吊子的图片轮播
- mysql一个用户SQL慢查询分析,原因及优化
- 柔性体没有应变_柔性应变和压力传感器
- 1147 Heaps
- Git远端库(GitHub)及Git流
- 交付自动化的探索与展望
- python各个版本区别_Python 的各个版本
- 网易云音乐linux版_全线下架:网易云音乐难解的困境
- Python读写Excel实现大量数据处理
- 领导力教练:世界著名企业教练们的实践心得(原书第3版)
- 跟着实训团初学HTML的第一天
- python3GUI--打造一款音乐播放器By:PyQt5(附下载地址)
- 腾讯大王卡 蚂蚁宝卡 区别 哪个好
- 国产网页在线编辑器kindeditor的使用
- python连乘函数_python 连乘
- R语言和医学统计学:非参数检验的补充
- mysql-5.7.12-winx64安装的时候无法启动服务问题
- 基于Matlab模拟偶极子天线设计
热门文章
- html5操作类名API——classlist
- JavaScript 循环
- linux tempfile指令学习
- vue + vue-router + vue-resource 基于vue-cli脚手架 ---笔记
- 使用Sublime Text 3做Python开发
- 朝花夕拾-4-shell
- 工业相机硬汉!这款相机被NASA选择,全程记录毅力号登陆火星
- 【项目合作】基于Kinect人体模型重建与三围测量
- mysql groupby 拼接_mysql分组并多行拼接--group_concat和groupby的使用
- 80 个例子,彻底掌握Python日期时间处理