1 | initial version |
Unfortunately openCV don't contain these classes so how can i get it in java ?
the FaceRecognizer classes are not contained in the prebuild opencv libs (it's not a java problem).
you will have to rebuild your opencv libs with the opencv_contrib repo
(see readme.md for build instructions) then you can just import org.opencv.face
in the meantime, you might also try the new dnn based facerecognition, using a pretrained OpenFace network:
import org.opencv.dnn.*;
// load the pretrained network (only once !) Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7"); // prepare a blob: Mat image = Imgcodecs.imread("face1.png"); // we can use color images here ! Mat inputBlob = Dnn.blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false); // feed it through the network: net.setInput(inputBlob); feature = net.forward(); // a 1x128 float vector
then we can compare features from 2 images, using a simpleL2 norm:
double dist = Core.norm(feature1, feature2);
(or apply your favourite ml technique here)
2 | No.2 Revision |
Unfortunately openCV don't contain these classes so how can i get it in java ?
the FaceRecognizer classes are not contained in the prebuild opencv libs (it's not a java problem).
you will have to rebuild your opencv libs with the opencv_contrib repo . you will need:
python (any version, for the generator)
(see readme.md for build instructions) then you can just import org.opencv.face
in the meantime, you might also try the new dnn based facerecognition, using a pretrained OpenFace network:
you'll need the pretrained facenet dnn model from here (30.1mb):
https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7
import org.opencv.dnn.*; org.opencv.dnn.*;
// load the pretrained network (only once !)
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
// prepare a blob:
Mat image = Imgcodecs.imread("face1.png"); // we can use color images here !
Mat inputBlob = Dnn.blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
// feed it through the network:
net.setInput(inputBlob);
feature = net.forward(); // a 1x128 float vectorvector
then we can compare features from 2 images, using a simpleL2 norm:
double dist = Core.norm(feature1, (or apply your favourite ml technique here)
3 | No.3 Revision |
Unfortunately openCV don't contain these classes so how can i get it in java ?
the FaceRecognizer classes are not contained in the prebuild opencv libs (it's not a java problem). if you want those, you will have to rebuild your opencv libs with the opencv_contrib repo . you will need:
python (any version, for the generator)
(see readme.md for build instructions) then you can just import org.opencv.face
in the meantime, you might also try the new dnn based facerecognition, using a pretrained OpenFace network:
you'll need the pretrained facenet dnn model from here (30.1mb):
https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7
import org.opencv.dnn.*;
// load the pretrained network (only once !)
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
// prepare a blob:
Mat image = Imgcodecs.imread("face1.png"); // we can use color images here !
Mat inputBlob = Dnn.blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
// feed it through the network:
net.setInput(inputBlob);
feature = net.forward(); // a 1x128 float vector
then we can compare features from 2 images, using a simpleL2 norm:
double dist = Core.norm(feature1, feature2);
(or apply your favourite ml technique here)
4 | No.4 Revision |
Unfortunately openCV don't contain these classes so how can i get it in java ?
the FaceRecognizer classes are not contained in the prebuild opencv libs (it's not a java problem). if you want those, you will have to rebuild your opencv libs with the opencv_contrib repo . you will need:
python (any version, for the generator)
(see readme.md for build instructions) then you can just import org.opencv.face
in the meantime, you might also try the new dnn based facerecognition, using a pretrained OpenFace network:
you'll need the pretrained facenet dnn model from here (30.1mb):
https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7
import org.opencv.dnn.*;
// load the pretrained network (only once !)
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
// prepare a blob:
Mat image = Imgcodecs.imread("face1.png"); // we can use color images here !
Mat inputBlob = Dnn.blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
// feed it through the network:
net.setInput(inputBlob);
Mat feature = net.forward(); // a 1x128 float vector
then we can compare features from 2 images, using a simpleL2 norm:
double dist = Core.norm(feature1, feature2);
(or apply your favourite ml technique here)
5 | No.5 Revision |
Unfortunately openCV don't contain these classes so how can i get it in java ?
the FaceRecognizer classes are not contained in the prebuild opencv libs (it's not a java problem). if you want those, you will have to rebuild your opencv libs with the opencv_contrib repo . you will need:
python (any version, for the generator)
(see readme.md for build instructions) then you can just import org.opencv.face
in the meantime, you might also try the new dnn based facerecognition, using a pretrained OpenFace network:
you'll need the pretrained facenet dnn model from here (30.1mb):
https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7
import org.opencv.dnn.*;
// load the pretrained network (only once !)
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
// prepare a blob:
Mat image = Imgcodecs.imread("face1.png"); // we can use color images here !
Mat inputBlob = Dnn.blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
// feed it through the network:
net.setInput(inputBlob);
Mat feature = net.forward(); // a 1x128 float vector
then we can compare features from 2 images, using a simpleL2 simple L2 norm:
double dist = Core.norm(feature1, feature2);
(or apply your favourite ml technique here)
6 | No.6 Revision |
Unfortunately openCV don't contain these classes so how can i get it in java ?
the FaceRecognizer classes are not contained in the prebuild opencv libs (it's not a java problem). if you want those, you will have to rebuild your opencv libs with the opencv_contrib repo . you will need:
python (any version, for the generator)
(see readme.md for build instructions) then you can just import org.opencv.face
in the meantime, you might also try the new dnn based facerecognition, using a pretrained OpenFace network:
you'll need the pretrained facenet dnn model from here (30.1mb):
https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7
import org.opencv.dnn.*;
// load the pretrained network (only once !)
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
// prepare a blob:
Mat image = Imgcodecs.imread("face1.png"); // we can use color images here !
Mat inputBlob = Dnn.blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
// feed it through the network:
net.setInput(inputBlob);
Mat feature = net.forward(); // a 1x128 float vector
then we can compare features from 2 images, using a simple L2 norm:
double dist = Core.norm(feature1, feature2);
(or apply your favourite ml technique here)
7 | No.7 Revision |
Unfortunately openCV don't contain these classes so how can i get it in java ?
the FaceRecognizer classes are not contained in the prebuild opencv libs (it's not a java problem). if you want those, you will have to rebuild your opencv libs with the opencv_contrib repo . you will need:
python (any version, for the generator)
(see readme.md for build instructions) then you can just import org.opencv.face
in the meantime, you might also try the new dnn based facerecognition, using a pretrained OpenFace network:
you'll need the pretrained facenet dnn model from here (30.1mb):
https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7
import org.opencv.dnn.*;
// load the pretrained network (only once !)
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
// prepare a blob:
Mat image = Imgcodecs.imread("face1.png"); // we can use color images here !
Mat inputBlob = Dnn.blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
// feed it through the network:
net.setInput(inputBlob);
Mat feature = net.forward(); // a 1x128 float vector
then we can compare features from 2 images, using a simple L2 norm:
double dist = Core.norm(feature1, feature2);
(or apply your favourite ml technique here)
and here are the docs: https://docs.opencv.org/master/javadoc/index.html
8 | No.8 Revision |
Unfortunately openCV don't contain these classes so how can i get it in java ?
the FaceRecognizer classes are not contained in the prebuild opencv libs (it's not a java problem). if you want those, you will have to rebuild your opencv libs with the opencv_contrib repo . you will need:
python (any version, for the generator)
(see readme.md for build instructions) then you can just import org.opencv.face
in the meantime, you might also try the new dnn based facerecognition, using a pretrained OpenFace network:
you'll need the pretrained facenet dnn model from here (30.1mb):
https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7
import org.opencv.dnn.*;
// load the pretrained network (only once !)
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
// prepare a blob:
Mat image = Imgcodecs.imread("face1.png"); // we can use color images here !
Mat inputBlob = Dnn.blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
// feed it through the network:
net.setInput(inputBlob);
Mat feature = net.forward(); // a 1x128 float vector
then we can compare features from 2 images, using a simple L2 norm:
double dist distance = Core.norm(feature1, feature2);
(or apply your favourite ml technique here)
and here are the docs: https://docs.opencv.org/master/javadoc/index.html
9 | No.9 Revision |
Unfortunately openCV don't contain these classes so how can i get it in java ?
the FaceRecognizer classes are not contained in the prebuild opencv libs (it's not a java problem). if you want those, you will have to rebuild your opencv libs with the opencv_contrib repo . you will need:
python (any version, for the generator)
(see readme.md for build instructions) then you can just import org.opencv.face
in the meantime, you might also try the new dnn based facerecognition, using a pretrained OpenFace network:
you'll need the pretrained facenet dnn model from here (30.1mb):
https://raw.githubusercontent.com/pyannote/pyannote-data/master/openface.nn4.small2.v1.t7
import org.opencv.dnn.*;
// load the pretrained network (only once !)
Net net = Dnn.readNetFromTorch("openface.nn4.small2.v1.t7");
// prepare a blob:
Mat image = Imgcodecs.imread("face1.png"); // we can use color images here !
Mat inputBlob = Dnn.blobFromImage(image, 1./255, new Size(96,96), new Scalar(), true, false);
// feed it through the network:
net.setInput(inputBlob);
Mat feature = net.forward(); net.forward().clone(); // a 1x128 float vector
then we can compare features from 2 images, using a simple L2 norm:
double distance = Core.norm(feature1, feature2);
(or apply your favourite ml technique here)
and here are the docs: https://docs.opencv.org/master/javadoc/index.html