Donate. I desperately need donations to survive due to my health

Get paid by answering surveys Click here

Click here to donate

Remote/Work from Home jobs

Should I sign up free trial for the google vision api?

  • I have a problem when use Cloud Google Vision API reading a picture information.
  • I receive the following error:

Cloud Vision API reuqest failed.Check logs for details.

  • After debugging, I notice the code runs to the line: BatchAnnotateImagesResponse response = annotateRequest.execute(); then runs to line return "Cloud Vision API request failed. Check logs for details.";

    protected String doInBackground(Object... params) { try{

                HttpTransport httpTransport = AndroidHttp.newCompatibleTransport();
                JsonFactory jsonFactory = GsonFactory.getDefaultInstance();
    
                VisionRequestInitializer requestInitializer = new VisionRequestInitializer(CLOUD_VISION_API_KEY);
    
                Vision.Builder builder = new Vision.Builder(httpTransport, jsonFactory, null);
                builder.setVisionRequestInitializer(requestInitializer);
    
                Vision vision = builder.build();
    
                BatchAnnotateImagesRequest batchAnnotateImagesRequest = new BatchAnnotateImagesRequest();
                batchAnnotateImagesRequest.setRequests(annotateImageRequests);
    
                Vision.Images.Annotate annotateRequest = vision.images().annotate(batchAnnotateImagesRequest);
                annotateRequest.setDisableGZipContent(true);
                BatchAnnotateImagesResponse response = annotateRequest.execute();
    
                return convertResponseToString(response);
            } catch (GoogleJsonResponseException e) {
                Log.d(TAG, "failed to make API request because " + e.getContent());
            } catch (IOException e) {
                Log.d(TAG, "failed to make API request because of other IOException " + e.getMessage());
            }
            return "Cloud Vision API request failed. Check logs for details.";
        }
    
  • Currently I use version minSdkVersion 21 and targetSdkVersion 26

  • Android 3.2.1
  • I don't activate free trial google api.
  • Link code github you can downnload and test:

    https://github.com/Thumar/GoogleVisionAPI

  • Who can help me with this issue?

Comments