Google Cloud Visionを使用してURLを分析できますか。私はローカルに保存した画像を解析する方法を知っているが、私は、インターネット上に存在するのjpgの分析に見えることはできません:私はURLを解析し、そこにあるかどうかについて答えを得ることができGoogle Cloud Vision - Pythonを使用したURLの分析
import argparse
import base64
import httplib2
from googleapiclient.discovery import build
import collections
import time
import datetime
import pyodbc
time_start = datetime.datetime.now()
def main(photo_file):
'''Run a label request on a single image'''
API_DISCOVERY_FILE = 'https://vision.googleapis.com/$discovery/rest?version=v1'
http = httplib2.Http()
service = build('vision', 'v1', http, discoveryServiceUrl=API_DISCOVERY_FILE, developerKey=INSERT API KEY HERE)
with open(photo_file, 'rb') as image:
image_content = base64.b64encode(image.read())
service_request = service.images().annotate(
body={
'requests': [{
'image': {
'content': image_content
},
'features': [{
'type': 'LOGO_DETECTION',
'maxResults': 10,
}]
}]
})
response = service_request.execute()
try:
logo_description = response['responses'][0]['logoAnnotations'][0]['description']
logo_description_score = response['responses'][0]['logoAnnotations'][0]['score']
print logo_description
print logo_description_score
except KeyError:
print "logo nonexistent"
pass
print time_start
if __name__ == '__main__':
main("C:\Users\KVadher\Desktop\image_file1.jpg")
とにかくありそれらのロゴはどれですか?
を私はすべての画像をダウンロードするにはどうすればよいですか? – semiflex
urllib2ライブラリで試してください... urlopen()メソッドを使用してください。 – trans1st0r