zhangzengfei
2024-10-22 2c77f012601b7788dc58b0c9fd99aad587983b0d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
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
}