get img Width height and Data from gocv
| | |
| | | } |
| | | } |
| | | |
| | | type CameraChangeRunVo struct { |
| | | CameraIds []string `json:"camera_ids"` |
| | | RunType int `json:"run_type"` |
| | | } |
| | | |
| | | // @Summary 摄像机轮询和实时状态切换 |
| | | // @Description 摄像机轮询和实时状态切换 |
| | | // @Produce json |
| | | // @Tags camera |
| | | // @Param cameraId query string true "摄像机id" |
| | | // @Param runType query int true "0:实时切轮询,1:轮询切实时" |
| | | // @Param changeRunBody body controllers.CameraChangeRunVo true "参数结构体,0:实时切轮询,1:轮询切实时" |
| | | // @Success 200 {string} json "{"code":200, success:true, msg:"", data:""}" |
| | | // @Failure 500 {string} json "{"code":500, success:false, msg:"",data:""}" |
| | | // @Router /data/api-v/camera/changeRunType [post] |
| | | func (cc CameraController) ChangeRunType(c *gin.Context){ |
| | | cameraId := c.PostForm("cameraId") |
| | | runTypeStr := c.PostForm("runType") |
| | | runType,err := strconv.Atoi(runTypeStr) |
| | | if cameraId == "" || err!=nil || (runType !=0 && runType !=1){ |
| | | var ccrVo CameraChangeRunVo |
| | | if err := c.BindJSON(&ccrVo);err !=nil{ |
| | | util.ResponseFormat(c,code.RequestParamError,"参数有误") |
| | | return |
| | | } |
| | | |
| | | paramBody := util.Struct2Map(ccrVo) |
| | | var api dbapi.CameraApi |
| | | b, data := api.ChangeRunType(cameraId, runType) |
| | | b, data := api.ChangeRunType(paramBody) |
| | | if b { |
| | | util.ResponseFormat(c,code.Success,data) |
| | | } else { |
| | |
| | | return |
| | | } |
| | | var api dbapi.SysSetApi |
| | | b, data := api.SavePollDelay(period) |
| | | b, data := api.SavePollPeriod(period) |
| | | if b { |
| | | util.ResponseFormat(c,code.Success,data) |
| | | } else { |
| | |
| | | "github.com/gogo/protobuf/proto" |
| | | "github.com/pierrec/lz4" |
| | | "github.com/satori/go.uuid" |
| | | "image" |
| | | "io/ioutil" |
| | | "os" |
| | | "gocv.io/x/gocv" |
| | | "time" |
| | | ) |
| | | |
| | |
| | | formatTimeStr := time.Unix(timeUnix, 0).Format("2006-01-02 15:04:05") |
| | | filePath := "/home/user/workspace/timg.jpg" |
| | | |
| | | file, err := os.Open(filePath) |
| | | defer file.Close() |
| | | if err !=nil{ |
| | | fmt.Println("image not exist") |
| | | return i |
| | | } else { |
| | | img, _, err := image.Decode(file) |
| | | bytes, err := ioutil.ReadFile(filePath) |
| | | if err !=nil { |
| | | picMat := gocv.IMRead(filePath, gocv.IMReadColor) |
| | | |
| | | defer picMat.Close() |
| | | |
| | | if picMat.Empty() { |
| | | fmt.Println("file not exist") |
| | | return i |
| | | } |
| | | b := img.Bounds() |
| | | width := b.Max.X |
| | | height := b.Max.Y |
| | | i = protomsg.Image{ |
| | | Width:int32(width), |
| | | Height:int32(height), |
| | | Width:int32(picMat.Rows()), |
| | | Height:int32(picMat.Cols()), |
| | | Timestamp:formatTimeStr, |
| | | Data:bytes, |
| | | Data:[]byte(picMat.DataPtrUint8()), |
| | | } |
| | | return i |
| | | } |
| | | } |
| | | |
| | | func PushImgMsg(is protomsg.Recvmsg){ |