驾驶行为分析
kkive康康 发布于2019-06 浏览:6271 回复:0
2
收藏
快速回复
最后编辑于2019-06

人像分割

直接上代码,不废话

 

from aip import AipBodyAnalysis
""" 你的 APPID AK SK """
APP_ID = '16144775'
API_KEY = 'j9Kn9bYH2go6kFs4yjETnxPF'
SECRET_KEY = 'YpNfHUbmSMN1F3cLftKcTMxW1hfCxVvO'
aipdriver = AipBodyAnalysis(APP_ID, API_KEY, SECRET_KEY)

#打开照片
filepath = 'test.jpg'

""" 读取图片 """
def get_file_content(filepath):
    with open(filepath, 'rb') as c:
        return c.read()

""" 如果有可选参数 """
options = {'type':'cellphone,not_buckling_up,both_hands_leaving_wheel,not_facing_front'

}
#options["type"] = "cellphone"
#options["type"] = "not_buckling_up"#未系安全带
#options["type"] = "both_hands_leaving_wheel"#双手离开方向盘
#options["type"] = "not_facing_front"#视角未朝前方


""" 带参数调用驾驶行为分析 """
request = aipdriver.driverBehavior(get_file_content(filepath), options)

#print(request)
if request['person_num'] == 1:
    print ('有驾驶员')
elif request['person_num'] != 1:
    print ('没有驾驶员')
print ("驾驶员的属性行为信息:",request['person_info'])

下面是输出

C:\Users\AAA\AppData\Local\Programs\Python\Python37-32\python.exe C:/Users/AAA/PycharmProjects/百度AI人体分析/驾驶行为分析-END.py
有驾驶员
驾驶员的属性行为信息: [{'attributes': {'cellphone': {'threshold': 0.5, 'score': 6.293485057540238e-06}, 'both_hands_leaving_wheel': {'threshold': 0.5799999833106995, 'score': 0.01667769439518452}, 'not_facing_front': {'threshold': 0.5, 'score': 9.272806522631072e-08}, 'not_buckling_up': {'threshold': 0.6700000166893005, 'score': 0.9999991655349731}}, 'location': {'width': 1869, 'top': 787, 'height': 3236, 'left': 0}}]

进程已结束,退出代码 0
收藏
点赞
2
个赞
TOP
切换版块