1 | initial version |
probably the best way to do so is using the pretrained openface dnn:
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
...
//Convert Mat to image batch
Mat inputBlob = dnn::blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
net.setInput(inputBlob);
Mat feature = net.forward();
then compare features using simple L2 norm:
double dist = Core.norm(f1,f2);
2 | No.2 Revision |
probably the best way to do so is using the pretrained openface dnn:
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
...
//Convert Mat to image batch
Mat inputBlob = dnn::blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
net.setInput(inputBlob);
Mat feature = net.forward();
then compare the resulting (128 float) features using simple L2 norm:
double dist = Core.norm(f1,f2);
3 | No.3 Revision |
probably the best way to do so is using the pretrained openface dnn:
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
...
//Convert Mat to image batch
Mat inputBlob blob = dnn::blobFromImage(image, dnn::blobFromImage(img, 1./255, new Size(96,96), new Scalar(), true, false);
net.setInput(inputBlob);
net.setInput(blob);
Mat feature = net.forward();
then compare the resulting (128 float) features using simple L2 norm:
double dist = Core.norm(f1,f2);