AndroidScannerDemo icon indicating copy to clipboard operation
AndroidScannerDemo copied to clipboard

Rotate image

Open ajaybarvey opened this issue 8 years ago • 9 comments

Hello, The example is working fine. How do I rotate the image? What is the api to use for rotation?

ajaybarvey avatar Jun 05 '16 18:06 ajaybarvey

yes same is my question Pls tell how to rotate image

sunil-singh-chaudhary avatar Jun 06 '16 05:06 sunil-singh-chaudhary

imageView.setRotation(imageView.getRotation() + 90);

waqasawan44 avatar Jun 09 '16 02:06 waqasawan44

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); }

waqasawan44 avatar Jun 09 '16 02:06 waqasawan44

tnx but i want to rotate it using Opencv

sunil-singh-chaudhary avatar Jun 09 '16 05:06 sunil-singh-chaudhary

no idea

waqasawan44 avatar Jun 10 '16 15:06 waqasawan44

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.

shivanraptor avatar Nov 15 '16 10:11 shivanraptor

+1

mario002e avatar Feb 04 '17 12:02 mario002e

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

abhigarg avatar Mar 30 '17 08:03 abhigarg

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;
}

klaszlo8207 avatar Nov 15 '17 08:11 klaszlo8207