From 5d17d528ded3c828f7f79ae57ec72429de6dd1c9 Mon Sep 17 00:00:00 2001
From: panlei <2799247126@qq.com>
Date: 星期三, 13 十一月 2019 16:56:37 +0800
Subject: [PATCH] 去掉link
---
ruleserver/readyDataForRule.go | 39 +++++++++++++--------------------------
1 files changed, 13 insertions(+), 26 deletions(-)
diff --git a/ruleserver/readyDataForRule.go b/ruleserver/readyDataForRule.go
index 15f781f..b0fcee6 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"
- "basic.com/valib/logger.git"
"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,16 +87,16 @@
}
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 {
+func GetTimeById(id string, index int) []structure.TimeRange {
_, cameraTimeRule := cache.GetTimeRuleById(id)
- var timeRangeList []day
+ var timeRangeList []structure.Day
err := json.Unmarshal([]byte(cameraTimeRule.TimeRule), &timeRangeList)
if err != nil {
logger.Error("鍙栨椂闂磋鍒欐椂鍙嶅簭鍒楀寲閿欒锛�")
@@ -123,14 +121,7 @@
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 {
@@ -162,7 +153,6 @@
}
bytes := getCompareMsg(comArg)
- //bytes := []byte{}
var scResult protomsg.SdkCompareResult
err1 := proto.Unmarshal(bytes, &scResult)
if err1 != nil {
@@ -285,23 +275,21 @@
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), obj.IsYolo, obj.Rects, obj.Feature, obj.ThftRes, []*structure.BaseInfo{}}
//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
@@ -362,7 +350,6 @@
logger.Debug("鏁版嵁鎺ㄩ�佹垚鍔燂紒鏀跺埌鍝嶅簲,鏁版嵁闀垮害涓猴細",len(msg))
return msg
}
-
func Push1(){
//var sock mangos.Socket
--
Gitblit v1.8.0