AndroidScannerDemo
AndroidScannerDemo copied to clipboard
Rotate image
Hello, The example is working fine. How do I rotate the image? What is the api to use for rotation?
yes same is my question Pls tell how to rotate image
imageView.setRotation(imageView.getRotation() + 90);
public static Bitmap RotateBitmap(Bitmap source, float angle) { Matrix matrix = new Matrix(); matrix.postRotate(angle); return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true); }
tnx but i want to rotate it using Opencv
no idea
The image captured from the Camera Activity is rotate 90 degrees. My app is in portrait but I have to take picture in landscape mode. It will be great if the image is rotated to correct orientation based on sensor orientation.
+1
use flip(cv::Mat, rotate_flag) in opencv to rotate the image by 90 or 270 degs or make a mirror image of original. Check this for documentation
Just update the ScanFragment activity:
private Bitmap getBitmap() {
Uri uri = getUri();
try {
Bitmap bitmap = Utils.getBitmap(getActivity(), uri);
Matrix m = new Matrix();
m.postRotate(90);
bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true);
getActivity().getContentResolver().delete(uri, null, null);
return bitmap;
} catch (IOException e) {
e.printStackTrace();
}
return null;
}