From 0d5aa709503ad0cb03c0c71a5fc23b5174f4fb50 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期二, 19 十一月 2019 11:51:53 +0800
Subject: [PATCH] ---
---
ruleserver/readyDataForRule.go | 88 +++++++++-----------------------------------
1 files changed, 18 insertions(+), 70 deletions(-)
diff --git a/ruleserver/readyDataForRule.go b/ruleserver/readyDataForRule.go
index ec483a8..033a2b3 100644
--- a/ruleserver/readyDataForRule.go
+++ b/ruleserver/readyDataForRule.go
@@ -3,17 +3,18 @@
import (
"basic.com/dbapi.git"
"basic.com/pubsub/protomsg.git"
+ "basic.com/valib/logger.git"
"encoding/json"
"errors"
"fmt"
"github.com/golang/protobuf/proto"
+ uuid "github.com/satori/go.uuid"
"math"
"nanomsg.org/go-mangos"
"nanomsg.org/go-mangos/protocol/req"
"nanomsg.org/go-mangos/transport/tcp"
"net"
"ruleprocess/cache"
- "ruleprocess/logger"
"ruleprocess/structure"
"strconv"
"time"
@@ -31,8 +32,6 @@
}
func Init() {
- //logger.Debug("鏈満淇℃伅鍜宻erver淇℃伅锛�", localConfig, serverIp, serverPort)
- //bigCache.Init(dbTablePersons, serverIp, serverPort, localConfig.ServerId)
go Push1()
}
@@ -63,7 +62,6 @@
taskGroup = task
}
}
- logger.Debug("褰撳墠鏁版嵁甯ц鍖归厤鐨勮鍒欑粍锛�-------------------------","鎽勫儚鏈篿d:",cameraId,"浠诲姟id",taskId)
if taskGroup == nil {
return nil
} else {
@@ -78,7 +76,7 @@
func GetPolygons(cameraId string) []protomsg.CameraPolygon {
var cameraPolygons []protomsg.CameraPolygon
cameraPolygons = cache.GetPolygonsByCameraId(cameraId)
- logger.Debug("------=======鏌ョ湅涓嬪叏閮ㄥ尯鍩燂細",cameraPolygons)
+ //logger.Debug("------=======鏌ョ湅涓嬪叏閮ㄥ尯鍩燂細",cameraPolygons)
return cameraPolygons
}
@@ -89,58 +87,22 @@
}
func Decimal(value float32) float64 {
value1, _ := strconv.ParseFloat(fmt.Sprintf("%.2f", float64(value)), 64)
- logger.Info("鍒濇淇濈暀涓や綅鎴恠tr:",value1)
+ //logger.Info("鍒濇淇濈暀涓や綅鎴恠tr:",value1)
n10 := math.Pow10(4)
value2 := math.Trunc((value1+0.5/n10)*n10) / n10
- logger.Info("鍒濇淇濈暀涓や綅鎴恠tr::::",value2)
+ //logger.Info("鍒濇淇濈暀涓や綅鎴恠tr::::",value2)
return value2
-}
-// 鍙栧嚭鏌愪釜鏃堕棿瑙勫垯鐨勭鍑犲ぉ鐨勮鍒欐闆嗗悎
-func GetTimeById(id string, index int) []TimeRange {
- _, cameraTimeRule := cache.GetTimeRuleById(id)
- var timeRangeList []day
- err := json.Unmarshal([]byte(cameraTimeRule.TimeRule), &timeRangeList)
- if err != nil {
- logger.Error("鍙栨椂闂磋鍒欐椂鍙嶅簭鍒楀寲閿欒锛�")
- }
- for _, timerange := range timeRangeList {
- if timerange.Day == index {
- //logger.Println("鍙栧埌鐨勬椂闂磋鍒欙細", timerange.TimeRange)
- return timerange.TimeRange
- }
- }
- return nil
-}
-
-// 鏍规嵁浼犲叆鐨勫瓧绗︿覆寰楀埌鍏跺湪涓�鍛ㄥ唴鐨勭储寮� 鍛ㄤ竴鍒板懆鏃ュ垎鍒搴�1鍒�7
-func getIndexOfWeek(weekday string) int {
- var weekdays = [7]string{"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"}
- for k, value := range weekdays {
- if value == weekday {
- return k + 1 // 鍥犱负鏁版嵁搴撲腑瀛樼殑鏄�1-7浠h〃鐨勫懆涓�鍒板懆鏃�
- }
- }
- return 0
-}
-
-type TimeRange struct {
- Start string `json:"start"`
- End string `json:"end"`
-}
-type day struct {
- Day int `json:"day"` // 鏍囩ず褰撳墠鏄熸湡鍑�
- TimeRange []TimeRange `json:"time_range"` // 褰撳ぉ鐨勫嚑涓椂闂存
}
// 灏嗗瓧绗︿覆鏍煎紡鐨勫潗鏍囧簭鍒楀寲涓篜oint鏍煎紡
-func Json2points(areaPoints string) []Point {
- var pts []Point
+func Json2points(areaPoints string) []structure.Point {
+ var pts []structure.Point
if areaPoints == "[]" || areaPoints == "" {
logger.Error("=====================姝ゅ尯鍩熶负鍏ㄩ儴鍖哄煙")
- pts = append(pts, Point{0, 0})
- pts = append(pts, Point{0, 540})
- pts = append(pts, Point{960, 540})
- pts = append(pts, Point{960, 0})
+ pts = append(pts, structure.Point{0, 0})
+ pts = append(pts, structure.Point{0, 540})
+ pts = append(pts, structure.Point{960, 540})
+ pts = append(pts, structure.Point{960, 0})
} else {
err := json.Unmarshal([]byte(areaPoints), &pts)
if err != nil {
@@ -162,7 +124,6 @@
}
bytes := getCompareMsg(comArg)
- //bytes := []byte{}
var scResult protomsg.SdkCompareResult
err1 := proto.Unmarshal(bytes, &scResult)
if err1 != nil {
@@ -197,7 +158,7 @@
logger.Error("鏍规嵁id鏌ヨ搴曞簱淇℃伅鍑洪敊锛�", err, "--杩斿洖鍊奸暱搴︿负锛�", len(table))
}
logger.Debug("鐪嬬湅杩欎釜base鐨勫姣斿�兼槸澶氬皯锛�", Decimal(m[baseinfo.Id].CompareScore))
- base := structure.BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id].CompareScore), PersonId: baseinfo.Id, PersonName: baseinfo.PersonName, PersonPicUrl: baseinfo.PersonPicUrl, PhoneNum: baseinfo.PhoneNum, Sex: baseinfo.Sex, IdCard: baseinfo.IdCard, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved}
+ base := structure.BaseInfo{TableId: baseinfo.TableId, TableName: table[0].TableName, BwType: table[0].BwType, CompareScore: Decimal(m[baseinfo.Id].CompareScore), TargetId: baseinfo.Id, TargetName: baseinfo.PersonName, TargetPicUrl: baseinfo.PersonPicUrl, MonitorLevel: baseinfo.MonitorLevel, Content: baseinfo.Reserved,DbLabel: baseinfo.PhoneNum+"/"+baseinfo.Sex+"/"+baseinfo.IdCard,}
//os.Exit(1)
arg.Liker = append(arg.Liker, &base)
}
@@ -247,14 +208,6 @@
//logger.Info("--------------鐪嬬湅compareFlag鐨勫�煎拰tableId鍜宎reaMap.args鐨勯暱搴︼細",compareFlag,tableIds,len(areaMap.args))
for _, arg := range areaMap.Args {
arg.Liker = arg.Liker[0:0]
- //logger.Info("娓呯┖涔嬪悗鐪嬬湅涔嬪墠鎵撶殑浜鸿劯鏍囩鍙樹簡娌★細")
- //if args.RuleResult["face"] != nil && len(args.RuleResult["face"].([]FaceResult)) > 0 {
- // for _, faceResult := range args.RuleResult["face"].([]FaceResult) {
- // for _,arg := range faceResult.Args {
- // logger.Info("浜哄憳鍒嗗�兼槸锛�",arg.Score,"liker鐨勬暟閲忎负",arg.Liker)
- // }
- // }
- //}
if compareFlag == 1 {
fillLiker(nil, threshold, arg)
}
@@ -280,31 +233,27 @@
a.TargetNum = 0
threshold := 80.0 // 鐩镐技搴�
- intersectionper := 0.2 // 鍗犳瘮
+ intersectionper := 20.0 // 鍗犳瘮
size := 0.0 // 灏哄
areaPoints := Json2points(a.AreaJson)
logger.Info("鐪嬬湅鍥剧墖鐨剋idth鍜宧eight:",arg.ImageWidth,arg.ImageHeight)
- widthScale := float64(arg.ImageWidth / 960)
- heigthScale := float64(arg.ImageHeight / 540)
+ widthScale := float64(arg.ImageWidth) / 960
+ heigthScale := float64(arg.ImageHeight) / 540
for _, obj := range arg.Photo {
//logger.Info("------------------鐪嬬湅sdkData:", arg.SdkName, "鐨凱hoto鏁版嵁----------------", obj, "----椤轰究鐪嬬湅鍗犳瘮-----锛�", PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale))
- if threshold <= obj.Score && size <= float64(obj.Rects.Width*obj.Rects.Height) && intersectionper <= PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale) {
+ if obj.Score >= threshold && float64(obj.Rects.Width*obj.Rects.Height) >= size && PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale) >= intersectionper {
// 杩欐瑕佸榻愯〃杈惧紡閲屾墍闇�瑕佺殑鎵�鏈夊弬鏁�
a.TargetNum++
- arg1 := structure.Arg{obj.Id,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), obj.IsYolo, obj.Rects, obj.Feature, obj.ThftRes, []*structure.BaseInfo{}}
+ uuid := uuid.NewV4().String()
+ arg1 := structure.Arg{obj.Id,uuid,obj.Score, PgsInterPercent(areaPoints, obj.Rects, widthScale, heigthScale), float64(obj.Rects.Width * obj.Rects.Height), a.AreaJson,obj.Type, obj.Rects, obj.Car,obj.Feature, obj.ThftRes, []*structure.BaseInfo{},"",structure.ResultMsg{}}
//logger.Println("鏀捐繘鍘荤殑arg锛�-------", arg1)
a.Args = append(a.Args, &arg1)
a.FilterData = append(a.FilterData, &arg1)
}
}
logger.Info("鍖哄煙鏄細",areaPoints,"鍖哄煙鍐呯洰鏍囨暟閲忎负锛�",a.TargetNum,"---",len(a.FilterData))
- //for _,tar := range a.FilterData {
- // logger.Info("鍏蜂綋鐩爣鐨勫潗鏍囦负",tar.Id,tar.Location)
- //}
a.Time = time.Unix(time.Now().Unix(), 0).String()[11:16]
- a.KeepRight = arg.KeepRight
- a.IsStatic = arg.IsStatic
//logger.Println("--------------------鐪嬬湅鍖哄煙鏁版嵁锛�",*a)
}
@@ -362,7 +311,6 @@
logger.Debug("鏁版嵁鎺ㄩ�佹垚鍔燂紒鏀跺埌鍝嶅簲,鏁版嵁闀垮害涓猴細",len(msg))
return msg
}
-
func Push1(){
//var sock mangos.Socket
--
Gitblit v1.8.0