jhansireddy / AndroidScannerDemo

ScanLibrary is an android document scanning library built on top of OpenCV, using the app you will be able to select the exact edges and crop the document accordingly from the selected 4 edges and change the perspective transformation of the cropped image.
MIT License
1.07k stars 472 forks source link

Rotate image #21

Open ajaybarvey opened 8 years ago

ajaybarvey commented 8 years ago

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

sunil-singh-chaudhary commented 8 years ago

yes same is my question Pls tell how to rotate image

waqasawan44 commented 8 years ago

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

waqasawan44 commented 8 years ago

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

sunil-singh-chaudhary commented 8 years ago

tnx but i want to rotate it using Opencv

waqasawan44 commented 8 years ago

no idea

shivanraptor commented 7 years ago

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.

mario002e commented 7 years ago

+1

abhigarg commented 7 years ago

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

klaszlo8207 commented 6 years ago

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