Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
mCameraSource = new CameraSource.Builder(getApplicationContext(), mTextRecognizer)
.setFacing(CameraSource.CAMERA_FACING_BACK)
.setRequestedPreviewSize(1280, 1024)
.setRequestedFps(15.0f)
.setAutoFocusEnabled(true)
.build();
mSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override
public void surfaceCreated(SurfaceHolder holder) {
if (ActivityCompat.checkSelfPermission(getApplicationContext(), Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED) {
try {
mCameraSource.start(mSurfaceView.getHolder());
} catch (IOException e) {
e.printStackTrace();
}
} else {
askCameraPermission();
}
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
mCameraSource.stop();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment