The following code is used to scale and rotate an image.
Opencv version: 2.4.2
// Image rotation and scaling // Author: www.icvpr.com // blog: http://blog.csdn.net/icvpr # include <iostream> # include <vector> # include <opencv2/opencv. HPP> int main (INT argc, char ** argv) {CV: mat image = CV: imread (".. /test.jpg "); If (image. empty () {STD: cout <"read image failure" <STD: Endl; Return-1;} CV: point2f center = CV :: point2f (image. cols/2, image. rows/2); // rotation center double angle = 30; // Rotation Angle double scale = 0.5; // scaling scale CV: mat rotatemat; rotatemat = CV :: getrotationmatrix2d (center, angle, scale); CV: mat rotateimg; CV: warpaffine (image, rotateimg, rotatemat, image. size (); CV: imwrite (".. /rotate.jpg ", rotateimg); Return 0 ;}
Source image:
Scaling:
Rotation:
Rotation + Scaling
Related content: www.icvpr.com
-------------------------------------------------------
<Reprint Please note: http://blog.csdn.net/icvpr>