Skip to content

Instantly share code, notes, and snippets.

@the-dagger
Last active July 15, 2018 17:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save the-dagger/956a25792f7323acc17def27b9725d28 to your computer and use it in GitHub Desktop.
Save the-dagger/956a25792f7323acc17def27b9725d28 to your computer and use it in GitHub Desktop.
Code to get landmarks from cloud
private fun getLandmarkFromCloud(bitmap: Bitmap) {
val image = FirebaseVisionImage.fromBitmap(bitmap)
val detector = FirebaseVision.getInstance()
.visionCloudLandmarkDetector
detector.detectInImage(image)
.addOnCompleteListener {
//The completion listener returns a list of detected landmarks
for (firebaseVisionLandmarks in it.result) {
//get the name of the landmark
val landmark = firebaseVisionLandmarks.landmark
// Multiple locations are possible so loop through them,
// e.g., the location of the depicted
// landmark and the location the picture was taken.
for (location in firebaseVisionLandmarks.locations) {
//get the latitude and the longitude of the location
val lat = location.latitude
val long = location.longitude
}
//Also extract the accuracy of the detected landmark
val confidence = firebaseVisionLandmarks.confidence
}
}
.addOnFailureListener {
//Failed to retrieve an image
Toast.makeText(this, "Something went wrong", Toast.LENGTH_SHORT).show()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment