|
jiajia7797|
2020-6-28 16:30:50
|
显示全部楼层
调用android原生摄像头传参的方法:- private String mCameraId = "0";//摄像头id(通常0代表后置摄像头,1代表前置摄像头。注意:豹小秘没有前置摄像头,但后置摄像头放在了前面,请开发者注意)
- /**打开摄像头*/
- @SuppressLint("MissingPermission")
- public void openCamera() {
- Log.i(TAG, "openCamera");
- CameraManager manager = (CameraManager) mContext.getSystemService(Context.CAMERA_SERVICE);
- //设置摄像头特性
- imageReader = ImageReader.newInstance(mWidth, mHeight,
- ImageFormat.JPEG, 2);
- //设置获取图片的监听
- imageReader.setOnImageAvailableListener(imageAvailableListener,null);
- // 获取最佳的预览尺寸
- previewSize = new Size(mWidth, mHeight);
- try {
- manager.openCamera(mCameraId, stateCallback, null);
- } catch (CameraAccessException e){
- e.printStackTrace();
- }
- }
复制代码
|
|