Comprueba qué cámara está abierta al frente o atrás Android
Sé que puedo establecer unboolean flag while opening front Camera
. Y si la bandera es verdadera, significa que la cámara frontal está encendida.
Pero, ¿hay alguna manera de usar la API de Android para saber qué cámara está abierta en este momento? Delante o detrás.
public int getFrontCameraId() {
CameraInfo ci = new CameraInfo();
for (int i = 0 ; i < Camera.getNumberOfCameras(); i++) {
Camera.getCameraInfo(i, ci);
if (ci.facing == CameraInfo.CAMERA_FACING_FRONT) return i;
}
return -1; // No front-facing camera found
}
La vista previa de la cámara se invierte (arriba) cuando abro la cámara frontal. Así que tengo que agregar un cheque qué cámara está abiertaif FrontCamera is opened then matrix = 270. otherwise matrix =90.
onPreviewFrame (byte abyte0 [], Cámara cámara)
int[] rgbData = YuvUtils.decodeGreyscale(abyte0, mWidth,mHeight);
editedBitmap.setPixels(rgbData, 0, widthPreview, 0, 0, widthPreview, heightPreview);
finalBitmap = Bitmap.createBitmap(editedBitmap, 0, 0, widthPreview, heightPreview, matrix, true);