zhangzengfei
2024-04-18 3c5bc166a563cd851f3e3b5e1a019f7fa0207ab0
fix cycle import
4个文件已修改
38 ■■■■ 已修改文件
compare/compare.go 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
compare/faceSdk.go 17 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
db/person.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
util/util.go 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
compare/compare.go
@@ -2,6 +2,7 @@
import (
    "fmt"
    "sdkCompare/util"
    "strconv"
    "sdkCompare/cache"
@@ -18,7 +19,7 @@
        return nil
    }
    floatFeat := ByteSlice2float32Slice(args.FaceFeature)
    floatFeat := util.ByteSlice2float32Slice(args.FaceFeature)
    //指定最低分
    baseScore := thresholdLimit
compare/faceSdk.go
@@ -1,7 +1,7 @@
package compare
import (
    "unsafe"
    "sdkCompare/util"
)
// #if FEATURE_NORMALIZE
@@ -84,8 +84,8 @@
}
func DecCompare(feat1, feat2 []byte) float32 {
    ffeat1 := ByteSlice2float32Slice(feat1)
    ffeat2 := ByteSlice2float32Slice(feat2)
    ffeat1 := util.ByteSlice2float32Slice(feat1)
    ffeat2 := util.ByteSlice2float32Slice(feat2)
    if len(feat1) != len(feat2) {
        return 0
    }
@@ -105,15 +105,4 @@
    }
    //fmt.Println("score:", score)
    return score
}
func ByteSlice2float32Slice(src []byte) []float32 {
    if len(src) == 0 {
        return nil
    }
    l := len(src) / 4
    ptr := unsafe.Pointer(&src[0])
    return (*[1 << 26]float32)((*[1 << 26]float32)(ptr))[:l:l]
}
db/person.go
@@ -2,7 +2,7 @@
import (
    "encoding/base64"
    "sdkCompare/compare"
    "sdkCompare/util"
    "strconv"
)
@@ -66,7 +66,7 @@
                Id:          p.Id,
                TableId:     p.TableId,
                AreaId:      p.AreaID,
                FaceFeature: compare.ByteSlice2float32Slice(byteFeat),
                FaceFeature: util.ByteSlice2float32Slice(byteFeat),
                Enable:      int32(p.Enable),
            })
        }
@@ -91,7 +91,7 @@
            Id:          p.Id,
            TableId:     p.TableId,
            AreaId:      p.AreaID,
            FaceFeature: compare.ByteSlice2float32Slice(byteFeat),
            FaceFeature: util.ByteSlice2float32Slice(byteFeat),
            Enable:      int32(p.Enable),
        }
    }
util/util.go
@@ -5,6 +5,7 @@
    "errors"
    "net"
    "strconv"
    "unsafe"
)
// 获取本机网卡IP
@@ -70,3 +71,14 @@
    }
    return c == len(arr)
}
func ByteSlice2float32Slice(src []byte) []float32 {
    if len(src) == 0 {
        return nil
    }
    l := len(src) / 4
    ptr := unsafe.Pointer(&src[0])
    return (*[1 << 26]float32)((*[1 << 26]float32)(ptr))[:l:l]
}