Created
January 27, 2022 11:55
-
-
Save nurcinozer/27a182ad8b3c2ac7f2b505c939aa09ed to your computer and use it in GitHub Desktop.
P2-Movie-App-Base-Project/blob/main/app/src/main/java/com/nurcinozer/baumovieapp/v2/ui/movie_detail/MovieDetailActivity.java
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
imageClassificationButton.setOnClickListener(view1 -> { | |
Task<List<MLImageClassification>> task = analyzer.asyncAnalyseFrame(frame); | |
task.addOnSuccessListener(classifications -> { | |
// Recognition success. | |
StringBuilder sb = new StringBuilder(); | |
sb.append("Results: \n\n"); | |
// All classification results will be added to StringBuilder object in a for loop: | |
for (int i = 0; i < classifications.size(); i++) { | |
sb.append("[") | |
.append(i) | |
.append("] ") | |
.append(classifications.get(i).getName()) | |
.append("\n"); | |
} | |
if (classifications.size() > 0) { | |
detectedClassesTv.setText(sb.toString()); | |
} else { | |
detectedClassesTv.setText("Results: \n\n" + "[0] Others"); | |
} | |
// After recognition is completed, release the detection resources: | |
releaseImageDetectionResources(); | |
}).addOnFailureListener(e -> { | |
// Recognition failure. | |
Toast.makeText(this, e.toString(), Toast.LENGTH_SHORT).show();; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment