package client
|
|
import (
|
"fmt"
|
"gat1400Exchange/pkg"
|
|
"encoding/json"
|
"gat1400Exchange/config"
|
"gat1400Exchange/pkg/logger"
|
"gat1400Exchange/vo"
|
)
|
|
const (
|
FacesUrI = "/VIID/Faces"
|
PersonsUrI = "/VIID/Persons"
|
)
|
|
func FaceCapture(msg []byte) int {
|
if clientStatus != vo.StatusSuccess {
|
return clientStatus
|
}
|
|
url := fmt.Sprintf("%s://%s:%s%s", config.ClientConf.Proto, config.ClientConf.ServerAddr, config.ClientConf.ServerPort, FacesUrI)
|
rsp, err := pkg.HttpPost(url, headers, msg)
|
if err != nil {
|
logger.Warn("Post faces failed, %s", err.Error())
|
return vo.StatusOtherError
|
}
|
|
var stat vo.ResponseStatus
|
err = json.Unmarshal(rsp, &stat)
|
if err != nil {
|
logger.Warn("Post faces response unmarshal failed, %s", err.Error())
|
return vo.StatusOtherError
|
}
|
|
logger.Debug("Post faces success.")
|
return stat.StatusCode
|
}
|
|
func PersonCapture(msg []byte) int {
|
if clientStatus != vo.StatusSuccess {
|
return clientStatus
|
}
|
|
url := fmt.Sprintf("%s://%s:%s%s", config.ClientConf.Proto, config.ClientConf.ServerAddr, config.ClientConf.ServerPort, PersonsUrI)
|
rsp, err := pkg.HttpPost(url, headers, msg)
|
if err != nil {
|
logger.Warn("Post person failed, %s", err.Error())
|
return vo.StatusOtherError
|
}
|
|
var stat vo.ResponseStatus
|
err = json.Unmarshal(rsp, &stat)
|
if err != nil {
|
logger.Warn("Post person response unmarshal failed, %s", err.Error())
|
return vo.StatusOtherError
|
}
|
|
logger.Debug("Post person success.")
|
|
return stat.StatusCode
|
}
|