mirror of
https://github.com/esimov/pigo.git
synced 2025-12-24 12:48:04 +08:00
core: replacing custom sorting function with sort.Slice
This commit is contained in:
13
core/pigo.go
13
core/pigo.go
@@ -261,7 +261,9 @@ func (pg *Pigo) RunCascade(cp CascadeParams, angle float64) []Detection {
|
||||
// We need to make this comparison to filter out multiple face detection regions.
|
||||
func (pg *Pigo) ClusterDetections(detections []Detection, iouThreshold float64) []Detection {
|
||||
// Sort detections by their score
|
||||
sort.Sort(det(detections))
|
||||
sort.Slice(detections, func(i, j int) bool {
|
||||
return detections[i].Q < detections[j].Q
|
||||
})
|
||||
|
||||
calcIoU := func(det1, det2 Detection) float64 {
|
||||
// Unpack the position and size of each detection.
|
||||
@@ -304,12 +306,3 @@ func (pg *Pigo) ClusterDetections(detections []Detection, iouThreshold float64)
|
||||
}
|
||||
return clusters
|
||||
}
|
||||
|
||||
// Implement sorting function on detection values.
|
||||
type det []Detection
|
||||
|
||||
func (q det) Len() int { return len(q) }
|
||||
func (q det) Swap(i, j int) { q[i], q[j] = q[j], q[i] }
|
||||
func (q det) Less(i, j int) bool {
|
||||
return q[i].Q < q[j].Q
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user