Skip to content

Instantly share code, notes, and snippets.

@frogermcs
Created June 9, 2019 12:23
Show Gist options
  • Save frogermcs/bde663003e9498cbcc4461edab458224 to your computer and use it in GitHub Desktop.
Save frogermcs/bde663003e9498cbcc4461edab458224 to your computer and use it in GitHub Desktop.
public class ClassificationFrameProcessor implements FrameProcessor {
private final ModelClassificator modelClassificator;
private final ClassificationListener classificationListener;
public ClassificationFrameProcessor(ModelClassificator modelClassificator,
ClassificationListener classificationListener) {
this.modelClassificator = modelClassificator;
this.classificationListener = classificationListener;
}
@Override
public void process(@NonNull Frame frame) {
Bitmap bitmap = frameToBitmap(frame);
List<ClassificationResult> results = modelClassificator.process(bitmap);
classificationListener.onClassifiedFrame(results);
}
private Bitmap frameToBitmap(Frame frame) {
/* Conversion code specific for data from CameraView library. */
}
public interface ClassificationListener {
void onClassifiedFrame(List<ClassificationResult> classificationResults);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment