personPicUrl submit add ?collection=persistent
| | |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return |
| | | } |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit" |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit?collection=persistent" |
| | | //根据人脸坐标扣出人脸小图 |
| | | t1 := time.Now() |
| | | cutFaceImgData := util.SubImg(*pI, int(rcFace.Left), int(rcFace.Top), int(rcFace.Right), int(rcFace.Bottom)) |
| | |
| | | feature = fea |
| | | } |
| | | if personPicUrl != "" && feature != "" { |
| | | var dbpApi dbapi.DbPersonApi |
| | | b,d := dbpApi.JoinDbTable(reqBody.TableIds, feature, personPicUrl) |
| | | if b { |
| | | util.ResponseFormat(c,code.Success,d) |
| | | return |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,"加入失败") |
| | | return |
| | | //将这张抓拍的照片下载下来上传到collection=persistent的集合中,防止被清理掉 |
| | | picB, e3 := util.DownLoad("http://" + personPicUrl) |
| | | if e3 == nil { |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit?collection=persistent" |
| | | newPersonPicUrl, e4 := WeedFSClient.UploadFile(weedfsUri, "capturePerson", picB) |
| | | if e4 == nil { |
| | | var dbpApi dbapi.DbPersonApi |
| | | b,d := dbpApi.JoinDbTable(reqBody.TableIds, feature, newPersonPicUrl) |
| | | if b { |
| | | util.ResponseFormat(c,code.Success,d) |
| | | return |
| | | } else { |
| | | util.ResponseFormat(c,code.ComError,"加入失败") |
| | | return |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | } |
| | | util.ResponseFormat(c,code.ComError,"加入失败") |
| | |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return |
| | | } |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit" |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit?collection=persistent" |
| | | logger.Debug("weedfsUri:",weedfsUri) |
| | | resultMap :=make(map[string]interface{},0) |
| | | //将上传的图片交人脸检测和人脸提取,获得特征 |
| | |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return nil,"",nil,errors.New("localConf err") |
| | | } |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit" |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit?collection=persistent" |
| | | logger.Debug("weedfsUri:",weedfsUri) |
| | | faceArr, err, pI := service.GetFaceFeaFromSdk(fileBytes, time.Second*60) |
| | | if err ==nil && len(faceArr) ==1 { |
| | |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return |
| | | } |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit" |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit?collection=persistent" |
| | | |
| | | //将上传的图片交人脸检测和人脸提取,获得特征 |
| | | fileBytes, _ := ioutil.ReadAll(file) |
| | |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return |
| | | } |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit" |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit?collection=persistent" |
| | | { |
| | | uri := weedfsUri |
| | | fileInfo, e := esutil.PostFormBufferData(uri, filename, "file", uploadData) |
| | |
| | | |
| | | import ( |
| | | "archive/zip" |
| | | "basic.com/valib/logger.git" |
| | | "bytes" |
| | | "crypto/md5" |
| | | "crypto/tls" |
| | | "encoding/hex" |
| | | "encoding/json" |
| | | "image" |
| | | "io" |
| | | "io/ioutil" |
| | | "net" |
| | | "net/http" |
| | | "os" |
| | | "path/filepath" |
| | |
| | | } |
| | | |
| | | return hex.EncodeToString(_md5.Sum(nil)),nil |
| | | } |
| | | |
| | | func DownLoad(url string)([]byte,error){ |
| | | connectTimeout := 5 * time.Second |
| | | readWriteTimeout := 10000 * time.Millisecond |
| | | c := &http.Client{ |
| | | Transport: &http.Transport{ |
| | | TLSClientConfig: &tls.Config{InsecureSkipVerify: true}, |
| | | Dial: TimeoutDialer(connectTimeout, readWriteTimeout), |
| | | }, |
| | | } |
| | | req, err := http.NewRequest("GET",url,nil) |
| | | if err != nil { |
| | | return nil,err |
| | | } |
| | | resp,err := c.Do(req) |
| | | |
| | | body, err1 := ioutil.ReadAll(resp.Body) |
| | | if err1 != nil { |
| | | resp.Body.Close() |
| | | return nil,err |
| | | }else { |
| | | logger.Debug("Download success") |
| | | } |
| | | resp.Body.Close() |
| | | return body,nil |
| | | } |
| | | |
| | | func TimeoutDialer(cTimeout time.Duration, rwTimeout time.Duration) func(net, addr string) (c net.Conn, err error) { |
| | | return func(netw, addr string) (net.Conn, error) { |
| | | conn, err := net.DialTimeout(netw, addr, cTimeout) |
| | | if err != nil { |
| | | return nil, err |
| | | } |
| | | conn.SetDeadline(time.Now().Add(rwTimeout)) |
| | | return conn, nil |
| | | } |
| | | } |
| | |
| | | logger.Debug("localConfig is wrong!!!") |
| | | return "",err2 |
| | | } |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit" |
| | | var weedfsUri = "http://"+localConf.WebPicIp+":"+strconv.Itoa(int(localConf.WebPicPort))+"/submit?collection=persistent" |
| | | weedFilePath, err := WeedFSClient.UploadFile(weedfsUri, camera.Name+".jpg", b) |
| | | if err != nil { |
| | | return "",err |