Recently, I met a customer's demand that when I was taking a pre shot, I didn't need a mirror preview, and I didn't need a mirror image for the photos I took.
For koppelin, the reason for the front image is to let the lens face itself. When the mirror is used, it is specially designed in this way.
Since the customer has a request, it has to be revised.
Through various channels, I wanted to insert a code chip here to modify the code through the driver layer before, but my driving colleagues told me that preview can be modified, and the photos taken can't be modified.
The photos taken can only be modified in the application layer, so you can only find the source code on the AP side.
This code is based on Qualcomm's android 7.1 platform.
packages\apps\SnapdragonCamera\src\com\android\camera\PhotoModule.java
private void setFlipValue() { // Read Flip mode from adb command //value: 0(default) - FLIP_MODE_OFF //value: 1 - FLIP_MODE_H //value: 2 - FLIP_MODE_V //value: 3 - FLIP_MODE_VH int preview_flip_value = SystemProperties.getInt("debug.camera.preview.flip", 0); int video_flip_value = SystemProperties.getInt("debug.camera.video.flip", 0); int picture_flip_value = SystemProperties.getInt("debug.camera.picture.flip", 0); int rotation = CameraUtil.getJpegRotation(mCameraId, mOrientation); mParameters.setRotation(rotation); if (rotation == 90 || rotation == 270) { // in case of 90 or 270 degree, V/H flip should reverse if (preview_flip_value == 1) { preview_flip_value = 2; } else if (preview_flip_value == 2) { preview_flip_value = 1; } if (video_flip_value == 1) { video_flip_value = 2; } else if (video_flip_value == 2) { video_flip_value = 1; } if (picture_flip_value == 1) { picture_flip_value = 2; } else if (picture_flip_value == 2) { picture_flip_value = 1; } } String preview_flip = CameraUtil.getFilpModeString(preview_flip_value); String video_flip = CameraUtil.getFilpModeString(video_flip_value); String picture_flip = CameraUtil.getFilpModeString(picture_flip_value); if(CameraUtil.isSupported(preview_flip, CameraSettings.getSupportedFlipMode(mParameters))){ mParameters.set(CameraSettings.KEY_QC_PREVIEW_FLIP, preview_flip); } if(CameraUtil.isSupported(video_flip, CameraSettings.getSupportedFlipMode(mParameters))){ mParameters.set(CameraSettings.KEY_QC_VIDEO_FLIP, video_flip); } if(CameraUtil.isSupported(picture_flip, CameraSettings.getSupportedFlipMode(mParameters))){ mParameters.set(CameraSettings.KEY_QC_SNAPSHOT_PICTURE_FLIP, picture_flip); } }
Find this function,
Add log.
private void setFlipValue() { // Read Flip mode from adb command //value: 0(default) - FLIP_MODE_OFF //value: 1 - FLIP_MODE_H //value: 2 - FLIP_MODE_V //value: 3 - FLIP_MODE_VH int preview_flip_value = SystemProperties.getInt("debug.camera.preview.flip", 0); int video_flip_value = SystemProperties.getInt("debug.camera.video.flip", 0); int picture_flip_value = SystemProperties.getInt("debug.camera.picture.flip", 0); int rotation = CameraUtil.getJpegRotation(mCameraId, mOrientation); Log.d("leo","preview_flip_value-->"+preview_flip_value); Log.d("leo","video_flip_value-->"+video_flip_value); Log.d("leo","picture_flip_value-->"+picture_flip_value); Log.d("leo","rotation-->"+rotation); Log.d("leo","mCameraId-->"+mCameraId); Log.d("leo","mOrientation-->"+mOrientation); mParameters.setRotation(rotation); if (rotation == 90 || rotation == 270) { // in case of 90 or 270 degree, V/H flip should reverse if (preview_flip_value == 1) { preview_flip_value = 2; } else if (preview_flip_value == 2) { preview_flip_value = 1; } if (video_flip_value == 1) { video_flip_value = 2; } else if (video_flip_value == 2) { video_flip_value = 1; } if (picture_flip_value == 1) { picture_flip_value = 2; } else if (picture_flip_value == 2) { picture_flip_value = 1; } } String preview_flip = CameraUtil.getFilpModeString(preview_flip_value); String video_flip = CameraUtil.getFilpModeString(video_flip_value); String picture_flip = CameraUtil.getFilpModeString(picture_flip_value); Log.d("leo","preview_flip-->"+preview_flip); Log.d("leo","video_flip-->"+video_flip); Log.d("leo","picture_flip-->"+picture_flip); if(CameraUtil.isSupported(preview_flip, CameraSettings.getSupportedFlipMode(mParameters))){ mParameters.set(CameraSettings.KEY_QC_PREVIEW_FLIP, preview_flip); } if(CameraUtil.isSupported(video_flip, CameraSettings.getSupportedFlipMode(mParameters))){ mParameters.set(CameraSettings.KEY_QC_VIDEO_FLIP, video_flip); } if(CameraUtil.isSupported(picture_flip, CameraSettings.getSupportedFlipMode(mParameters))){ mParameters.set(CameraSettings.KEY_QC_SNAPSHOT_PICTURE_FLIP, picture_flip); } }
In this part of the code,
mParameters.set
When setting the camera's properties, there will be a flip property. This property can be used to set whether the photos taken are mirrored, v direction or h direction.
If you need to modify, you can refer to the following:
private void setFlipValue() { // Read Flip mode from adb command //value: 0(default) - FLIP_MODE_OFF //value: 1 - FLIP_MODE_H //value: 2 - FLIP_MODE_V //value: 3 - FLIP_MODE_VH int preview_flip_value = SystemProperties.getInt("debug.camera.preview.flip", 0); int video_flip_value = SystemProperties.getInt("debug.camera.video.flip", 0); int picture_flip_value = SystemProperties.getInt("debug.camera.picture.flip", 0); int rotation = CameraUtil.getJpegRotation(mCameraId, mOrientation); Log.d("leo","preview_flip_value-->"+preview_flip_value); Log.d("leo","video_flip_value-->"+video_flip_value); Log.d("leo","picture_flip_value-->"+picture_flip_value); Log.d("leo","rotation-->"+rotation); Log.d("leo","mCameraId-->"+mCameraId); Log.d("leo","mOrientation-->"+mOrientation); // Add a judgment on cameraiId in this place, that is, you can judge an id if you want to mirror a camera, // The modification of filp is also based on your needs. Here, I just need to modify the image after taking a picture. Then, modify the picture "flip" value if(2 == mCameraId){ picture_flip_value = 2; } mParameters.setRotation(rotation); if (rotation == 90 || rotation == 270) { // in case of 90 or 270 degree, V/H flip should reverse if (preview_flip_value == 1) { preview_flip_value = 2; } else if (preview_flip_value == 2) { preview_flip_value = 1; } if (video_flip_value == 1) { video_flip_value = 2; } else if (video_flip_value == 2) { video_flip_value = 1; } if (picture_flip_value == 1) { picture_flip_value = 2; } else if (picture_flip_value == 2) { picture_flip_value = 1; } } String preview_flip = CameraUtil.getFilpModeString(preview_flip_value); String video_flip = CameraUtil.getFilpModeString(video_flip_value); String picture_flip = CameraUtil.getFilpModeString(picture_flip_value); Log.d("leo","preview_flip-->"+preview_flip); Log.d("leo","video_flip-->"+video_flip); Log.d("leo","picture_flip-->"+picture_flip); if(CameraUtil.isSupported(preview_flip, CameraSettings.getSupportedFlipMode(mParameters))){ mParameters.set(CameraSettings.KEY_QC_PREVIEW_FLIP, preview_flip); } if(CameraUtil.isSupported(video_flip, CameraSettings.getSupportedFlipMode(mParameters))){ mParameters.set(CameraSettings.KEY_QC_VIDEO_FLIP, video_flip); } if(CameraUtil.isSupported(picture_flip, CameraSettings.getSupportedFlipMode(mParameters))){ mParameters.set(CameraSettings.KEY_QC_SNAPSHOT_PICTURE_FLIP, picture_flip); } }