How to detect landmarks of a face including forehead? - python

This tutorial teaches how to detect landmarks of a face.
Here, there are no landmarks for the forehead. What can I do so that the landmarks also detect the forehead?

Forehead is not "re;iable" part of face, it's often being covered by hairs.. By the same reason ears are not included too in that 68-points dlib model. So, you can either create your own model or use, for example, Mediapipe Mesh.

Related

How to change the face emotion with a single image?

I have a face image, and I found the 68 facial coordinate points with dlib libarary in python.
Now I want to change the face emotion by closing the mouth, for ex. remove the distance between points[61, 62,63,64,65,66,67,68,68], or closing the right eye by removing the distance between points:[43,44,..,48]
So, I need to to color this area with natural colors in a way that it seems natural.
is there any method or algorithm available to solve it? I use openCV right now,but any other library is okay for me, thanks.
What you could do is run your facial coordinate points detection algorithm on the images in this data set: https://datarepository.wolframcloud.com/resources/FER-2013, which contains images for seven emotions (happiness, neutral, sadness, anger, surprise, disgust, fear).
Like that you could maybe infer the transformation from the neutral face to one of this emotion.

What are the different types of face recognitions the dlib has?

Can i know what are all the face recognitions the dlib has to offer us. This is in the case of face landmarks.
There are many landmark detectors dlib has to offer us. Mostly, The first one is:
68-point landmark detectors: This pre-trained landmark detector identifies 68 points ((x,y) coordinates) in a human face. These points localize the region around the eyes, eyebrows, nose, mouth, chin and jaw.
The second one is:5 point landmark detector: To make things faster than the 68 point detector, dlib introduced the 5 point detector which assigns 2 points for the corners of the left eye, 2 points for the right eye and one point for the nose. This detector is most commonly used for alignment of faces.
There is a good article in gfg:Link
There is also another link : good explanation with examples.

How to Crop face and its parts?

I am building a face remake application from where the user remakes face by scrolling through different facial parts to make a face (basically, mix-matching eyes, nose, lips of some other person), until now I wrote an algorithm that divides the facial parts like eyes, nose from the image using Python's Dlib and OpenCv, but due to images being ill-captured facial features cropped aren't aligned. So when I create a database of eyes, nose, lips, and face, while remaking they aren't gonna look like a face when placed at their position.
This is the Original Image
These are the Eyes(Titled)
The Nose Cropped(tilted)
And Lips(tilted)
This image is what I ended up to extract just the face part(NEED ALTERNATIVE IDEA FOR THIS (%)
So my plan was to use this last image as the base for remaking the face.
To tackle the tilting, I applied the face alignment algorithm so that when I crop the eyes in a rectangle image is perfectly straight. But this is what I am getting:
The face is straight but the image being tilted the pockets of black color are added around it, now as this is unavoidable, I NEED HELP REGARDING, HOW CAN I PREPARE THE FACE WITH NO FACIAL PARTS?
NOTES:
1.) Image cropping should not crop out any part of the face.
2.) Thought of using Grabcut to separate face and background, but validating nearly 10,000 images, I need a higher accuracy module, Or would Grabcut be fine(NEED SUGGESTION)?
Dont mind the smudge, but this is somewhat I need the output from the Algorithm

Unable to detect faces of cartoon images

I am trying to implement a simple face detection of cartoons code using opencv and python. Though the code I have used works for faces of humans I am not able to detect cartoon faces using this. Is there any way I can make it detect cartoon faces too.
import cv2
import matplotlib.pyplot as plt
imagePath = 'frame179.jpg'
cascPath = '/Users/tonystark/opencv/data/haarcascades/haarcascade_frontalface_default.xml'
faceCascade = cv2.CascadeClassifier(cascPath)
image = cv2.imread(imagePath)
gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
faces = faceCascade.detectMultiScale(
gray,
scaleFactor=1.1,
minNeighbors=40,
minSize=(24, 24),
flags=cv2.CASCADE_SCALE_IMAGE
)
The images are human for which I am able to get the location of the face, whereas for cartoon, I am not able to get the location of faces.
Thanks a lot in advance !
Haar cascades are used to detect only one particular thing and in your case, it has been trained to detect only human faces. You will have to create another haar cascade to detect cartoon faces.
You can refer to this video for creating one -https://www.youtube.com/watch?v=jG3bu0tjFbk
Actually I agree with all above comments. There is no ready sollution for catroon objects and I've tried a lot of models and nothing works (ORB, Haar Cascade, SuperPixel and etc.) and no AutoML solution (from Google or Amazon) also does not work. There is only one way to do the face recognition in cartoons objects. This solution is firstly to make your own labeled data set of images and then try to train some models to detect objects. So I've chosen this way, and results are great, 91% accuracy.
So as cartoon images are very different to that of humans, we need to train a model from scratch for them separately.
I implemented a YOLO model, and trained it, and the results were really good !
labelImg can be used to prepare the dataset.
I referred this blog : Darknet YOLO using OpenCV to create my own YOLO detector in which the github repository Darknet YOLO is cloned and modified.
EDIT :
My project on github

Face detection for two faces-Cascade opencv python

I am working on with the Face detection using cascade Classifier in opencv python. Its working fine. But i want to develop my code to detect only one face and also the largest face only to detect.
Sort the detected faces by size and keep the biggest one only?

Categories