人脸识别

C:\WINDOWS\system32>pip install opencv-python
Collecting opencv-python
  Downloading https://files.pythonhosted.org/packages/a3/50/04d0669afe884f137c2f490642756e8c4a658254300a9eaf253d1e643085/opencv_python-4.1.0.25-cp37-cp37m-win_amd64.whl (37.3MB)
    100% |████████████████████████████████| 37.4MB 534kB/s
Collecting numpy>=1.14.5 (from opencv-python)
  Downloading https://files.pythonhosted.org/packages/ce/61/be72eee50f042db3acf0b1fb86650ad36d6c0d9be9fc29f8505d3b9d6baa/numpy-1.16.4-cp37-cp37m-win_amd64.whl (11.9MB)
    100% |████████████████████████████████| 11.9MB 2.4MB/s
Installing collected packages: numpy, opencv-python
Successfully installed numpy-1.16.4 opencv-python-4.1.0.25
You are using pip version 18.1, however version 19.1.1 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.

C:\WINDOWS\system32>

https://github.com/Mjrovai/OpenCV-Face-Recognition

https://www.jianshu.com/p/3e3b295e0e98https://blog.csdn.net/u012679707/article/details/80410094
http://www.sohu.com/a/259092417_172964https://blog.csdn.net/yefeng215315434/article/details/80690539
#coding=utf8
import cv2, time

print('Press Esc to exit')
faceCascade = cv2.CascadeClassifier('Cascades/haarcascade_frontalface_default.xml')
imgWindow = cv2.namedWindow('FaceDetect', cv2.WINDOW_NORMAL)

def detect_face():
    source = "http://192.168.0.100:8080/video"
    capInput = cv2.VideoCapture(source)
    # 避免处理时间过长造成画面卡顿
    nextCaptureTime = time.time()
    faces = []
    if not capInput.isOpened(): print('Capture failed because of camera')
    while 1:
        ret, img = capInput.read()
        gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
        if nextCaptureTime < time.time():
            nextCaptureTime = time.time() + 0.1
            faces = faceCascade.detectMultiScale(gray, 1.1,3,0,(140,140))
        if 0 < len(faces):
            for x, y, w, h in faces:
                cv2.rectangle(img, (x, y), (x + w, y + h), (255, 0, 0), 2)
        cv2.imshow('FaceDetect', img)
        # 这是简单的读取键盘输入,27即Esc的acsii码
        if cv2.waitKey(1) & 0xFF == 27: break
    capInput.release()
    cv2.destroyAllWindows()

if __name__ == '__main__':
    detect_face()

sudo apt-get install libopencv-dev
sudo apt-get install python-opencv

https://blog.csdn.net/yuanlulu/article/details/86498836

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值