mirror of
https://github.com/esimov/pigo.git
synced 2025-11-02 20:24:02 +08:00
Extend flploc benchmark tests
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
p = pigo.NewPigo()
|
||||
pigoCascade []byte
|
||||
srcImg *image.NRGBA
|
||||
)
|
||||
@@ -47,6 +48,43 @@ func init() {
|
||||
}
|
||||
}
|
||||
|
||||
func TestPigo_UnpackCascadeFileShouldNotBeNil(t *testing.T) {
|
||||
var (
|
||||
err error
|
||||
pigo = pigo.NewPigo()
|
||||
)
|
||||
p, err = pigo.Unpack(pigoCascade)
|
||||
if err != nil {
|
||||
t.Fatalf("failed unpacking the cascade file: %v", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestPigo_InputImageShouldBeGrayscale(t *testing.T) {
|
||||
// Since an image converted grayscale has only one channel,we should assume
|
||||
// that the grayscale image array length is the source image length / 4.
|
||||
if len(imgParams.Pixels) != len(srcImg.Pix)/4 {
|
||||
t.Fatalf("the source image should be converted to grayscale")
|
||||
}
|
||||
}
|
||||
|
||||
func TestPigo_Detector_ShouldDetectFace(t *testing.T) {
|
||||
// Unpack the binary file. This will return the number of cascade trees,
|
||||
// the tree depth, the threshold and the prediction from tree's leaf nodes.
|
||||
classifier, err := p.Unpack(pigoCascade)
|
||||
if err != nil {
|
||||
t.Fatalf("error reading the cascade file: %s", err)
|
||||
}
|
||||
|
||||
// Run the classifier over the obtained leaf nodes and return the detection results.
|
||||
// The result contains quadruplets representing the row, column, scale and detection score.
|
||||
faces := classifier.RunCascade(*cParams, 0.0)
|
||||
// Calculate the intersection over union (IoU) of two clusters.
|
||||
faces = classifier.ClusterDetections(faces, 0.1)
|
||||
if len(faces) == 0 {
|
||||
t.Fatalf("should have been detected eyes: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
func BenchmarkPigo(b *testing.B) {
|
||||
pg := pigo.NewPigo()
|
||||
// Unpack the binary file. This will return the number of cascade trees,
|
||||
|
||||
Reference in New Issue
Block a user