介绍
这篇文章给大家介绍怎么在python中调用百度AI接口统计人流量,内容非常详细,感兴趣的小伙伴们可以参考借鉴,希望对大家能有所帮助。
新建AipBodyAnalysis
得到aip import AipBodyAnalysis “““,你的,APPID AK SK “““ 时间=APP_ID & # 39;你的,App id # 39; 时间=API_KEY & # 39;你的,Api 关键# 39; 时间=SECRET_KEY & # 39;你的,Secret 关键# 39; 时间=client AipBodyAnalysis (APP_ID, API_KEY, SECRET_KEY)
读取和调用
“““,读取图片,“““ def get_file_content (filePath): with 才能;开放(filePath, & # 39; rb # 39;), as 外交政策: ,,,return fp.read () 时间=image get_file_content (& # 39; example.jpg& # 39;) “““,调用人流量统计,“““ client.bodyNum(图片); “““,如果有可选参数,“““ options =, {} 选项(“area"),=,“(x1, y1, x2, y2, x3, y3…xn yn" 选项(“show"),=,“false" “““,带参数调用人流量统计,“““ client.bodyNum(图像,选项)
显示图片
img =, Image.open (& # 39; ren.jpg& # 39;) plt.imshow (img) plt.show ()
完整代码
#, - *安康;编码:utf-8 - * - “““ Created 提醒Mon Feb 1 22:22:40 2021 @author:联想 “““ 得到aip import  AipBodyAnalysis 得到PIL import 形象 import matplotlib.pyplot  as plt 时间=APP_ID & # 39; 23619478 & # 39; 时间=API_KEY & # 39; x2M6XTQ4oNIlhS2f2GQBElHa& # 39; 时间=SECRET_KEY & # 39; xxxxxxxxxxxxxxx& # 39; 时间=client AipBodyAnalysis (APP_ID, API_KEY, SECRET_KEY) “““,读取图片,“““ def get_file_content (filePath): with 才能;开放(filePath, & # 39; rb # 39;), as 外交政策: ,,,return fp.read () 时间=image get_file_content (& # 39; ren.jpg& # 39;) 时间=img Image.open (& # 39; ren.jpg& # 39;) plt.imshow (img) plt.show () “““,调用人流量统计,“““ print (client.bodyNum(图片)
最终效果
关于怎么在python中调用百度AI接口统计人流量就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看的到。