Skip to content
This repository was archived by the owner on Nov 30, 2022. It is now read-only.

Face detection Open cv #209

Merged
merged 4 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions Image-Processing/Face_detection/Face_detection.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import cv2 ##Import OpenCv

face = cv2.CascadeClassifier('C:/Users/91976/Desktop/haarcascade_frontalface_default.xml') ##'haarcascade_frontalface_default.xml' an opencv classifier for face detection
cap = cv2.VideoCapture(0) ##capturevideo by webcam or your laptop default cam for webcame => 1 and for defalut laptop camera => 2

while True:
sucess , img = cap.read()
gray = cv2.cvtColor( img , cv2.COLOR_BGR2GRAY ) ##before detecting face you should convert img or video into gray image
faces = face.detectMultiScale( gray ,1.1 ,5 )

for ( x , y , w , h) in faces:
cv2.rectangle(img,( x , y ),( x*w , y*h ),(255,0,0),2) ##will create the rectangle where face is detected

cv2.imshow('img',img)
k = cv2.waitKey(30) & 0xff
if k == 27:
break

cap.release()
20 changes: 20 additions & 0 deletions Image-Processing/Face_detection/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Image Processing

Image Processing is most commonly termed as 'Digital Image Processing' and the domain in which it is frequently used is 'Computer Vision'.
Don't be confused - we are going to talk about both of these terms and how they connect.
Both Image Processing algorithms and Computer Vision (CV) algorithms take an image as input; however, in image processing,
the output is also an image, whereas in computer vision the output can be some features/information about the image.

## OpenCV

![](https://logodix.com/logo/1989939.png)

## Installation

### Windows

$ pip install opencv-python
### MacOS
$ brew install opencv3 --with-contrib --with-python3
### Linux
$ sudo apt-get install libopencv-dev python-opencv