The 2nd exercise is a demonstration using the Face module of the OpenCV contribution libraries. The official documentation for OpenCV 3.4.2 has a tutorial on face landmark detection. The Face module distribution also has a sample – Facemark.java. This exercise is derived from this sample. There are 2 extra parameter files. One is the Haar Cascades file, haarcascade_frontalface_default.xml we used in the last post for general face detection. The other one is the face landmark model file face_landmark_model.dat that will be downloaded during the building process of the OpenCV. Otherwise, it is also available at this GitHub link.
The program uses the Facemark class with the instance variable fm.
It is created by the command.
fm = Face.createFacemarkKazemi();
And load in the model file with the following,
where modelFile is the string variable containing the model file name.
Complete source code is in this GitHub repository.