android opencv旋转角度,Android OpenCV 旋转图像

本文介绍了如何使用Android OpenCV库中的`getRotationMatrix2D`和`warpAffine`方法来实现图像的顺时针90度旋转。通过在`onCameraFrame`方法中应用旋转矩阵,可以将摄像头预览图像进行正确的角度调整。
摘要由CSDN通过智能技术生成

使用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.<

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值