mirror of
https://github.com/dev6699/face.git
synced 2025-09-26 13:11:27 +08:00
68 lines
1.5 KiB
Go
68 lines
1.5 KiB
Go
package _2dfan4
|
|
|
|
import (
|
|
"github.com/dev6699/face/model"
|
|
"gocv.io/x/gocv"
|
|
)
|
|
|
|
type Model struct {
|
|
affineMatrix gocv.Mat
|
|
}
|
|
|
|
type Input struct {
|
|
Img gocv.Mat
|
|
BoundingBox model.BoundingBox
|
|
// ApplyContrastEnhancement allows toggling this feature on/off.
|
|
// NOTE: Enabling this will slow down processing because it performs extra color conversions and CLAHE.
|
|
ApplyContrastEnhancement bool
|
|
// BrightnessThreshold defines how dark the image can be before we apply contrast enhancement.
|
|
// Suggested value: 30.0 for low-light detection.
|
|
// Typical LAB L-channel values range from 0 to 100.
|
|
BrightnessThreshold float64
|
|
// ClaheClipLimit controls how much CLAHE enhances contrast.
|
|
// Suggested value: 2.0 for a balanced effect without over-enhancement.
|
|
// Higher values = more aggressive contrast stretching. Typical values: 2.0 to 4.0.
|
|
ClaheClipLimit float32
|
|
}
|
|
|
|
type Output struct {
|
|
FaceLandmark68 FaceLandmark68
|
|
FaceLandmark68Score float64
|
|
}
|
|
|
|
type FaceLandmark68 struct {
|
|
Data []gocv.Point2f
|
|
}
|
|
|
|
func (f *FaceLandmark68) ToLandmark5() []gocv.Point2f {
|
|
return []gocv.Point2f{
|
|
model.CalculateMean2f(f.Data[36:42]),
|
|
model.CalculateMean2f(f.Data[42:48]),
|
|
f.Data[30],
|
|
f.Data[48],
|
|
f.Data[54],
|
|
}
|
|
}
|
|
|
|
type TModel = model.Model[*Input, *Output]
|
|
|
|
var _ TModel = &Model{}
|
|
|
|
func NewFactory() func() TModel {
|
|
return func() TModel {
|
|
return New()
|
|
}
|
|
}
|
|
|
|
func New() *Model {
|
|
return &Model{}
|
|
}
|
|
|
|
func (m *Model) ModelName() string {
|
|
return "2dfan4"
|
|
}
|
|
|
|
func (m *Model) ModelVersion() string {
|
|
return "1"
|
|
}
|