forked from geekcomputers/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2d34fc1
commit b0fa82b
Showing
6 changed files
with
68,197 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
## Name - Soumyajit Chakraborty | ||
## place - kolkata | ||
## date - 10 / 08 / 2020 | ||
|
||
import cv2 as cv | ||
face_cascade = cv.CascadeClassifier('..\libs\haarcascade_frontalface_default.xml') | ||
face_cascade_eye = cv.CascadeClassifier('..\libs\haarcascade_eye.xml') | ||
#face_glass = cv.CascadeClassifier('..\libs\haarcascade_eye_tree_eyeglasses.xml') | ||
|
||
cap = cv.VideoCapture(0) | ||
while(cap.isOpened()): | ||
|
||
falg ,img = cap.read() #start reading the camera output i mean frames | ||
# cap.read() returning a bool value and a frame onject type value | ||
|
||
gray = cv.cvtColor(img , cv.COLOR_BGR2GRAY) # converting to grayscale image to perform smoother | ||
faces = face_cascade.detectMultiScale(img , 1.1, 7) #we use detectMultiscale library function to detect the predefined structures of a face | ||
eyes = face_cascade_eye.detectMultiScale(img , 1.1 , 7) | ||
# using for loops we are trying to read each and every frame and map | ||
for(x , y ,w ,h ) in faces: | ||
cv.rectangle(img , (x , y) , (x+w , y+h) , (0 , 255 , 0) , 1) | ||
|
||
for(a , b , c , d) in eyes: | ||
cv.rectangle(img, (a , b), (a+c, b+d), (255, 0, 0), 1) | ||
|
||
cv.imshow('img' , img ) | ||
c = cv.waitKey(1) | ||
if c == ord('q'): | ||
break | ||
|
||
cv.release() | ||
cv.destroyAllWindows() | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import cv2 as cv | ||
import numpy as np | ||
|
||
img = cv.imread('..\img\hand1.jpg' , 0) | ||
flag,frame = cv.threshold(img , 70 , 255 , cv.THRESH_BINARY) | ||
|
||
contor,_ = cv.findContours(frame.copy(),cv.RETR_TREE,cv.CHAIN_APPROX_SIMPLE) | ||
|
||
hull = [cv.convexHull(c) for c in contor] | ||
|
||
final = cv.drawContours(img , hull , -1 , (0 , 0 , 0) ) | ||
cv.imshow('original_image' , img) | ||
cv.imshow('thres' , frame) | ||
cv.imshow('final_hsv' , final) | ||
|
||
cv.waitKey(0) | ||
cv.destroyAllWindows() |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.