| | |
| | | func InitService() { |
| | | fmt.Println("service init!") |
| | | imgPushChan = make(chan []byte) |
| | | |
| | | resultMap.FeaM = make(map[string][]*protomsg.ResultFaceExtCom,0) |
| | | client_push = deliver.NewClient(deliver.PushPull, Url_Service_PUSH) |
| | | client_pull = deliver.NewClient(deliver.PushPull, Url_Service_PULL) |
| | | defer func() { |
| | |
| | | fmt.Println("Len(sdkInfos)=",len(sdkInfos)) |
| | | for _,swt :=range sdkInfos{ |
| | | if swt.Sdktype =="FaceDetect"{ |
| | | fmt.Println("人脸检测结果") |
| | | var pfp protomsg.ParamFacePos |
| | | err := proto.Unmarshal(swt.Sdkdata, &pfp) |
| | | if err !=nil { |
| | | fmt.Println("faceDetect result unmarshal err:",err) |
| | | } else { |
| | | for _,face :=range pfp.Faces{ |
| | | fmt.Println("FacePos:",face.Pos) |
| | | fmt.Println("ThftResult:",face.Result) |
| | | fmt.Println("人脸检测结果长度:",len(swt.Sdkdata)) |
| | | if len(swt.Sdkdata)>1{ |
| | | var pfp protomsg.ParamFacePos |
| | | err := proto.Unmarshal(swt.Sdkdata, &pfp) |
| | | if err !=nil { |
| | | fmt.Println("faceDetect result unmarshal err:",err) |
| | | } else { |
| | | for _,face :=range pfp.Faces{ |
| | | fmt.Println("FacePos:",face.Pos) |
| | | fmt.Println("ThftResult:",face.Result) |
| | | } |
| | | } |
| | | } |
| | | } |
| | | if swt.Sdktype == "FaceExtract"{ |
| | | var pff protomsg.ParamFaceFeature |
| | | if err := proto.Unmarshal(swt.Sdkdata, &pff);err !=nil{ |
| | | //fmt.Println("ParamFaceFeature unmarshal err:",err) |
| | | } else { |
| | | fmt.Println("目标数:",len(pff.ExtComp)) |
| | | if len(pff.ExtComp) >0 { |
| | | resultMap.Write(perId,pff.ExtComp) |
| | | fmt.Println("人脸提取结果长度:",len(swt.Sdkdata)) |
| | | if len(swt.Sdkdata) > 1{ |
| | | var pff protomsg.ParamFaceFeature |
| | | if err := proto.Unmarshal(swt.Sdkdata, &pff);err !=nil{ |
| | | //fmt.Println("ParamFaceFeature unmarshal err:",err) |
| | | } else { |
| | | fmt.Println("目标数:",len(pff.ExtComp)) |
| | | if len(pff.ExtComp) >0 { |
| | | resultMap.Write(perId,pff.ExtComp) |
| | | |
| | | for _,fea :=range pff.ExtComp{ |
| | | base64Fea := base64.StdEncoding.EncodeToString(fea.Feats) |
| | | fmt.Println("perId:",perId) |
| | | fmt.Println("faceFeature:",base64Fea) |
| | | for _,fea :=range pff.ExtComp{ |
| | | base64Fea := base64.StdEncoding.EncodeToString(fea.Feats) |
| | | fmt.Println("perId:",perId) |
| | | fmt.Println("faceFeature:",base64Fea) |
| | | } |
| | | } |
| | | } |
| | | break |
| | | } |
| | | break |
| | | } |
| | | } |
| | | } |