Skip to content

Commit b0fa82b

Browse files
committed
face
1 parent 2d34fc1 commit b0fa82b

6 files changed

+68197
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
## Name - Soumyajit Chakraborty
2+
## place - kolkata
3+
## date - 10 / 08 / 2020
4+
5+
import cv2 as cv
6+
face_cascade = cv.CascadeClassifier('..\libs\haarcascade_frontalface_default.xml')
7+
face_cascade_eye = cv.CascadeClassifier('..\libs\haarcascade_eye.xml')
8+
#face_glass = cv.CascadeClassifier('..\libs\haarcascade_eye_tree_eyeglasses.xml')
9+
10+
cap = cv.VideoCapture(0)
11+
while(cap.isOpened()):
12+
13+
falg ,img = cap.read() #start reading the camera output i mean frames
14+
# cap.read() returning a bool value and a frame onject type value
15+
16+
gray = cv.cvtColor(img , cv.COLOR_BGR2GRAY) # converting to grayscale image to perform smoother
17+
faces = face_cascade.detectMultiScale(img , 1.1, 7) #we use detectMultiscale library function to detect the predefined structures of a face
18+
eyes = face_cascade_eye.detectMultiScale(img , 1.1 , 7)
19+
# using for loops we are trying to read each and every frame and map
20+
for(x , y ,w ,h ) in faces:
21+
cv.rectangle(img , (x , y) , (x+w , y+h) , (0 , 255 , 0) , 1)
22+
23+
for(a , b , c , d) in eyes:
24+
cv.rectangle(img, (a , b), (a+c, b+d), (255, 0, 0), 1)
25+
26+
cv.imshow('img' , img )
27+
c = cv.waitKey(1)
28+
if c == ord('q'):
29+
break
30+
31+
cv.release()
32+
cv.destroyAllWindows()
33+
34+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import cv2 as cv
2+
import numpy as np
3+
4+
img = cv.imread('..\img\hand1.jpg' , 0)
5+
flag,frame = cv.threshold(img , 70 , 255 , cv.THRESH_BINARY)
6+
7+
contor,_ = cv.findContours(frame.copy(),cv.RETR_TREE,cv.CHAIN_APPROX_SIMPLE)
8+
9+
hull = [cv.convexHull(c) for c in contor]
10+
11+
final = cv.drawContours(img , hull , -1 , (0 , 0 , 0) )
12+
cv.imshow('original_image' , img)
13+
cv.imshow('thres' , frame)
14+
cv.imshow('final_hsv' , final)
15+
16+
cv.waitKey(0)
17+
cv.destroyAllWindows()

img/hand1.jpg

20.1 KB
Loading

0 commit comments

Comments
 (0)