| | |
| | | |
| | | import ( |
| | | "fmt" |
| | | "sdkCompare/util" |
| | | "strconv" |
| | | |
| | | "sdkCompare/cache" |
| | |
| | | return nil |
| | | } |
| | | |
| | | floatFeat := ByteSlice2float32Slice(args.FaceFeature) |
| | | floatFeat := util.ByteSlice2float32Slice(args.FaceFeature) |
| | | |
| | | //指定最低分 |
| | | baseScore := thresholdLimit |
| | |
| | | package compare |
| | | |
| | | import ( |
| | | "unsafe" |
| | | "sdkCompare/util" |
| | | ) |
| | | |
| | | // #if FEATURE_NORMALIZE |
| | |
| | | } |
| | | |
| | | 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 |
| | | } |
| | |
| | | } |
| | | //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] |
| | | } |
| | |
| | | |
| | | import ( |
| | | "encoding/base64" |
| | | "sdkCompare/compare" |
| | | "sdkCompare/util" |
| | | "strconv" |
| | | ) |
| | | |
| | |
| | | Id: p.Id, |
| | | TableId: p.TableId, |
| | | AreaId: p.AreaID, |
| | | FaceFeature: compare.ByteSlice2float32Slice(byteFeat), |
| | | FaceFeature: util.ByteSlice2float32Slice(byteFeat), |
| | | Enable: int32(p.Enable), |
| | | }) |
| | | } |
| | |
| | | Id: p.Id, |
| | | TableId: p.TableId, |
| | | AreaId: p.AreaID, |
| | | FaceFeature: compare.ByteSlice2float32Slice(byteFeat), |
| | | FaceFeature: util.ByteSlice2float32Slice(byteFeat), |
| | | Enable: int32(p.Enable), |
| | | } |
| | | } |
| | |
| | | "errors" |
| | | "net" |
| | | "strconv" |
| | | "unsafe" |
| | | ) |
| | | |
| | | // 获取本机网卡IP |
| | |
| | | } |
| | | 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] |
| | | } |