| | |
| | | err = proto.Unmarshal(bdata, &i) |
| | | if imgMaxUrl == "" { |
| | | bigPhotoUrl := make(map[string]interface{}) |
| | | bigPhotoUrl, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String()) |
| | | bigPhotoUrl, err = util.DrawPolygonOnImageForFace(msg.Cid, i, msg.RuleResult["face"].([]ruleserver.FaceResult), weedfsUrl) |
| | | logger.Debug("========大图路径:", bigPhotoUrl) |
| | | imgMaxUrl = bigPhotoUrl["fileUrl"].(string) |
| | | picTime = i.Timestamp |
| | |
| | | } |
| | | i := protomsg.Image{} |
| | | err = proto.Unmarshal(bdata, &i) |
| | | resp1, err1 := util.DrawPolygonOnImage(msg1.Cid, i, msg1.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) |
| | | resp1, err1 := util.DrawPolygonOnImageForYolo(msg1.Cid, i, msg1.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) |
| | | if err1 != nil { |
| | | logger.Error("缓存数据画框或上传图片服务器出错", err) |
| | | } else { |
| | |
| | | if len(alarmRules) > 0 { |
| | | isAlarm = 1 |
| | | //resp, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String()) |
| | | resp, err = util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) |
| | | resp, err = util.DrawPolygonOnImageForYolo(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result), weedfsUrl) |
| | | if err != nil { |
| | | logger.Error("画框或上传图片服务器出错", err) |
| | | return |
| | |
| | | } |
| | | } |
| | | |
| | | func DrawPolygonOnImage(cameraId string, img protomsg.Image, results []ruleserver.Result,url string) (maps map[string]interface{}, err0 error) { |
| | | func DrawPolygonOnImageForYolo(cameraId string, img protomsg.Image, results []ruleserver.Result,url string) (maps map[string]interface{}, err0 error) { |
| | | |
| | | rook, _ := gocv.NewMatFromBytes(int(img.Height), int(img.Width), gocv.MatTypeCV8UC3, img.Data) |
| | | //rook := gocv.IMRead("/home/user/workspace/ruleprocess/util/105.jpg",gocv.IMReadColor) |
| | |
| | | return |
| | | } |
| | | |
| | | func DrawPolygonOnImageForFace(cameraId string, img protomsg.Image, results []ruleserver.FaceResult,url string) (maps map[string]interface{}, err0 error) { |
| | | |
| | | rook, _ := gocv.NewMatFromBytes(int(img.Height), int(img.Width), gocv.MatTypeCV8UC3, img.Data) |
| | | //rook := gocv.IMRead("/home/user/workspace/ruleprocess/util/105.jpg",gocv.IMReadColor) |
| | | defer rook.Close() |
| | | |
| | | yellow := color.RGBA{255, 255, 0, 0} |
| | | |
| | | // 分割区域id集合并根据id查询区域然后画框 |
| | | for _,result := range results { |
| | | polygonIds := strings.Split(result.AlarmPolygon,",") |
| | | logger.Info("-----------------------看看报警区域id:",polygonIds) |
| | | for i := 0; i < len(polygonIds)-1; i++ { |
| | | polygon := getPolygonById(polygonIds[i],cameraId) |
| | | if polygon.Polygon != "[]" && polygon.Polygon != ""{ |
| | | logger.Debug("所画区域:",polygon.Polygon) |
| | | DrawAPolygon(&rook,polygon.Polygon,yellow) |
| | | } |
| | | } |
| | | } |
| | | //return nil,nil |
| | | maps,err0 = UploadFromMat(url,rook) |
| | | return |
| | | } |
| | | |
| | | // 把图片转成二进制流 |
| | | func RetrieveROM(filename string) ([]byte, error) { |
| | | file, err := os.Open(filename) |