Rotate image by 90, 180 or 270 degrees

后端 未结 11 2216
一个人的身影
一个人的身影 2020-12-01 07:48

I need to rotate an image by either 90, 180 or 270 degrees. In OpenCV4Android I can use:

Imgproc.getRotationMatrix2D(new Point(center, center), degrees, 1);         


        
11条回答
  •  失恋的感觉
    2020-12-01 08:28

    Here is a solution using the Android API. Here, I am using it to rotate images from a camera which could be mounted in various orientations.

    if (mCameraOrientation == 270) {
        // Rotate clockwise 270 degrees
        Core.flip(src.t(), dst, 0);
    } else if (mCameraOrientation == 180) {
        // Rotate clockwise 180 degrees
        Core.flip(src, dst, -1);
    } else if (mCameraOrientation == 90) {
        // Rotate clockwise 90 degrees
        Core.flip(src.t(), dst, 1);
    } else if (mCameraOrientation == 0) {
        // No rotation
        dst = src;
    }
    

提交回复
热议问题