A short example with OpenCV
To begin, you need to upload an image.
Dim bmp As Bitmap = LoadBitmap(File.DirAssets, "face.jpg")
Dim mat As OCVMat = OCV.BitmapToMat(bmp)
For face detection, you need to load a Haar classifier (.xml file)
Dim classifier As OCVCascadeClassifier
classifier.Initialize(File.DirAssets, "haarcascade_frontalface_default.xml")
Dim faces As List = classifier.DetectMultiScale(mat, 1.1, 3, 0, OCV.Size(30, 30), OCV.Size(300, 300))
The haarcascade_frontalface_default.xml file is a pre-trained classifier used by OpenCV to detect faces in an image.
It contains a series of mathematical rules based on the Haar Cascade algorithm, which identifies characteristic facial features (eyes, nose, mouth, etc.).
Finally, overlay an image (hairstyle) and display the result.
For Each r As OCVRect In faces
' Load hairstyle image
Dim hairBmp As Bitmap = LoadBitmap(File.DirAssets, "hair.png")
' Resize according to face size
Dim scaledHair As Bitmap = hairBmp.Resize(r.Width, r.Height, True)
' Overlay on face
OCV.OverlayBitmap(mat, scaledHair, r.X, r.Y - r.Height / 2) ' positionner au-dessus
Next
Dim resultBmp As Bitmap = OCV.MatToBitmap(mat)
ImageView1.Bitmap = resultBmp
It's something like that. But creating a complete application will require a lot of work.