Open axmadjon opened 6 years ago
most parts you'll need are already builtin with recent opencv3.4 !
you can use the same, pretrained deep-face network, using opencv's dnn module, like this:
dnn::Net net;
try {
net = dnn::readNetFromTorch("openface.nn4.small2.v1.t7");
} catch(Exception &e) {
cerr << "Download it from: ";
cerr << "https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7" << endl;
}
// later:
Mat inputBlob = dnn::blobFromImage(image, 1./255, Size(96,96), Scalar(), true, false);
net.setInput(inputBlob);
Mat feature = net.forward();
now you can compare images, using the 128 float feature Mat from the dnn output, using a simple:
double distance = norm(feature_a, feature_b);
(or train your favourite ml or clustering)
its algorithm works much slower, but with one person the best result