zmc
2023-12-22 9fdbf60165db0400c2e8e6be2dc6e88138ac719a
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# -*- coding: utf-8 -*-
 
"""
人体分析
"""
 
import re
import sys
import math
import time
from .base import AipBase
from .base import base64
from .base import json
from .base import urlencode
from .base import quote
 
class AipBodyAnalysis(AipBase):
 
    """
    人体分析
    """
 
    __bodyAnalysisUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/body_analysis'
 
    __bodyAttrUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/body_attr'
 
    __bodyNumUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/body_num'
 
    __gestureUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/gesture'
 
    __bodySegUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/body_seg'
 
    __driverBehaviorUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/driver_behavior'
 
    __bodyTrackingUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/body_tracking'
 
    __handAnalysisUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/hand_analysis'
 
    __bodyDangerV1Url = 'https://aip.baidubce.com/rest/2.0/video-classify/v1/body_danger'
    __fingertipV1Url = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/fingertip'
    
    def bodyAnalysis(self, image, options=None):
        """
            人体关键点识别
        """
        options = options or {}
 
        data = {}
        data['image'] = base64.b64encode(image).decode()
 
        data.update(options)
 
        return self._request(self.__bodyAnalysisUrl, data)
    
    def bodyAttr(self, image, options=None):
        """
            人体检测与属性识别
        """
        options = options or {}
 
        data = {}
        data['image'] = base64.b64encode(image).decode()
 
        data.update(options)
 
        return self._request(self.__bodyAttrUrl, data)
    
    def bodyNum(self, image, options=None):
        """
            人流量统计
        """
        options = options or {}
 
        data = {}
        data['image'] = base64.b64encode(image).decode()
 
        data.update(options)
 
        return self._request(self.__bodyNumUrl, data)
    
    def gesture(self, image, options=None):
        """
            手势识别
        """
        options = options or {}
 
        data = {}
        data['image'] = base64.b64encode(image).decode()
 
        data.update(options)
 
        return self._request(self.__gestureUrl, data)
    
    def bodySeg(self, image, options=None):
        """
            人像分割
        """
        options = options or {}
 
        data = {}
        data['image'] = base64.b64encode(image).decode()
 
        data.update(options)
 
        return self._request(self.__bodySegUrl, data)
    
    def driverBehavior(self, image, options=None):
        """
            驾驶行为分析
        """
        options = options or {}
 
        data = {}
        data['image'] = base64.b64encode(image).decode()
 
        data.update(options)
 
        return self._request(self.__driverBehaviorUrl, data)
    
    def bodyTracking(self, image, dynamic, options=None):
        """
            人流量统计-动态版
        """
        options = options or {}
 
        data = {}
        data['image'] = base64.b64encode(image).decode()
        data['dynamic'] = dynamic
 
        data.update(options)
 
        return self._request(self.__bodyTrackingUrl, data)
    
    def handAnalysis(self, image, options=None):
        """
            手部关键点识别
        """
        options = options or {}
 
        data = {}
        data['image'] = base64.b64encode(image).decode()
 
        data.update(options)
 
        return self._request(self.__handAnalysisUrl, data)
    
    def bodyDangerV1(self, videoData, options=None):
        """
            危险行为识别
            接口使用说明文档: https://ai.baidu.com/ai-doc/BODY/uk3cpywke
        """
        options = options or {}
        data = {}
        data['data'] = base64.b64encode(videoData).decode()
        data.update(options)
        return self._request(self.__bodyDangerV1Url, data)
 
    def fingertipV1(self, image, options=None):
        """
            指尖检测
            接口使用说明文档: https://ai.baidu.com/ai-doc/BODY/Jk7ir38ut
        """
        options = options or {}
        data = {}
        data['image'] = base64.b64encode(image).decode()
        data.update(options)
        return self._request(self.__fingertipV1Url, data)