Documentation ¶
Overview ¶
Package face implements face recognition for Go using dlib, a popular machine learning toolkit.
Index ¶
- func SquaredEuclideanDistance(d1 Descriptor, d2 Descriptor) (sum float64)
- type Descriptor
- type Face
- type Gender
- type ImageLoadError
- type Recognizer
- func (rec *Recognizer) Classify(testSample Descriptor) int
- func (rec *Recognizer) ClassifyThreshold(testSample Descriptor, tolerance float32) int
- func (rec *Recognizer) Close()
- func (rec *Recognizer) DetectFromBuffer(imgData []byte) (faces []Face, err error)
- func (rec *Recognizer) DetectFromBufferCNN(imgData []byte) (faces []Face, err error)
- func (rec *Recognizer) DetectFromBufferCustom(imgData []byte) (faces []Face, err error)
- func (rec *Recognizer) DetectFromFile(imgPath string) (faces []Face, err error)
- func (rec *Recognizer) DetectFromFileCNN(imgPath string) (faces []Face, err error)
- func (rec *Recognizer) DetectFromFileCustom(imgPath string) (faces []Face, err error)
- func (rec *Recognizer) GetAge(face *Face)
- func (rec *Recognizer) GetGender(face *Face)
- func (rec *Recognizer) Recognize(face *Face) error
- func (rec *Recognizer) SetAgeModel(agePath string) (err error)
- func (rec *Recognizer) SetCNNModel(cnnResnetPath string) (err error)
- func (rec *Recognizer) SetCustomModel(cnnResnetPath string) (err error)
- func (rec *Recognizer) SetDescriptorModel(resnetPath string) (err error)
- func (rec *Recognizer) SetGenderModel(genderPath string) (err error)
- func (rec *Recognizer) SetJittering(jittering int)
- func (rec *Recognizer) SetMinImageSize(minImageSize int)
- func (rec *Recognizer) SetPadding(padding float32)
- func (rec *Recognizer) SetSamples(samples []Descriptor, cats []int32)
- func (rec *Recognizer) SetShapeModel(shapePredictorPath string) (err error)
- func (rec *Recognizer) SetSize(size int)
- type SerializationError
- type Tracker
- func (tracker *Tracker) Close()
- func (tracker *Tracker) Position() (rect image.Rectangle, err error)
- func (tracker *Tracker) StartBuffer(imgData []byte, rect image.Rectangle) (err error)
- func (tracker *Tracker) StartFile(file string, rect image.Rectangle) (err error)
- func (tracker *Tracker) UpdateBuffer(imgData []byte) (confidence float32, err error)
- func (tracker *Tracker) UpdateFile(file string) (confidence float32, err error)
- type UnknownError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SquaredEuclideanDistance ¶
func SquaredEuclideanDistance(d1 Descriptor, d2 Descriptor) (sum float64)
Types ¶
type Face ¶
type Face struct { Rectangle image.Rectangle Descriptor Descriptor Shapes []image.Point Gender Gender Age int // contains filtered or unexported fields }
Face holds coordinates and descriptor of the human face.
func New ¶
func New(r image.Rectangle, d Descriptor) Face
New creates new face with the provided parameters.
func NewWithShape ¶
type ImageLoadError ¶
type ImageLoadError string
An ImageLoadError is returned when provided image file is corrupted.
func (ImageLoadError) Error ¶
func (e ImageLoadError) Error() string
type Recognizer ¶
type Recognizer struct {
// contains filtered or unexported fields
}
A Recognizer creates face descriptors for provided images and classifies them into categories.
func NewRecognizer ¶
func NewRecognizer() (rec *Recognizer, err error)
NewRecognizer returns a new recognizer interface. modelDir points to directory with shape_predictor_5_face_landmarks.dat and dlib_face_recognition_resnet_model_v1.dat files.
func (*Recognizer) Classify ¶
func (rec *Recognizer) Classify(testSample Descriptor) int
Classify returns class ID for the given descriptor. Negative index is returned if no match. Thread-safe.
func (*Recognizer) ClassifyThreshold ¶
func (rec *Recognizer) ClassifyThreshold(testSample Descriptor, tolerance float32) int
Same as Classify but allows to specify max distance between faces to consider it a match. Start with 0.6 if not sure.
func (*Recognizer) Close ¶
func (rec *Recognizer) Close()
Close frees resources taken by the Recognizer. Safe to call multiple times. Don't use Recognizer after close call.
func (*Recognizer) DetectFromBuffer ¶
func (rec *Recognizer) DetectFromBuffer(imgData []byte) (faces []Face, err error)
Detect returns all faces found on the provided image, sorted from left to right. Empty list is returned if there are no faces, error is returned if there was some error while decoding/processing image. Only JPEG format is currently supported. Thread-safe.
func (*Recognizer) DetectFromBufferCNN ¶
func (rec *Recognizer) DetectFromBufferCNN(imgData []byte) (faces []Face, err error)
func (*Recognizer) DetectFromBufferCustom ¶
func (rec *Recognizer) DetectFromBufferCustom(imgData []byte) (faces []Face, err error)
func (*Recognizer) DetectFromFile ¶
func (rec *Recognizer) DetectFromFile(imgPath string) (faces []Face, err error)
Same as Recognize but accepts image path instead.
func (*Recognizer) DetectFromFileCNN ¶
func (rec *Recognizer) DetectFromFileCNN(imgPath string) (faces []Face, err error)
func (*Recognizer) DetectFromFileCustom ¶
func (rec *Recognizer) DetectFromFileCustom(imgPath string) (faces []Face, err error)
func (*Recognizer) GetAge ¶
func (rec *Recognizer) GetAge(face *Face)
func (*Recognizer) GetGender ¶
func (rec *Recognizer) GetGender(face *Face)
func (*Recognizer) Recognize ¶
func (rec *Recognizer) Recognize(face *Face) error
func (*Recognizer) SetAgeModel ¶
func (rec *Recognizer) SetAgeModel(agePath string) (err error)
func (*Recognizer) SetCNNModel ¶
func (rec *Recognizer) SetCNNModel(cnnResnetPath string) (err error)
func (*Recognizer) SetCustomModel ¶
func (rec *Recognizer) SetCustomModel(cnnResnetPath string) (err error)
func (*Recognizer) SetDescriptorModel ¶
func (rec *Recognizer) SetDescriptorModel(resnetPath string) (err error)
func (*Recognizer) SetGenderModel ¶
func (rec *Recognizer) SetGenderModel(genderPath string) (err error)
func (*Recognizer) SetJittering ¶
func (rec *Recognizer) SetJittering(jittering int)
func (*Recognizer) SetMinImageSize ¶
func (rec *Recognizer) SetMinImageSize(minImageSize int)
func (*Recognizer) SetPadding ¶
func (rec *Recognizer) SetPadding(padding float32)
func (*Recognizer) SetSamples ¶
func (rec *Recognizer) SetSamples(samples []Descriptor, cats []int32)
SetSamples sets known descriptors so you can classify the new ones. Thread-safe.
func (*Recognizer) SetShapeModel ¶
func (rec *Recognizer) SetShapeModel(shapePredictorPath string) (err error)
func (*Recognizer) SetSize ¶
func (rec *Recognizer) SetSize(size int)
type SerializationError ¶
type SerializationError string
An SerializationError is returned when provided model is corrupted.
func (SerializationError) Error ¶
func (e SerializationError) Error() string
type Tracker ¶
type Tracker struct {
// contains filtered or unexported fields
}
func NewTracker ¶
func (*Tracker) StartBuffer ¶
func (*Tracker) UpdateBuffer ¶
type UnknownError ¶
type UnknownError string
An UnknownError represents some nonclassified error.
func (UnknownError) Error ¶
func (e UnknownError) Error() string