Preparations

This section gives details about the key activities we need to do before we can start using the Google Cloud Vision API from our mobile application:

  1. The Google Cloud Vision API should be enabled in the Google Cloud Console and an API key should be created that will be used in the mobile application code. Please perform the following steps to get the Cloud Vision API key:
    1. Open cloud.google.com/vision.
    2. Go to Console. If you do no have a trial account, it will ask you to create one and complete the process.
    3. Enable billing so we get $300 free credit. Once we have the account, we can go to Console and complete the process of creating the key.
    4. From the Console, create a project.
    5. Open that project. Go to API services | Library search for cloud vision API.
    6. Click on it and enable it.
    7. Go to API Services | Credentials.
    8. Go to Credentials | API Key.
    9. Create the API key.
    10. Copy the API key; this will be used in the mobile application code.
  2. Add the dependencies required in the mobile client application to use the Google Cloud Vision API. The Google API Client will be needed and hence this needs to be added to the client project. These will need to be specified in the Gradle build file. The sample Gradle file with the key dependencies is as follows:
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.support:design:27.0.2'
compile 'com.google.api-client:google-api-client-android:1.23.0' exclude module: 'httpclient'
compile 'com.google.http-client:google-http-client-gson:1.23.0' exclude module: 'httpclient'
compile 'com.google.apis:google-api-services-vision:v1-rev369-1.23.0'
}
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset