1

I have 2 Files:

  1. Camera Activity
  2. FaceDetectionProcessor(Firebase MLKit)

I have implemented Firebase MLKit for Face detection in my app. It consists of a file FaceDetectionProcessor having an onSuccess method which is called on each camera frame. I have passed a TextView to this file that needs to be updated from onSuccess.

Issue: The code gets executed but the value to the TextView does not update.

Observations:

  1. The TextView value updates when called from the constructor of FaceDetectionProcessor but does not update when called from onSuccess(). Tried using runInUIThread() and AsyncTaskThread(doInBackground) but didn't work.

  2. Since the call to onSuccess is continuous, AsyncTaskThread crashes the app with error that the task is already executed.

CameraActivity:

/*Call to the FaceDetectionProcessor' constructor*/
cameraSource.setMachineLearningFrameProcessor(new 
    FaceDetectionProcessor (this, getResources(), requestCode, 
    cameraSource, myTextView));

FaceDetectionProcessor:

@Override
protected void onSuccess(
        @Nullable Bitmap originalCameraImage,
        @NonNull List<FirebaseVisionFace> faces,
        @NonNull FrameMetadata frameMetadata,
        @NonNull GraphicOverlay graphicOverlay) {
    myTextView.setText("someValue");
}
James Z
  • 12,209
  • 10
  • 24
  • 44

0 Answers0