1) Create member variable of class TextureView (Instantiate under OnCreate)
2) Instantiate memeber variable of class TextureView.SurfaceTextureListener
Requires:
setUpCamera(width,height); // get camera id, preview size connectCamera(); // open camera and set cameraDevice. Requires camera id, camera listener, backgroundhandler
3) Create member variable of class CameraDevice
4) Instantiate member variable of class CameraDEvice.StateCallBack
Requires:
mCameraDevice = camera; startPreview(); // stream image buffer
5) Create a string variable for cameraId
6) Create a Size variable for previewSize
7) Implement setUpCamera(int width, int height)
a) Find the required camera Id from CameraManager
b) Calculate the preview size for textureView
8) Create and implement methods for BackgroundHandler
9) Add permission to access camera and request permission access under onCreate
<uses-permission android:name="android.permission.CAMERA" />10) Implement connectCamera
if(ContextCompat.checkSelfPermission(this, Manifest.permission.CAMERA) == 0) cameraManager.openCamera(mCameraId,mCameraDeviceStateCallback,mBackgroundHandler);
11) Implement startPreview (called when camera is open by CameraDeice.StateCallback)
a) Get SurfaceTexture and set preview size
b) Create CaptureRequestBuilder and add preview surface as target
c) Set CameraDevice.createCaptureSession
mCameraDevice.createCaptureSession(Arrays.asList(previewSurface), new CameraCaptureSession.StateCallback(){ build builder}, null);
12) Implement OnResume and Onpause methods to reset cameraDevice and Backgroundhandler