face

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 10, 2021 License: MIT Imports: 6 Imported by: 3

README

face

Face detection and recognition using dlib and gocv in Go.

Inspired by github.com/Kagami/go-face.

License

face is licensed under MIT.

Documentation

Index

Constants

View Source
const DescriptorSize = 128

DescriptorSize is a face descriptor size.

Variables

This section is empty.

Functions

This section is empty.

Types

type Descriptor

type Descriptor [DescriptorSize]float32

Descriptor is a face descriptor.

type Detection

type Detection struct {
	Rectangle  image.Rectangle
	Confidence float64
}

Detection is a one face detection on image.

type Detector

type Detector struct {
	// contains filtered or unexported fields
}

Detector is a face detector. It utilizes dlib's CNN face detector. Can detect faces on single image or on multiple images (batch detect).

func NewDetector

func NewDetector(modelFilePath string) (*Detector, error)

NewDetector creates new detector using given model file path. Model file path should be path to mmod_human_face_detector.dat file from https://github.com/davisking/dlib-models.

func (*Detector) BatchDetect

func (d *Detector) BatchDetect(imgs []gocv.Mat) ([][]Detection, error)

BatchDetect takes images imgs and tries to detect faces on them. Image sizes should be the same. Each array of detections from returned array corresponds to input image with the same index.

func (*Detector) Close

func (d *Detector) Close()

Close frees allocated detector object.

func (*Detector) Detect

func (d *Detector) Detect(img gocv.Mat) ([]Detection, error)

Detect takes image img and tries to detect faces on it.

type Recognizer

type Recognizer struct {
	// contains filtered or unexported fields
}

Recognizer is face recognizer. Doesn't recognize faces actually but computes face descriptors which can be compared later. Utilizes dlib's face recognition model and face shape predictor.

func NewRecognizer

func NewRecognizer(shaperModelFilePath, recognizerModelFilePath string) (*Recognizer, error)

NewRecognizer creates new recognizer using given models. shaperModelFilePath should be a path to shape_predictor_68_face_landmarks.dat file and recognizerModelFilePath should be a path to dlib_face_recognition_resnet_model_v1.dat file. All this files are available in https://github.com/davisking/dlib-models.

func (*Recognizer) Close

func (r *Recognizer) Close()

Close frees allocated recognizer objects.

func (*Recognizer) Recognize

func (r *Recognizer) Recognize(img gocv.Mat, faceLocation image.Rectangle, padding float64, jittering int) (d Descriptor, err error)

Recognize performs face vectorization process on given image img, face location faceLocation and with given params padding and jittering.

Directories

Path Synopsis
example

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL