Skip to content

Instantly share code, notes, and snippets.

@nandantal
Last active March 1, 2018 13:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nandantal/876db0ab5b1192a5b5acef9c14a4e61a to your computer and use it in GitHub Desktop.
Save nandantal/876db0ab5b1192a5b5acef9c14a4e61a to your computer and use it in GitHub Desktop.
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