I have 2 Files:
- Camera Activity
- 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:
The
TextView
value updates when called from the constructor ofFaceDetectionProcessor
but does not update when called fromonSuccess()
. Tried usingrunInUIThread()
andAsyncTaskThread(doInBackground)
but didn't work.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");
}