File tree Expand file tree Collapse file tree 7 files changed +20
-19
lines changed Expand file tree Collapse file tree 7 files changed +20
-19
lines changed Original file line number Diff line number Diff line change 5
5
import time
6
6
7
7
# https://raw.githubusercontent.com/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt
8
- prototxt_path = "07. Face Detection /deploy.prototxt.txt"
8
+ prototxt_path = "./assets /deploy.prototxt.txt"
9
9
# https://raw.githubusercontent.com/opencv/opencv_3rdparty/dnn_samples_face_detector_20180205_fp16/res10_300x300_ssd_iter_140000_fp16.caffemodel
10
- model_path = "07. Face Detection /res10_300x300_ssd_iter_140000.caffemodel"
10
+ model_path = "./assets /res10_300x300_ssd_iter_140000.caffemodel"
11
11
12
12
# load Caffe model
13
13
model = cv2 .dnn .readNetFromCaffe (prototxt_path , model_path )
Original file line number Diff line number Diff line change 3
3
import cv2
4
4
5
5
# Path
6
- face_path = './haarcascade_frontalface_default.xml'
7
- eye_path = './haarcascade_eye.xml'
8
- face_cascade = cv2 .CascadeClassifier (face_path )
9
- eye_cascade = cv2 .CascadeClassifier (eye_path )
6
+ face_cascade = cv2 .CascadeClassifier ('./assets/haarcascade_frontalface_default.xml' )
7
+ eye_cascade = cv2 .CascadeClassifier ('./assets/haarcascade_eye.xml' )
10
8
11
9
12
10
def detectedFace (img ):
@@ -45,9 +43,9 @@ def detectedFace(img):
45
43
if k == 27 :
46
44
cv2 .destroyAllWindows ()
47
45
elif k == ord ('s' ):
48
- cv2 .imwrite ('Media/face-detected.jpeg' , img )
46
+ cv2 .imwrite ('./ Media/face-detected.jpeg' , img )
49
47
cv2 .destroyAllWindows ()
50
48
51
49
52
- path_img = '.. /Media/face-001.jpg'
50
+ path_img = './Media/face-001.jpg'
53
51
detectedFace (path_img )
Original file line number Diff line number Diff line change 3
3
import cv2
4
4
5
5
# Global Declarations
6
- proto = 'deploy.prototxt.txt'
7
- model = 'res10_300x300_ssd_iter_140000.caffemodel'
6
+ # https://raw.githubusercontent.com/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt
7
+ prototxt_path = "./assets/deploy.prototxt.txt"
8
+ # https://raw.githubusercontent.com/opencv/opencv_3rdparty/dnn_samples_face_detector_20180205_fp16/res10_300x300_ssd_iter_140000_fp16.caffemodel
9
+ model_path = "./assets/res10_300x300_ssd_iter_140000.caffemodel"
10
+
8
11
confThresh = 0.8
9
- net = cv2 .dnn .readNetFromCaffe (proto , model )
12
+ net = cv2 .dnn .readNetFromCaffe (prototxt_path , model_path )
10
13
11
14
def detectFace (imgPath ):
12
15
img = cv2 .imread (imgPath )
@@ -31,10 +34,10 @@ def detectFace(imgPath):
31
34
if key == 27 :
32
35
cv2 .destroyAllWindows ()
33
36
elif key == ord ('s' ):
34
- cv2 .imwrite ('.. /Media/face-detected-dnn.jpeg' , img )
37
+ cv2 .imwrite ('./Media/face-detected-dnn.jpeg' , img )
35
38
cv2 .destroyAllWindows ()
36
39
37
40
38
41
39
- path_img = '.. /Media/face-001.jpg'
42
+ path_img = './Media/face-001.jpg'
40
43
detectFace (path_img )
Original file line number Diff line number Diff line change 3
3
import numpy as np
4
4
import cv2
5
5
6
- face_cascade = cv2 .CascadeClassifier (cv2 . data . haarcascades + ' haarcascade_frontalface_default.xml' )
7
- eye_cascade = cv2 .CascadeClassifier (cv2 . data . haarcascades + ' haarcascade_eye.xml' )
6
+ face_cascade = cv2 .CascadeClassifier ('./assets/ haarcascade_frontalface_default.xml' )
7
+ eye_cascade = cv2 .CascadeClassifier ('./assets/ haarcascade_eye.xml' )
8
8
9
9
cap = cv2 .VideoCapture (0 )
10
10
Original file line number Diff line number Diff line change 4
4
import cv2
5
5
6
6
# https://raw.githubusercontent.com/opencv/opencv/master/samples/dnn/face_detector/deploy.prototxt
7
- prototxt_path = "07. Face Detection /deploy.prototxt.txt"
7
+ prototxt_path = "./assets /deploy.prototxt.txt"
8
8
# https://raw.githubusercontent.com/opencv/opencv_3rdparty/dnn_samples_face_detector_20180205_fp16/res10_300x300_ssd_iter_140000_fp16.caffemodel
9
- model_path = "07. Face Detection /res10_300x300_ssd_iter_140000.caffemodel"
9
+ model_path = "./assets /res10_300x300_ssd_iter_140000.caffemodel"
10
10
11
11
confThresh = 0.5
12
12
net = cv2 .dnn .readNetFromCaffe (prototxt_path , model_path )
Original file line number Diff line number Diff line change 3
3
import numpy as np
4
4
import cv2
5
5
6
- face_cascade = cv2 .CascadeClassifier (cv2 . data . haarcascades + ' haarcascade_frontalface_default.xml' )
7
- smile_cascade = cv2 .CascadeClassifier (cv2 . data . haarcascades + ' haarcascade_smile.xml' )
6
+ face_cascade = cv2 .CascadeClassifier ('./assets/ haarcascade_frontalface_default.xml' )
7
+ smile_cascade = cv2 .CascadeClassifier ('./assets/ haarcascade_smile.xml' )
8
8
9
9
cap = cv2 .VideoCapture (0 )
10
10
You can’t perform that action at this time.
0 commit comments