当前位置: 首页 > >

java opencv 旋转90度_OpenCV3 Java图像的旋转(Imgproc.getRotationMatrix2D)

发布时间:

函数说明:


Imgproc.getRotationMatrix2D(Point center, double angle, double scale)


参数详解:


Point center:表示旋转的中心点;


double angle:表示旋转的角度;


double scale:图像缩放因子;


代码案例:package?com.what21.opencv.demo;


import?org.opencv.core.Core;


import?org.opencv.core.Mat;


import?org.opencv.core.Point;


import?org.opencv.imgcodecs.Imgcodecs;


import?org.opencv.imgproc.Imgproc;


public?class?Rotate?{


public?static?void?main(String[]?args)?{


System.loadLibrary(Core.NATIVE_LIBRARY_NAME);


Mat?src=Imgcodecs.imread("D:/ShareData/internet.jpg");


//读取图像到矩阵中,取灰度图像


if(src.empty()){


return?;


}


try{


Mat?dst=src.clone();


//复制矩阵进入dst


Point?center?=new?Point(src.width()/2.0,src.height()/2.0);


Mat?affineTrans=Imgproc.getRotationMatrix2D(center,?33.0,?1.0);


Imgproc.warpAffine(src,?dst,?affineTrans,?dst.size(),Imgproc.INTER_NEAREST);


Imgcodecs.imwrite("D:/ShareData/internet.033.jpg",dst);


affineTrans=Imgproc.getRotationMatrix2D(center,?110.0,?1.1);


Imgproc.warpAffine(src,dst,affineTrans,dst.size(),Imgproc.INTER_NEAREST);


Imgcodecs.imwrite("D:/ShareData/internet.110.jpg",dst);


}catch(Exception?e){


e.printStackTrace();


}


}


}







相关资源:利用openCV实现图像旋转C++程序源代码



友情链接: