googlecloudvisionapi客户端库

visionar的Python项目详细描述


用于google cloud vision api的python客户端库

https://cloud.google.com/vision

安装

库可以与pip一起安装:pip install visionary

用法

用法示例:

fromvisionaryimportGoogleCloudVision,LabelDetection,LogoDetectionAPI_KEY="dummy_api_key"client=GoogleCloudVision(API_KEY)# Ask for logo detection, 10 results maxresponse=client.annotate("dummy.jpg",LogoDetection())# Ask for label detection, 3 results maxresponse=client.annotate("dummy.jpg",LabelDetection(3))

检测参数可以显式设置:

# 5 results max for logo detection and only one result for label detectionresponse=client.annotate("dummy.jpg",LogoDetection(5),LabelDetection(1))

第一个参数可以是文件对象:

uploaded_file=open("dummy.jpg")...# somewhere laterresponse=client.annotate(uploaded_file)

或网址:

response=client.annotate("http://google.com/dummy.jpg")

客户端支持单个注释中的多个图像调用

response=client.annotate(("dummy.jpg"),("http://google.com/dummy.jpg"),("dummy.jpg",LogoDetection(1)),)

处理响应:

ifresponse.ok:forrespinresponse.responses:foriinresp.logo_annotations:print(i.description)else:print(response.error['code'],response.error['message'],response.error['status'])

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
java CXF和授权   java在网站中部署使用swing创建的表单   java为什么getHeaderField()返回一个字符串,其中getHeaderFields()返回HttpUrlConnection中的Map<String,List<String>>   java如何检测恶意数据包?   webview中的java网页为空   java SWT图像资源,用于将我的所有图像存储在一个位置   java计算数组的最大长度,使平均值小于给定值   java“发件人电话号码无效”和美国号码   将Swing组件作为内容的自定义Java工具提示不会显示   在并发HashMap中重新灰化期间的java检索   Java 7和Tomcat 7.0.64 ClassFormatException:常量池中的字节标记无效   使用JUnit的java assertNull因NullPointerException失败   java内存中的文件是否与文件系统中的文件大小相同?   循环内实例化的类型的java注入依赖项