From ad5c50a9231182b6ec384acccb776282a7a41a4b Mon Sep 17 00:00:00 2001 From: Tetragramm Date: Wed, 2 Nov 2016 17:44:13 -0500 Subject: [PATCH] Improve the efficiency as suggested by vpisarev. Alter the Rotation enum to be unambiguous as to direction. --- modules/core/include/opencv2/core.hpp | 4 ++-- modules/core/src/copy.cpp | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/modules/core/include/opencv2/core.hpp b/modules/core/include/opencv2/core.hpp index 2263272..5208d03 100644 --- a/modules/core/include/opencv2/core.hpp +++ b/modules/core/include/opencv2/core.hpp @@ -1023,9 +1023,9 @@ around both axes. CV_EXPORTS_W void flip(InputArray src, OutputArray dst, int flipCode); enum RotateFlags { - ROTATE_90 = 0, //Rotate 90 degrees clockwise + ROTATE_90_CLOCKWISE = 0, //Rotate 90 degrees clockwise ROTATE_180 = 1, //Rotate 180 degrees clockwise - ROTATE_270 = 2, //Rotate 270 degrees clockwise + ROTATE_90_COUNTERCLOCKWISE = 2, //Rotate 270 degrees clockwise }; /** @brief Rotates a 2D array in multiples of 90 degrees. The function rotate rotates the array in one of three different ways: diff --git a/modules/core/src/copy.cpp b/modules/core/src/copy.cpp index 0310329..259b71c 100644 --- a/modules/core/src/copy.cpp +++ b/modules/core/src/copy.cpp @@ -832,14 +832,16 @@ static bool ocl_rotate(InputArray _src, OutputArray _dst, int rotateMode) { switch (rotateMode) { - case ROTATE_90: - flip(_src.getUMat().t(), _dst, 1); + case ROTATE_90_CLOCKWISE: + _dst.getUMat() = _src.getUMat().t(); + flip(_dst, _dst, 1); break; case ROTATE_180: flip(_src, _dst, -1); break; - case ROTATE_270: - flip(_src.getUMat().t(), _dst, 0); + case ROTATE_90_COUNTERCLOCKWISE: + _dst.getUMat() = _src.getUMat().t(); + flip(_dst, _dst, 0); break; default: break; @@ -856,14 +858,16 @@ void rotate(InputArray _src, OutputArray _dst, int rotateMode) switch (rotateMode) { - case ROTATE_90: - flip(_src.getMat().t(), _dst, 1); + case ROTATE_90_CLOCKWISE: + _dst.getMat() = _src.getMat().t(); + flip(_dst, _dst, 1); break; case ROTATE_180: flip(_src, _dst, -1); break; - case ROTATE_270: - flip(_src.getMat().t(), _dst, 0); + case ROTATE_90_COUNTERCLOCKWISE: + _dst.getMat() = _src.getMat().t(); + flip(_dst, _dst, 0); break; default: break; -- 2.7.4