Skip to content

Commit

Permalink
Fix face detector settings not being applied on first run (expo#2308)
Browse files Browse the repository at this point in the history
  • Loading branch information
sjchmiela authored Oct 10, 2018
1 parent 6928377 commit 5655751
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public class ExpoCameraView extends CameraView implements LifecycleEventListener
// Scanning-related properties
private BarCodeScanner mBarCodeScanner;
private FaceDetector mFaceDetector;
private Map<String, Object> mPendingFaceDetectorSettings;
private boolean mShouldDetectFaces = false;
private boolean mShouldScanBarCodes = false;

Expand Down Expand Up @@ -270,6 +271,10 @@ public void onHostResume() {
FaceDetectorProvider faceDetectorProvider = mModuleRegistry.getModule(FaceDetectorProvider.class);
if (faceDetectorProvider != null) {
mFaceDetector = faceDetectorProvider.createFaceDetectorWithContext(getContext());
if (mPendingFaceDetectorSettings != null) {
mFaceDetector.setSettings(mPendingFaceDetectorSettings);
mPendingFaceDetectorSettings = null;
}
}
}
}
Expand Down Expand Up @@ -308,7 +313,9 @@ public void setShouldDetectFaces(boolean shouldDetectFaces) {
}

public void setFaceDetectorSettings(Map<String, Object> settings) {
if (mFaceDetector != null) {
if (mFaceDetector == null) {
mPendingFaceDetectorSettings = settings;
} else {
mFaceDetector.setSettings(settings);
}
}
Expand Down

0 comments on commit 5655751

Please sign in to comment.