Last active
March 1, 2018 13:51
-
-
Save nandantal/876db0ab5b1192a5b5acef9c14a4e61a 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
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