panlei
2019-07-02 fa7f3adbefe5bbe533fcfd098bc874f603520a06
likeDat额、
2个文件已修改
15 ■■■■■ 已修改文件
insertdata/insertDataToEs.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
util/image.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
insertdata/insertDataToEs.go
@@ -127,7 +127,7 @@
                i := protomsg.Image{}
                err = proto.Unmarshal(bdata, &i)
                log.Println("======================================看看这个框:",face.Location)
                bytes := util.Subimg(i.Data, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height))
                bytes := util.SubImg(i, int(face.Location.X), int(face.Location.Y), int(face.Location.X+face.Location.Width), int(face.Location.Y+face.Location.Height))
                resp, err := util.PostFormBufferData1(weedfsUrl, bytes, uuid.NewV4().String())
                if err != nil {
                    log.Println("上传小图出错")
@@ -142,7 +142,7 @@
                    msg.Tasklab.Taskname,
                    face.SdkName,
                    "",
                    "", // 只检测,没有比对时间
                    time.Now().Format("2006-01-02 15:04:05"), // 只检测,没有比对时间
                    face.ThftRes.Gender,
                    face.ThftRes.Age,
                    "",
@@ -170,11 +170,7 @@
                }
                err = EsReq("POST", "http://192.168.1.182:9200/videopersons/perVideoPicture", requstbody)
                if err != nil {
                    log.Println("es can not execute right.")
                } else {
                    log.Println("___________________________________往ES插入人脸数据成功")
                }
                log.Println(err)
            }else {
                log.Println("跟底库的相似数据---------:",face.Liker)
            }
util/image.go
@@ -1,12 +1,13 @@
package util
import (
    "basic.com/pubsub/protomsg.git"
    "gocv.io/x/gocv"
    "image"
    "log"
)
// 按尺寸去切图
func Subimg(dbyte []byte,x0,y0,x1,y1 int,) []byte{
func SubImg(i protomsg.Image,x0,y0,x1,y1 int,) []byte{
    //bbb := bytes.NewBuffer(dbyte)                           // 必须加一个buffer 不然没有read方法就会报错
    ////log.Println("==================看看这个buffer",bbb)
@@ -26,7 +27,7 @@
    //defer f.Close()                                         //关闭文件
    //jpeg.Encode(f, subImg, nil)                         //写入文件
    log.Println("--------------------------四大金刚:",x0,y0,x1,y1)
    img,_ := gocv.NewMatFromBytes(720,1280,gocv.MatTypeCV8UC3,dbyte)
    img,_ := gocv.NewMatFromBytes(int(i.Height),int(i.Width),gocv.MatTypeCV8UC3,i.Data)
    rect := image.Rect(x0,y0,x1,y1)
    region := img.Region(rect)
    bytes, _ := gocv.IMEncode(".jpg", region)