CamerAwesome
CamerAwesome copied to clipboard
mirrorFrontCamera:true and Sensor.position(SensorPosition.back) ,turn iPhone left or right ,preview screen is reverse
Steps to Reproduce
mirrorFrontCamera:true and Sensor.position(SensorPosition.back) ,turn iPhone left or right ,preview screen is reverse
iOS is Error ,Android is ok
I reviewed the source code and found that the mirrorFrontCamera parameter is not being used. Therefore, setting the mirrorFrontCamera parameter has no effect.
According to the documentation, the setMirrorFrontCamera method can be called through the state to set the front camera mirror. However, I cannot find how to call the setMirrorFrontCamera method!
Then I reviewed the source code regarding the implementation of setMirrorFrontCamera, and now I know how to call this method.
First, you need to import the package:
import 'package:camerawesome/pigeon.dart';
Then you can call the method:
// Assuming you have a reference to the state object
CameraInterface().setMirrorFrontCamera(false);
It works on my iPhone, I hope this can be helpful to you!
Did you find any solution? Also having this problem
The same
So for anyone who need a solution, don't mirror the front camera but save flip the image you get with image_editor
cameraAwesomeBuilder.awesome(
onMediaCaptureEvent: (mediaCapture) async {
if (mediaCapture.status == MediaCaptureStatus.success && mediaCapture.captureRequest.path != null) {
final sensorPosition = mediaCapture.captureRequest.when(
single: (single) => single.sensor.position,
);
final mediaCaptureFile = File(mediaCapture.captureRequest.path!);
//on iOS, force the front camera picture to be mirrored
if (sensorPosition == SensorPosition.front && mediaCapture.isPicture && Platform.isIOS) {
final correctedImage = ImageEditor.editImage(
image: imageBytes,
imageEditorOption: ImageEditorOption()..addOption(const FlipOption()),
);
if (correctedImage != null) {
await mediaCaptureFile.writeAsBytes(correctedImage);
//then save your file
}
}
}
},
So for anyone who need a solution, don't mirror the front camera but save flip the image you get with image_editor
cameraAwesomeBuilder.awesome( onMediaCaptureEvent: (mediaCapture) async { if (mediaCapture.status == MediaCaptureStatus.success && mediaCapture.captureRequest.path != null) { final sensorPosition = mediaCapture.captureRequest.when( single: (single) => single.sensor.position, ); final mediaCaptureFile = File(mediaCapture.captureRequest.path!); //on iOS, force the front camera picture to be mirrored if (sensorPosition == SensorPosition.front && mediaCapture.isPicture && Platform.isIOS) { final correctedImage = ImageEditor.editImage( image: imageBytes, imageEditorOption: ImageEditorOption()..addOption(const FlipOption()), ); if (correctedImage != null) { await mediaCaptureFile.writeAsBytes(correctedImage); //then save your file } } } },
Thanks! this worked like a charm