使用 OpenCV 将图像旋转 90 度的最简单方法? [英] Easiest way to rotate by 90 degrees an image using OpenCV?

查看:60
本文介绍了使用 OpenCV 将图像旋转 90 度的最简单方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将 IplImage/cv::Mat 旋转 90 度的最佳方法是什么(在 c/c++ 中)?我认为一定有比使用矩阵转换它更好的东西,但我似乎在 API 和在线中找不到其他任何东西.

What is the best way (in c/c++) to rotate an IplImage/cv::Mat by 90 degrees? I would assume that there must be something better than transforming it using a matrix, but I can't seem to find anything other than that in the API and online.

推荐答案

从 OpenCV3.2 开始,生活变得更简单了,您现在可以在一行代码中旋转图像:

As of OpenCV3.2, life just got a bit easier, you can now rotate an image in a single line of code:

cv::rotate(image, image, cv::ROTATE_90_CLOCKWISE);

对于方向,您可以选择以下任何一项:

For the direction you can choose any of the following:

ROTATE_90_CLOCKWISE
ROTATE_180
ROTATE_90_COUNTERCLOCKWISE

这篇关于使用 OpenCV 将图像旋转 90 度的最简单方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆