Last active
August 1, 2018 08:00
-
-
Save the-dagger/7b4db62bed38e8057d134b0fd35170dc to your computer and use it in GitHub Desktop.
This file contains hidden or 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 getPokemonFromBitmap(bitmap: Bitmap?) { | |
| val inputs = FirebaseModelInputs.Builder() | |
| .add(convertBitmapToByteBuffer(bitmap)) // add() as many input arrays as your model requires | |
| .build() | |
| fireBaseInterpreter.run(inputs, inputOutputOptions) | |
| ?.addOnSuccessListener { | |
| val pokeList = mutableListOf<Pokemon>() | |
| /** | |
| * Run a foreach loop through the output float array containing the probabilities | |
| * corresponding to each label | |
| * @see pokeArray to know what labels are supported | |
| * it here is the list of probabilities for the detected pokemons, so we can loop through it easily | |
| */ | |
| it.getOutput<Array<FloatArray>>(0)[0].forEachIndexed { index, fl -> | |
| //Only consider a pokemon when the accuracy is more than 40% | |
| if (fl > .40) | |
| Log.d("Detected Pokemon ", pokeArray[index]) | |
| } | |
| //Update UI here by setting pokeList to the adapter | |
| } | |
| ?.addOnFailureListener { | |
| it.printStackTrace() | |
| fabProgressCircle.hide() | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment