-
-
Save mcpotter/bad3f1e91ff3b35c459f37dbf4c3eec7 to your computer and use it in GitHub Desktop.
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
public void init() { | |
//... | |
for (int i = 0; i < numberOfCameras; i++) { | |
Camera.getCameraInfo(i, ci); | |
if (ci.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) { | |
isFrontFacing = true; | |
break; | |
} | |
} | |
//... | |
FaceDetector detector = | |
new FaceDetector | |
.Builder(context) | |
.setLandmarkType(FaceDetector.ALL_LANDMARKS) | |
.setClassificationType(FaceDetector.ALL_CLASSIFICATIONS) | |
.setTrackingEnabled(true) | |
.setMode(FaceDetector.FAST_MODE) | |
.setProminentFaceOnly(isFrontFacing) | |
.setMinFaceSize(isFrontFacing ? 0.35f : 0.15f) | |
.build(); | |
Detector.Processor<Face> processor; | |
if (isFrontFacing) { | |
Tracker<Face> tracker = new FaceTracker(overlay); | |
processor = | |
new LargestFaceFocusingProcessor.Builder(detector, tracker).build(); | |
} else { | |
MultiProcessor.Factory<Face> factory = face -> new FaceTracker(overlay); | |
processor = new MultiProcessor.Builder<>(factory).build(); | |
} | |
detector.setProcessor(processor); | |
cameraSource = | |
new CameraSource | |
.Builder(context, detector) | |
.setFacing(facing) | |
.setRequestedPreviewSize(defaultWidth, defaultHeight) | |
.setRequestedFps(60.0f) | |
.setAutoFocusEnabled(true) | |
.build(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment