I've been working on a project to get the forehead area from a live streaming video and not just use and image and crop the forehead like from this example How can i detect the forehead region using opencv and dlib?.
cap = cv2.VideoCapture(0)
detector = dlib.get_frontal_face_detector()
predictor = dlib.shape_predictor(predict_path)
while True:
_, frame = cap.read()
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)
faces = detector(gray) #detects number of faces present
for face in faces:
x1 = face.left()
y1 = face.top()
x2 = face.right()
y2 = face.bottom()
cv2.rectangle(frame, (x1, y1), (x2, y2), (0, 0, 255), 3)
landmarks = predictor(gray, face)
for n in range(68, 81):
x = landmarks.part(n).x
y = landmarks.part(n).y
cv2.circle(frame, (x, y), 4, (0, 255, 0), -1)
I managed to get the forehead region using the landmarks of using https://github.com/codeniko/shape_predictor_81_face_landmarks/blob/master/shape_predictor_81_face_landmarks.dat
But what I need is the rectangle bounding box onto where the landmark is at detecting the forehead region. Is this possible to get? If not, what should I do to get the forehead region. Thanks in advance.