Opencv学习----图像处理的应用-图片变形(扭曲图片)

void ES::ImageProcessing::imageWarpOper(cv::Mat* dst)
{
	Mat src = imread("lena.jpg", IMREAD_COLOR);
	cv::resize(src, src, Size(src.rows / 4 * 3, src.cols / 4 * 3));
	Mat mat;
	const int rows = src.rows;
	const int cols = src.cols;
	std::vector> srcPts;
	srcPts.push_back(cv::Point_(0, 0));
	srcPts.push_back(cv::Point_(0, (int)(rows / 2)));
	srcPts.push_back(cv::Point_(0, rows));
	std::vector> tarPts;
	tarPts.push_back(cv::Point_(0, 0));
	tarPts.push_back(cv::Point_(80, (int)(rows / 2)));
	tarPts.push_back(cv::Point_(0, rows));
	ImageWarpAlgrithm imgWarpAlgo;
	bool res = imgWarpAlgo.generateWarpMat(mat, src, srcPts, tarPts, src.cols, src.rows);

	Mat mergeMat(src.rows, src.cols + mat.cols, src.type());
	Mat submat = mergeMat.colRange(0, src.cols);
	src.copyTo(submat);
	submat = mergeMat.colRange(src.cols, src.cols + mat.cols);
	mat.copyTo(submat);
	mergeMat.copyTo(*dst);
}

Opencv学习----图像处理的应用-图片变形(扭曲图片)_第1张图片

你可能感兴趣的:(Opencv)