FACE - Type of DetectedFacePERSON - Type representing a personpublic class FaceRecognitionEngine<FACE extends DetectedFace,PERSON> extends Object implements ReadWriteableBinary
FaceRecognitionEngine ties together the implementations of a
FaceDetector and FaceRecogniser, and provides a single
convenience API with which to interact with a face recognition system.| Modifier and Type | Field and Description |
|---|---|
protected FaceDetector<FACE,FImage> |
detector |
protected FaceRecogniser<FACE,PERSON> |
recogniser |
| Modifier | Constructor and Description |
|---|---|
protected |
FaceRecognitionEngine() |
|
FaceRecognitionEngine(FaceDetector<FACE,FImage> detector,
FaceRecogniser<FACE,PERSON> recogniser)
Construct a
FaceRecognitionEngine with the given face detector
and recogniser. |
| Modifier and Type | Method and Description |
|---|---|
byte[] |
binaryHeader()
Header for binary input.
|
static <FACE extends DetectedFace,EXTRACTOR extends FeatureExtractor<?,FACE>,PERSON> |
create(FaceDetector<FACE,FImage> detector,
FaceRecogniser<FACE,PERSON> recogniser)
Create a
FaceRecognitionEngine with the given face detector and
recogniser. |
FaceDetector<FACE,FImage> |
getDetector() |
FaceRecogniser<FACE,PERSON> |
getRecogniser() |
static <O extends DetectedFace,P> |
load(File file)
Load a
FaceRecognitionEngine previously saved by
save(File). |
void |
readBinary(DataInput in)
Read internal state from in.
|
List<IndependentPair<FACE,List<ScoredAnnotation<PERSON>>>> |
recognise(FImage image)
Detect and recognise the faces in the given image, returning a list of
potential people for each face.
|
List<IndependentPair<FACE,List<ScoredAnnotation<PERSON>>>> |
recognise(FImage image,
Set<PERSON> restrict)
Detect and recognise the faces in the given image, returning a list of
potential people for each face.
|
List<IndependentPair<FACE,ScoredAnnotation<PERSON>>> |
recogniseBest(FImage image)
Detect and recognise the faces in the given image, returning the most
likely person for each face.
|
List<IndependentPair<FACE,ScoredAnnotation<PERSON>>> |
recogniseBest(FImage image,
Set<PERSON> restrict)
Detect and recognise the faces in the given image, returning the most
likely person for each face.
|
void |
save(File file)
Save the
FaceRecognitionEngine to a file, including all the
internal state of the recogniser, etc. |
FACE |
train(FACE face,
PERSON person)
Train for the given face patch without doing any face detection.
|
void |
train(GroupedDataset<PERSON,ListDataset<FImage>,FImage> dataset)
Train with a dataset
|
FACE |
train(PERSON person,
FImage image)
Train the recogniser with a single example, returning the detected face.
|
void |
writeBinary(DataOutput out)
Write the content of this as binary to out.
|
protected FaceDetector<FACE extends DetectedFace,FImage> detector
protected FaceRecogniser<FACE extends DetectedFace,PERSON> recogniser
protected FaceRecognitionEngine()
public FaceRecognitionEngine(FaceDetector<FACE,FImage> detector, FaceRecogniser<FACE,PERSON> recogniser)
FaceRecognitionEngine with the given face detector
and recogniser.detector - the face detectorrecogniser - the face recogniserpublic static <FACE extends DetectedFace,EXTRACTOR extends FeatureExtractor<?,FACE>,PERSON> FaceRecognitionEngine<FACE,PERSON> create(FaceDetector<FACE,FImage> detector, FaceRecogniser<FACE,PERSON> recogniser)
FaceRecognitionEngine with the given face detector and
recogniser.FACE - Type of DetectedFaceEXTRACTOR - Type of FeatureExtractorPERSON - Type representing a persondetector - the face detectorrecogniser - the face recogniserFaceRecognitionEnginepublic FaceDetector<FACE,FImage> getDetector()
public FaceRecogniser<FACE,PERSON> getRecogniser()
public void save(File file) throws IOException
FaceRecognitionEngine to a file, including all the
internal state of the recogniser, etc.file - the file to save toIOException - if an error occurs when writingpublic static <O extends DetectedFace,P> FaceRecognitionEngine<O,P> load(File file) throws IOException
FaceRecognitionEngine previously saved by
save(File).O - Type of DetectedFaceP - Type representing a personfile - the file to read fromIOException - if an error occurs during the readpublic void train(GroupedDataset<PERSON,ListDataset<FImage>,FImage> dataset)
dataset - the datasetpublic FACE train(PERSON person, FImage image)
If you need more control, consider calling getDetector() to get
a detector which you can apply to your image and getRecogniser()
to get the recogniser which you can train with the detections directly.
person - the personimage - the image with the persons facepublic FACE train(FACE face, PERSON person)
face - The detected face implementationperson - The person to whom this face belongspublic List<IndependentPair<FACE,List<ScoredAnnotation<PERSON>>>> recognise(FImage image)
image - the imagepublic List<IndependentPair<FACE,ScoredAnnotation<PERSON>>> recogniseBest(FImage image)
image - the imagepublic List<IndependentPair<FACE,List<ScoredAnnotation<PERSON>>>> recognise(FImage image, Set<PERSON> restrict)
image - the imagerestrict - set of people to restrict topublic List<IndependentPair<FACE,ScoredAnnotation<PERSON>>> recogniseBest(FImage image, Set<PERSON> restrict)
image - the imagerestrict - set of people to restrict topublic void readBinary(DataInput in) throws IOException
ReadableBinaryreadBinary in interface ReadableBinaryin - source to read from.IOException - an error reading inputpublic byte[] binaryHeader()
ReadableBinarybinaryHeader in interface ReadableBinarybinaryHeader in interface WriteableBinarypublic void writeBinary(DataOutput out) throws IOException
WriteableBinarywriteBinary in interface WriteableBinaryout - sink to write toIOException - an error writing to out