Access to the Vision API can be obtained through a call to the REST API. You submit a JSON request with an embedded image or image link in GCS. Then you can pass the functions you want to run on the image. This is passed as a JSON request, and the response object contains annotations. Here is a snippet of Python code calling the Vision API.
DISCOVERY_URL='https://{api}.googleapis.com/$discovery/rest?version={apiVersion}' credentials = GoogleCredentials.get_application_default() service = discovery.build('vision', 'v1', credentials=credentials, discoveryServiceUrl=DISCOVERY_URL) 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': 'LABEL_DETECTION', # Feature to detect 'maxResults': 1, }] }] }) response = service_request.execute() label = response['responses'][0]['labelAnnotations'][0]['description']
For more information, you can see the Label Detection Tutorial.
source share