Skip to content

Instantly share code, notes, and snippets.

@aledalgrande
Last active August 29, 2015 14:06
Show Gist options
  • Save aledalgrande/3999e4ac00f8cf3c6f78 to your computer and use it in GitHub Desktop.
Save aledalgrande/3999e4ac00f8cf3c6f78 to your computer and use it in GitHub Desktop.
Fast 90°, -90°, 180° rotations
// rotate 90° CW: flip the transpose on Y
inline void rotate90CW(cv::Mat& input)
{
cv::flip(input.t(), input, 1);
}
// rotate -90° CW: flip the transpose on X
inline void rotate90CCW(cv::Mat& input)
{
cv::flip(input.t(), input, 0);
}
// rotate 180°: flip on X and Y
inline void rotate180(cv::Mat& input)
{
cv::flip(input, input, -1);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment