最简单的方法使用OpenCV旋转90度图像

最简单的方法使用OpenCV旋转90度图像

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

问题描述

什么是旋转IplImage / cv :: Mat 90度的最好的方法(在c / c ++中)?我假设必须有一些东西比使用矩阵转换更好,但我似乎找不到除了在API和在线之外的任何东西。

解决方案

换位更新



您应该使用 cvTranspose c $ c>或 cv :: transpose()因为(正确地指出)它更有效率。再次,我建议升级到OpenCV2.0,因为大多数 cvXXX 函数只是将 IplImage * 结构转换为 Mat 对象(无深拷贝)。如果将图像存储在 Mat 对象中, Mat.t()将返回转置。

任何轮换:



您应该使用cvWarpAffine定义一般框架中的旋转矩阵变换矩阵。我强烈建议您升级到,它有几个功能以及 Mat 封装了矩阵和图像的类。使用2.0,您可以使用访问上述内容。


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.

解决方案

Update for transposition:

You should use cvTranspose() or cv::transpose() because (as you rightly pointed out) it's more efficient. Again, I recommend upgrading to OpenCV2.0 since most of the cvXXX functions just convert IplImage* structures to Mat objects (no deep copies). If you stored the image in a Mat object, Mat.t() would return the transpose.

Any rotation:

You should use cvWarpAffine by defining the rotation matrix in the general framework of the transformation matrix. I would highly recommend upgrading to OpenCV2.0 which has several features as well as a Mat class which encapsulates matrices and images. With 2.0 you can use warpAffine to the above.

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

08-31 06:43