Pre-record: Today I suddenly found out that the project code I just opened had several warnings in eclipse, Camera is deprecated, camera.parameters was deprecated ... and other warnings that have been discarded. A look at official documents originally Google this time Android version update to the camera this piece of new alternative classAndroid.hardware.camera2. This class encapsulates a camera device into a multi-level, linear pipeline with multiple processing stages, which is used to process each frame captured in the input request. When a photo is requested by CAMERA2 to the system, an output packet with a set of image buffers is returned. If multiple requests are processed sequentially, multiple repeated requests are sent only once. using the new API: 1. Get Cameramanager instances to traverse, query, and open a camera object. 2. Research by Cameramanager ObjectGetcameracharacteristics (String) to obtain the Cameracharacteristics object that contains the device's setup information and output parameters. 3. Pre-set each preview object through the Cameracapturesession object, such as size and format, which must be supported by the device, and can call Camera.createcapturesession (List, Cameracapturesession.statecallback, Handler)to obtain this object.
4. Create Surfaceview Ortextureview (via its surfacetexture). Renders the image. The system is at the bottom or calls Renderscript or opengles, or even native local methods to the data that the instance passes to the view. 5. Construct a Capturerequest object that describes the specific settings for each capture picture. 6. Finally call the capture () method to finish capturing the image.
Precautions :If you fail to open or get a camera object with a Cameramanager object, or if you attempt to connect to an already open device to throw an exception, remember to catch and handle the exception with Cameraaccessexception.
Android 5.0 Lollipop new Webcam API