Professional Documents
Culture Documents
Esther Jemima
Esther Jemima
AHnme Rlrrinn
26
27 #cV2. imwrite("thresh_otsu. jpg", thresh1)
28 #cV2. waitKey()
est 2
Iimport cv2
img.py
La
3 #img=cv2. imread(" people.jpg")
4 ing=cv2.imread("class. jpg")
5 resize=cv2.resiz , (500,
1ze(tng,(
St 6 i=cv2.cvtColor (resize cu2 COL 0BBGR2GRAY)
gaussian blur=cv2.GaussianBlur (i,(1,1),0)
est 8 adap=cv2.adaptiveThreshold (gaussian blur,
esti 255,cv2.ADAPTIVE_THRESH_ MEAN_C, Cv2.THRESH_BINARY,25,30) ing. py
9 edge=cV2.Canny (adap, 50, 190)
D 10 cv2.imshow(" Edge show",edge)
11 cv2.waitKey (0)
12
4 cascPath=os . path.dirname(cv2._file_)+"/data/
haarcascade_frontalface_default.xml"
5 faceCascade = cv2.CascadeClassifier (cascPath)
6
7 video_capture = cv2.VideoCapture (0)
9 while True:
10 # Capture frame -by -frame
11 ret, frames = video_capture . read()
12
13 gray = cv2.cvtColor (frames, cV2.COLOR_BGR2GRAY)
14
15 faces = faceCascade.detectMultiScale(
16 gray,
17 scaleFactor=1.1,
18 minNeighbors=5,
minSize=(30, 30),
2 flags=cv2.CASCADE_SCALE_IMAGE
21 )
22
23 # Draw a rectangle around the faces
24 for (x, y, w, h) in faces:
25 cV2.rectangle(frames, (x, y), (x+W, y+h), (0, 255, 0), 2)
26
# the resulting frane
27
28 D0spLay
cV2.imshow( deo', frames) (x=128, y=3) -R:77 G:79 B:65
29
1if cv2.waitKev(1) & 0xEF == 0 r d a ) :
Python Tab Width: 8 Ln 1, Col 1 INS