I am making an application in which I have to take a picture every one second in a service without launching the camera preview.
I wrote the following code in service and able to take picture.
if (cameraId < 0) {
Log.d(TAG, "No camera found");
}
else
{
camera = Camera.open(cameraId);
camera.startPreview();
}
camera.takePicture(null, null, bitmapHandler);
In the bitmapHandler class I get the capture image data in
@Override
public void onPictureTaken(byte[] data, Camera camera) {
.
.
.
}
- when I take the picture in portrait mode, the resultant image is rotated by 90 degree clockwise.
- when I take the picture in landscape mode, the resultant image is proper.
- when I take the picture in reverse-landscape mode, the resultant image is rotated by 180 degree
- when I take the picture in reverse-portrait mode, the resultant image is rotated by 270 degree What i did to get proper image so that I can feed that image to my neural network.
What I tried : I am rotating the bitmap by 90 when image was taken in portrait mode, but still not able to find in which mode the image was captured.
Does the Camera API have any way to know or control the rotation angle ?