Windows环境miniconda下安装face-recognition

步骤:

0.安装dlib,参考博文:https://blog.csdn.net/csdn_zhishui/article/details/79805380

1.打开anaconda prompt,激活python36环境。

如有问题请参考博文:参考博文:https://blog.csdn.net/csdn_zhishui/article/details/79767956

2.键入以下命令:

pip install face-recognition

如果有错误,重新键入一次。

成功。



键入

python

import face_recognition

现在可以愉快的使用 face-recognition了。


3.测试代码

# -*- 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("yuantu" , 0)
cv2.imshow("yuantu", 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("recongnition" , 0)
cv2.imshow("recongnition", img)

cv2.waitKey(0)
cv2.destroyAllWindows()

安装face_recognition的时候提示下面报错信息: Building wheels for collected packages: dlib Building wheel for dlib (setup.py) … error error: subprocess-exited-with-error × python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [47 lines of output] C:\Users\dltsz\AppData\Local\Temp\pip-install-liqyha4o\dlib_943d38e4a62c4e52914ec6f7e8bcbde9\setup.py:234: SyntaxWarning: invalid escape sequence ‘(’ major = re.findall(“set(CPACK_PACKAGE_VERSION_MAJOR."(.)"”, open(cmake_file).read())[0] C:\Users\dltsz\AppData\Local\Temp\pip-install-liqyha4o\dlib_943d38e4a62c4e52914ec6f7e8bcbde9\setup.py:235: SyntaxWarning: invalid escape sequence ‘(’ minor = re.findall(“set(CPACK_PACKAGE_VERSION_MINOR."(.)"”, open(cmake_file).read())[0] C:\Users\dltsz\AppData\Local\Temp\pip-install-liqyha4o\dlib_943d38e4a62c4e52914ec6f7e8bcbde9\setup.py:236: SyntaxWarning: invalid escape sequence ‘(’ patch = re.findall(“set(CPACK_PACKAGE_VERSION_PATCH."(.)"”, open(cmake_file).read())[0] running bdist_wheel running build running build_ext CMake is not installed on your system! Or it is possible some broken copy of cmake is installed on your system. It is unfortunately very common for python package managers to include broken copies of cmake. So if the error above this refers to some file path to a cmake file inside a python or anaconda or miniconda path then you should delete that broken copy of cmake from your computer. Instead, please get an official copy of cmake from one of these known good sources of an official cmake: - cmake.org (this is how windows users should get cmake) - apt install cmake (for Ubuntu or Debian based systems) - yum install cmake (for Redhat or CenOS based systems) On a linux machine you can run `which cmake` to see what cmake you are actually using. If it tells you it's some cmake from any kind of python packager delete it and install an official cmake. More generally, cmake is not installed if when you open a terminal window and type cmake --version you get an error. So you can use that as a very basic test to see if you have cmake installed. That is, if cmake --version doesn't run from the same terminal window from which you are reading this error message, then you have not installed cmake. Windows users should take note that they need to tell the cmake installer to add cmake to their PATH. Since you can't run commands that are not in your PATH. This is how the PATH works on Linux as well, but failing to add cmake to the PATH is a particularly common problem on windows and rarely a problem on Linux. ================================================================================ ================================================================================ ================================================================================ [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for dlib Running setup.py clean for dlib Failed to build dlib ERROR: Failed to build installable wheels for some pyproject.toml based projects (dlib)
03-21
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值