opencv之WarpPerspective透视变化

这段代码演示了如何使用OpenCV库实现图像的透视变换。通过定义源和目标三角形坐标,然后应用`cvGetPerspectiveTransform`计算变换矩阵,最后使用`cvWarpPerspective`执行实际的透视变换。变换后的图像显示在'Affine_Transform'窗口中。
摘要由CSDN通过智能技术生成
// opencv2.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/features2d/features2d.hpp"  
#include "cv.h"
#include "highgui.h"
#include <cxcore.h>
using namespace cv;
using namespace std;




int main(int argc, char **argv)
{
	CvPoint2D32f srcTri[4], dstTri[4];
	CvMat*       warp_mat = cvCreateMat(3, 3, CV_32FC1);
	IplImage*    src = NULL;
	IplImage*    dst = NULL;

	src = cvLoadImage("test.jpg", 1);
	dst = cvCloneImage(src);
	dst->origin = src->origin;
	cvZero(dst);

	srcTri[0].x = 0;
	srcTri[0].y = 0;
	srcTri[1].x = src->width - 1;
	srcTri[1].y = 0;
	srcTri[2].x = 0;
	srcTri[2].y = src->height - 1;
	srcTri[3].x = src->width - 1;
	srcTri[3].y = src->height - 1;

	dstTri[0].x = src->width 
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

vqt5_qt6

你的鼓励是我们创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值