| | |
| | | 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)) |
| | | resp, err = util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result),weedfsUrl) |
| | | if err != nil { |
| | | logger.Error("画框或上传图片服务器出错", err) |
| | | } else { |
| | |
| | | i := protomsg.Image{} |
| | | err = proto.Unmarshal(bdata, &i) |
| | | //resp, err = util.PostFormBufferData(weedfsUrl, i, uuid.NewV4().String()) |
| | | resp, err := util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result)) |
| | | resp, err := util.DrawPolygonOnImage(msg.Cid, i, msg.RuleResult["yolo"].([]ruleserver.Result),weedfsUrl) |
| | | if err != nil { |
| | | logger.Error("画框或上传图片服务器出错", err) |
| | | } else { |
| | |
| | | } |
| | | } |
| | | |
| | | func DrawPolygonOnImage(cameraId string, img protomsg.Image, results []ruleserver.Result) (maps map[string]interface{}, err0 error) { |
| | | func DrawPolygonOnImage(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 nil,nil |
| | | maps,err0 = UploadFromMat(rook) |
| | | maps,err0 = UploadFromMat(url,rook) |
| | | return |
| | | } |
| | | |
| | |
| | | } |
| | | } |
| | | |
| | | func UploadFromMat(rook gocv.Mat)(maps map[string]interface{}, err0 error){ |
| | | func UploadFromMat(url string,rook gocv.Mat)(maps map[string]interface{}, err0 error){ |
| | | // 上传 |
| | | fdata, _ := gocv.IMEncode(".jpg", rook) |
| | | body := &bytes.Buffer{} |
| | |
| | | request_reader := io.MultiReader(body, file, close_buf) |
| | | //_, err = io.Copy(part, file) |
| | | //writer.WriteField(key, val) |
| | | request, err := http.NewRequest("POST", "http://192.168.1.182:6333/submit", request_reader) |
| | | request, err := http.NewRequest("POST", url, request_reader) |
| | | request.Header.Add("Content-Type", writer.FormDataContentType()) |
| | | timeout := time.Duration(5 * time.Second) //超时时间50ms |
| | | client := &http.Client{Timeout: timeout} |