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

Commit 46b60bc

Browse files
committed
Add project: first
1 parent c3f388c commit 46b60bc

File tree

9 files changed

+69100
-0
lines changed

9 files changed

+69100
-0
lines changed

MachineLearning Projects/Face-detecting/Cascade-Files/face_default.xml

Lines changed: 33314 additions & 0 deletions
Large diffs are not rendered by default.

MachineLearning Projects/Face-detecting/Cascade-Files/more_bet.xml

Lines changed: 35712 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Detecting face from photo or camera
2+
___
3+
### Setup
4+
`pip install -r requirements.txt`
5+
6+
___
7+
### Usage
8+
`python3 main.py` detecting face from camera
9+
`q` for exit from frame
10+
11+
12+
`pyhton3 detect_face_from_image` detecting face from images on
13+
directory images `q` for exit from frame
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import cv2
2+
3+
img = cv2.imread('images/im1.jpg')
4+
img2 = cv2.imread('images/im2.jpg')
5+
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
6+
gray2 = cv2.cvtColor(img2, cv2.COLOR_BGR2GRAY)
7+
8+
window_name = 'Image'
9+
10+
faces = cv2.CascadeClassifier('Cascade-Files/more_bet.xml')
11+
12+
results = faces.detectMultiScale(gray, 1.1, 4)
13+
# results = faces.detectMultiScale(gray2, 1.1, 4)
14+
15+
for (x, y, w, h) in results:
16+
cv2.rectangle(img, (x, y), (x + w, y + h), (0, 0, 255), 2)
17+
cv2.rectangle(img2, (x, y), (x + w, y + h), (0, 0, 255), 2)
18+
19+
cv2.imshow(window_name, img)
20+
cv2.waitKey(0)
Loading
Loading
Loading
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# обнаруживает пока что только лицо и пишет на рамочке
2+
3+
import cv2
4+
5+
video = cv2.VideoCapture(0)
6+
hands_hear_cascade = cv2.CascadeClassifier('Cascade-Files/more_bet.xml')
7+
8+
# Write some Text
9+
10+
font = cv2.FONT_ITALIC
11+
text = 'Face detected'
12+
fontScale = 1
13+
fontColor = (0, 255, 0)
14+
thickness = 3
15+
lineType = 1
16+
17+
while True:
18+
_r, frame = video.read()
19+
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
20+
hands = hands_hear_cascade.detectMultiScale(gray, 1.1, 3)
21+
22+
if len(hands):
23+
print("Face")
24+
25+
for x, y, w, h in hands:
26+
bottomLeftCornerOfText = (x - 5, y - 5)
27+
cv2.rectangle(frame, (x, y), (x + w, y + h), (0, 255, 0), 2)
28+
cv2.putText(frame, text,
29+
bottomLeftCornerOfText,
30+
font,
31+
fontScale,
32+
fontColor,
33+
thickness,
34+
lineType)
35+
cv2.imshow("test", frame)
36+
if cv2.waitKey(1) & 0xFF == ord('q'):
37+
break
38+
video.release()
39+
cv2.destroyAllWindows()
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
numpy==1.23.4
2+
opencv-python==4.6.0.66

0 commit comments

Comments
 (0)