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.
|
// pipeName is the file name that indicates stdin/stdout is being used.
|
||||||
const pipeName = "-"
|
const pipeName = "-"
|
||||||
|
|
||||||
@@ -69,22 +66,22 @@ var (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
eyeCascades = []string{"lp46", "lp44", "lp42", "lp38", "lp312"}
|
eyeCascades = [5]string{"lp46", "lp44", "lp42", "lp38", "lp312"}
|
||||||
mouthCascades = []string{"lp93", "lp84", "lp82", "lp81"}
|
mouthCascades = [4]string{"lp93", "lp84", "lp82", "lp81"}
|
||||||
)
|
)
|
||||||
|
|
||||||
// faceDetector struct contains Pigo face detector general settings.
|
// faceDetector struct contains Pigo face detector general settings.
|
||||||
type faceDetector struct {
|
type faceDetector struct {
|
||||||
angle float64
|
|
||||||
cascadeFile string
|
cascadeFile string
|
||||||
destination string
|
destination string
|
||||||
|
puploc string
|
||||||
|
flploc string
|
||||||
|
angle float64
|
||||||
minSize int
|
minSize int
|
||||||
maxSize int
|
maxSize int
|
||||||
shiftFactor float64
|
shiftFactor float64
|
||||||
scaleFactor float64
|
scaleFactor float64
|
||||||
iouThreshold float64
|
iouThreshold float64
|
||||||
puploc string
|
|
||||||
flploc string
|
|
||||||
markDetEyes bool
|
markDetEyes bool
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -97,9 +94,9 @@ type coord struct {
|
|||||||
|
|
||||||
// detection holds the detection points of the various detection types
|
// detection holds the detection points of the various detection types
|
||||||
type detection struct {
|
type detection struct {
|
||||||
FacePoints coord `json:"face,omitempty"`
|
|
||||||
EyePoints []coord `json:"eyes,omitempty"`
|
EyePoints []coord `json:"eyes,omitempty"`
|
||||||
LandmarkPoints []coord `json:"landmark_points,omitempty"`
|
LandmarkPoints []coord `json:"landmark_points,omitempty"`
|
||||||
|
FacePoints coord `json:"face,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func main() {
|
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.
|
// 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.
|
// ScaleFactor: defines in percentage the resize value of the detection window when moving to a higher scale.
|
||||||
type CascadeParams struct {
|
type CascadeParams struct {
|
||||||
|
ImageParams
|
||||||
MinSize int
|
MinSize int
|
||||||
MaxSize int
|
MaxSize int
|
||||||
ShiftFactor float64
|
ShiftFactor float64
|
||||||
ScaleFactor float64
|
ScaleFactor float64
|
||||||
ImageParams
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ImageParams is a struct for image related settings.
|
// ImageParams is a struct for image related settings.
|
||||||
@@ -35,11 +35,11 @@ type ImageParams struct {
|
|||||||
|
|
||||||
// Pigo struct defines the basic binary tree components.
|
// Pigo struct defines the basic binary tree components.
|
||||||
type Pigo struct {
|
type Pigo struct {
|
||||||
treeDepth uint32
|
|
||||||
treeNum uint32
|
|
||||||
treeCodes []int8
|
treeCodes []int8
|
||||||
treePred []float32
|
treePred []float32
|
||||||
treeThreshold []float32
|
treeThreshold []float32
|
||||||
|
treeDepth uint32
|
||||||
|
treeNum uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPigo initializes the Pigo constructor method.
|
// NewPigo initializes the Pigo constructor method.
|
||||||
@@ -101,11 +101,11 @@ func (pg *Pigo) Unpack(packet []byte) (*Pigo, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return &Pigo{
|
return &Pigo{
|
||||||
treeDepth,
|
|
||||||
treeNum,
|
|
||||||
treeCodes,
|
treeCodes,
|
||||||
treePred,
|
treePred,
|
||||||
treeThreshold,
|
treeThreshold,
|
||||||
|
treeDepth,
|
||||||
|
treeNum,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -21,12 +21,12 @@ type Puploc struct {
|
|||||||
// PuplocCascade is a general struct for storing
|
// PuplocCascade is a general struct for storing
|
||||||
// the cascade tree values encoded into the binary file.
|
// the cascade tree values encoded into the binary file.
|
||||||
type PuplocCascade struct {
|
type PuplocCascade struct {
|
||||||
stages uint32
|
|
||||||
scales float32
|
|
||||||
trees uint32
|
|
||||||
treeDepth uint32
|
|
||||||
treeCodes []int8
|
treeCodes []int8
|
||||||
treePreds []float32
|
treePreds []float32
|
||||||
|
scales float32
|
||||||
|
stages uint32
|
||||||
|
trees uint32
|
||||||
|
treeDepth uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewPuplocCascade initializes the PuplocCascade constructor method.
|
// NewPuplocCascade initializes the PuplocCascade constructor method.
|
||||||
@@ -237,7 +237,7 @@ var plcPool = sync.Pool{
|
|||||||
|
|
||||||
// RunDetector runs the pupil localization function.
|
// RunDetector runs the pupil localization function.
|
||||||
func (plc *PuplocCascade) RunDetector(pl Puploc, img ImageParams, angle float64, flipV bool) *Puploc {
|
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)
|
det := plcPool.Get().(*puplocPool)
|
||||||
defer plcPool.Put(det)
|
defer plcPool.Put(det)
|
||||||
|
Reference in New Issue
Block a user