2017-04-13 95 views
0

在google视觉api标签检测中,无法知道对象所在的位置?任何选项或想法? 我已经在示例中尝试过,然后响应json是不包含对象的位置!谷歌视觉API标签检测

+0

可能的重复[如何使用视觉识别api获取自定义对象在图像上的位置](http://stackoverflow.com/questions/38634409/how-to-get-a-position-of-定制对象使用图像使用视觉识别API) – Nakilon

回答

0
try this 
import io 
from google.cloud import vision 
import argparse 
import base64 
import picamera 
import json 
import os 
import picamera 
import sys 

from googleapiclient import discovery 
from oauth2client.client import GoogleCredentials 

    os.environ["GOOGLE_APPLICATION_CREDENTIALS"] = "provide here the json key path" 
    camera = picamera.PiCamera() 


    camera.capture('pic1.jpg') 
    credentials = GoogleCredentials.get_application_default() 
    service = discovery.build('vision', 'v1', credentials=credentials) 

    vision_client=vision.Client() 
    file_name='pic1.jpg' 

    with io.open(file_name,'rb') as image_file: 
     content=image_file.read() 
     image=vision_client.image(content=content) 


    labels = image.detect_labels() 

    for label in labels: 
     print(label.description) 

` 
+0

你应该解释你的代码只有答案。只有代码答案经常被低估,甚至可能被删除。谢谢。 – Bugs