recognizeObjectAPIAsync(sensorMessage) {
    return new Promise(function (resolve, reject) {
      const gcsURI = sensorMessage.sensors.frontCameraImagePathGCS;
  
      if (!gcsURI) {
        reject("Error: No gcURI found in sensorMessage");
        
      } else if (!gcsURI.startsWith("gs://")) {
        reject("Error: gcsURI must start with gs://");
        
      } else {
        // Example request for the inference VM: http://xx.xx.xx.xx:8082/v1/objectInference?gcs_uri=gs%3A%2F%2Fcamera-9-roman-test-oct9%2Fimage1.jpg
        const apiUrl = OBJECT_INFERENCE_API_URL + "?gcs_uri=" + encodeURIComponent(gcsURI);
        console.log("Vision API URL: " + apiUrl);
        // var visionResponse = new VisionResponse();
        const auth = {user: INFERENCE_USER_NAME, pass: INFERENCE_PASSWORD};
        
        // Measure the time it takes to call inference API
        const startTime = Date.now();
  
        request({uri: apiUrl, auth: auth}, function (err, response, body) {
          if (err) {
            console.log("!!! ERROR !!! calling remote ML API: " + err + ". Please verify that your Inference VM and the App are up and running and proper HTTP port is open in the firewall.");
            reject(err);
          } else {
            console.log("Vision API call took " + (Date.now() - startTime) + " ms. Result: " + body);
            if (response.statusCode != 200) {
              reject("Error: Received  " + response.statusCode + " from API");
              
            } else {
              resolve(body);
            }
          }
        });
      }
    });
  }
/************************************************************
   Generate response from the ML Vision
   Input:
   - sensorMessage - message from the car with sensor data
   Output:
   -
   ************************************************************/
Generate response from the ML Vision
Input:
sensorMessage - message from the car with sensor data
Output.
Generate response from the ML Vision Input : sensorMessage - message from the car with sensor data Output .
recognizeObjectAPIAsync(sensorMessage) {
    return new Promise(function (resolve, reject) {
      const gcsURI = sensorMessage.sensors.frontCameraImagePathGCS;
      if (!gcsURI) {
        reject("Error: No gcURI found in sensorMessage");
      } else if (!gcsURI.startsWith("gs://")) {
        reject("Error: gcsURI must start with gs://");
      } else {
        const apiUrl = OBJECT_INFERENCE_API_URL + "?gcs_uri=" + encodeURIComponent(gcsURI);
        console.log("Vision API URL: " + apiUrl);
        const auth = {user: INFERENCE_USER_NAME, pass: INFERENCE_PASSWORD};
        const startTime = Date.now();
        request({uri: apiUrl, auth: auth}, function (err, response, body) {
          if (err) {
            console.log("!!! ERROR !!! calling remote ML API: " + err + ". Please verify that your Inference VM and the App are up and running and proper HTTP port is open in the firewall.");
            reject(err);
          } else {
            console.log("Vision API call took " + (Date.now() - startTime) + " ms. Result: " + body);
            if (response.statusCode != 200) {
              reject("Error: Received  " + response.statusCode + " from API");
            } else {
              resolve(body);
            }
          }
        });
      }
    });
  }
recognizeObjectAPIAsync ( sensorMessage ) { return new Promise ( function ( resolve , reject ) { const gcsURI = sensorMessage . sensors . frontCameraImagePathGCS ; if ( ! gcsURI ) { reject ( "Error: No gcURI found in sensorMessage" ) ; } else if ( ! gcsURI . startsWith ( "gs://" ) ) { reject ( "Error: gcsURI must start with gs://" ) ; } else { const apiUrl = OBJECT_INFERENCE_API_URL + "?gcs_uri=" + encodeURIComponent ( gcsURI ) ; console . log ( "Vision API URL: " + apiUrl ) ; const auth = { user : INFERENCE_USER_NAME , pass : INFERENCE_PASSWORD } ; const startTime = Date . now ( ) ; request ( { uri : apiUrl , auth : auth } , function ( err , response , body ) { if ( err ) { console . log ( "!!! ERROR !!! calling remote ML API: " + err + ". Please verify that your Inference VM and the App are up and running and proper HTTP port is open in the firewall." ) ; reject ( err ) ; } else { console . log ( "Vision API call took " + ( Date . now ( ) - startTime ) + " ms. Result: " + body ) ; if ( response . statusCode != 200 ) { reject ( "Error: Received  " + response . statusCode + " from API" ) ; } else { resolve ( body ) ; } } } ) ; } } ) ; }
Generate response from the ML Vision
Input:
 sensorMessage - message from the car with sensor data
Output:
Generate response from the ML Vision Input : sensorMessage - message from the car with sensor data Output :
// Example request for the inference VM: http://xx.xx.xx.xx:8082/v1/objectInference?gcs_uri=gs%3A%2F%2Fcamera-9-roman-test-oct9%2Fimage1.jpg // var visionResponse = new VisionResponse(); // Measure the time it takes to call inference API