Last active
July 15, 2018 17:59
-
-
Save the-dagger/956a25792f7323acc17def27b9725d28 to your computer and use it in GitHub Desktop.
Code to get landmarks from cloud
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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