Coder Social home page Coder Social logo

facedetect's Introduction

FaceDetect

臉部偵測 use Python

Python OpenCV Tutorial

特色

  • 圖片、影片 臉部偵測

建立環境

Python 3.5.2 + OpenCV 3.1.0 (建議用這個,更簡單) 請參考

如何安裝 OpenCV3 - 使用 Anaconda

Python 2.7.3 + OpenCV 2.4.12 請參考

可參考 如何在Windows安裝OpenCV Python設定

執行範例

Python 3.5.2 + OpenCV 3.1.0

python face_detect_python3.py

程式執行後,會自動跳出偵測臉部的圖片

alt tag

透過 camera 偵測人臉

python face_detect_camera.py

圖片會輸出到 camera 資料夾裡,會存 10 張。

alt tag

Python 2.7.3 + OpenCV 2.4.12

python face_detect_python2.py test1.jpg haarcascade_frontalface_alt.xml

輸出

目錄底下會多出一張名稱為 face_detection.jpg 的圖片

alt tag

備註

更多的 haarcascade 可到 opencv 路徑裡 opencv\sources\data\haarcascades 取得,

路徑底下還有 haarcascade_eye.xml 偵測眼睛之類的,大家可以自行摸索。

最後,請注意,這是 臉部偵測 ,並不是 臉部辨識

其他

更多的資訊可參考原作者

Run the code like this:

python face_detect.py abba.png haarcascade_frontalface_default.xml

If you want to understand how the code works, the details are here:

https://realpython.com/blog/python/face-recognition-with-python/

後記

本篇文章所介紹的是 臉部偵測 ( Face Detection ),並不是 臉部辨識 ( Face Recognize)

如果要辦到 臉部辨識 ( Face Recognize),OpenCV 其實也可以辦到,可以透過OpenCV官網提供的演算法來完成,

OpenCV 官方有提供三種 Face Recognition 演算法,分別為

EigenFaceRecognizer、FisherFaceRecognizer、 LBPHFaceRecognizer。

最後我選擇 LBPHFaceRecognizer,為什麼不選 EigenFaceRecognizer 或 FisherFaceRecognizer 呢?

因為 LBPHFaceRecognizer 有幾個優點:

  • 訓練和比對的圖片大小可以不一致。
  • 比較不會受到光線以及角度的影響 ( 辨識率 )。
  • 可以直接更新訓練資料庫,不用全部重新訓練。

流程大致上是 收集人臉 --> 訓練 --> 得到一個 dataSet 然後透過這個 dataSet 下去辨識。

我認為使用 OpenCV 提供的 Face Recognition 演算法效果沒有非常好,

或許可以考慮用目前最紅的深度學習 ( Deep learning ) 處理精準度的問題,

之前有稍微接觸深度學習結合人臉辨識,可以參考 face-recognition-notes

執行環境

  • Windows 10
  • Python 3.5.2
  • OpenCV 3.1.0

Donation

如果有幫助到您,也想鼓勵我的話,歡迎請我喝一杯咖啡:laughing:

alt tag

贊助者付款

License

MIT license

facedetect's People

Contributors

twtrubiks avatar shantnu avatar www avatar mjhea0 avatar coldclimate avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.