remove if condition

This commit is contained in:
Endre Simo
2019-02-06 16:18:04 +02:00
parent 57f26c8d4a
commit 747334f841
2 changed files with 23 additions and 25 deletions

View File

@@ -34,38 +34,36 @@ func FindFaces(pixels []uint8) uintptr {
}
}
if len(result) > 0 {
// Since we cannot transfer a 2d array trough an array pointer
// we have to transform it into 1d array.
go func() {
det := make([]int, 0, len(result))
for _, v := range result {
det = append(det, v...)
}
fmt.Println(det)
// Include as a first slice element the number of detected faces.
// We need to transfer this value in order to define the Python array buffer length.
det = append([]int{len(result), 0, 0}, det...)
// Since in Go we cannot transfer a 2d array trough an array pointer
// we have to transform it into 1d array.
go func() {
det := make([]int, 0, len(result))
for _, v := range result {
det = append(det, v...)
}
fmt.Println(det)
// Include as a first slice element the number of detected faces.
// We need to transfer this value in order to define the Python array buffer length.
det = append([]int{len(result), 0, 0}, det...)
// Convert the slice into an array pointer.
s := *(*[]int)(unsafe.Pointer(&det))
p := uintptr(unsafe.Pointer(&s[0]))
// Convert the slice into an array pointer.
s := *(*[]int)(unsafe.Pointer(&det))
p := uintptr(unsafe.Pointer(&s[0]))
// Ensure `det` is not freed up by GC prematurely.
runtime.KeepAlive(det)
// return the pointer address
pointCh <- p
}()
return <-pointCh
}
return 0
// Ensure `det` is not freed up by GC prematurely.
runtime.KeepAlive(det)
// return the pointer address
pointCh <- p
}()
return <-pointCh
}
// clusterDetection runs Pigo face detector core methods
// and returns a cluster with the detected faces coordinates.
func clusterDetection(pixels []uint8, rows, cols int) []pigo.Detection {
cParams := pigo.CascadeParams{
MinSize: 100,
MinSize: 20,
MaxSize: 1000,
ShiftFactor: 0.15,
ScaleFactor: 1.1,