使用opencv的摄像头预览图像是逆时针旋转90度的。
c++的方法多一点,我就想java也有直接的办法。参考API后看到这样一个方法,在Imgproc类下。
API说明:
getRotationMatrix2D
public static Mat getRotationMatrix2D(Point center,
double angle,
double scale)
Calculates an affine matrix of 2D rotation.
The function calculates the following matrix:
alpha beta(1- alpha) * center.x - beta * center.y - beta alpha beta * center.x + (1- alpha) * center.y
where
alpha = scale * cos angle, beta = scale * sin angle
The transformation maps the rotation center to itself. If this is not the target, adjust the shift.
Parameters:
center - Center of the rotation in the source image.
angle - Rotation angle in degrees. Positive values mean counter-clockwise rotation (the coordinate origin is assumed to be the top-left corner).
scale - Isotropic scale factor.<