mirror of
https://github.com/esimov/pigo.git
synced 2025-09-26 20:21:28 +08:00
perf: struct memory alignment
This commit is contained in:
@@ -35,9 +35,6 @@ Go (Golang) Face detection library.
|
||||
|
||||
`
|
||||
|
||||
// messageType is a placeholder for various message types.
|
||||
type messageType int
|
||||
|
||||
// pipeName is the file name that indicates stdin/stdout is being used.
|
||||
const pipeName = "-"
|
||||
|
||||
@@ -69,22 +66,22 @@ var (
|
||||
)
|
||||
|
||||
var (
|
||||
eyeCascades = []string{"lp46", "lp44", "lp42", "lp38", "lp312"}
|
||||
mouthCascades = []string{"lp93", "lp84", "lp82", "lp81"}
|
||||
eyeCascades = [5]string{"lp46", "lp44", "lp42", "lp38", "lp312"}
|
||||
mouthCascades = [4]string{"lp93", "lp84", "lp82", "lp81"}
|
||||
)
|
||||
|
||||
// faceDetector struct contains Pigo face detector general settings.
|
||||
type faceDetector struct {
|
||||
angle float64
|
||||
cascadeFile string
|
||||
destination string
|
||||
puploc string
|
||||
flploc string
|
||||
angle float64
|
||||
minSize int
|
||||
maxSize int
|
||||
shiftFactor float64
|
||||
scaleFactor float64
|
||||
iouThreshold float64
|
||||
puploc string
|
||||
flploc string
|
||||
markDetEyes bool
|
||||
}
|
||||
|
||||
@@ -97,9 +94,9 @@ type coord struct {
|
||||
|
||||
// detection holds the detection points of the various detection types
|
||||
type detection struct {
|
||||
FacePoints coord `json:"face,omitempty"`
|
||||
EyePoints []coord `json:"eyes,omitempty"`
|
||||
LandmarkPoints []coord `json:"landmark_points,omitempty"`
|
||||
FacePoints coord `json:"face,omitempty"`
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
10
core/pigo.go
10
core/pigo.go
@@ -14,11 +14,11 @@ import (
|
||||
// ShiftFactor: determines to what percentage to move the detection window over its size.
|
||||
// ScaleFactor: defines in percentage the resize value of the detection window when moving to a higher scale.
|
||||
type CascadeParams struct {
|
||||
ImageParams
|
||||
MinSize int
|
||||
MaxSize int
|
||||
ShiftFactor float64
|
||||
ScaleFactor float64
|
||||
ImageParams
|
||||
}
|
||||
|
||||
// ImageParams is a struct for image related settings.
|
||||
@@ -35,11 +35,11 @@ type ImageParams struct {
|
||||
|
||||
// Pigo struct defines the basic binary tree components.
|
||||
type Pigo struct {
|
||||
treeDepth uint32
|
||||
treeNum uint32
|
||||
treeCodes []int8
|
||||
treePred []float32
|
||||
treeThreshold []float32
|
||||
treeDepth uint32
|
||||
treeNum uint32
|
||||
}
|
||||
|
||||
// NewPigo initializes the Pigo constructor method.
|
||||
@@ -101,11 +101,11 @@ func (pg *Pigo) Unpack(packet []byte) (*Pigo, error) {
|
||||
}
|
||||
|
||||
return &Pigo{
|
||||
treeDepth,
|
||||
treeNum,
|
||||
treeCodes,
|
||||
treePred,
|
||||
treeThreshold,
|
||||
treeDepth,
|
||||
treeNum,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@@ -21,12 +21,12 @@ type Puploc struct {
|
||||
// PuplocCascade is a general struct for storing
|
||||
// the cascade tree values encoded into the binary file.
|
||||
type PuplocCascade struct {
|
||||
stages uint32
|
||||
scales float32
|
||||
trees uint32
|
||||
treeDepth uint32
|
||||
treeCodes []int8
|
||||
treePreds []float32
|
||||
scales float32
|
||||
stages uint32
|
||||
trees uint32
|
||||
treeDepth uint32
|
||||
}
|
||||
|
||||
// NewPuplocCascade initializes the PuplocCascade constructor method.
|
||||
@@ -237,7 +237,7 @@ var plcPool = sync.Pool{
|
||||
|
||||
// RunDetector runs the pupil localization function.
|
||||
func (plc *PuplocCascade) RunDetector(pl Puploc, img ImageParams, angle float64, flipV bool) *Puploc {
|
||||
var res = make([]float32, 3)
|
||||
var res []float32
|
||||
|
||||
det := plcPool.Get().(*puplocPool)
|
||||
defer plcPool.Put(det)
|
||||
|
Reference in New Issue
Block a user