Warp Image

For the Image, so you can select any of these cards. Now I’m going to do this king card. So what is the idea behind this first of all we have imported our image, now we need the points that we want to work. so here we are going to write point but the function that we are going to use actually requires floating points. So we are going to use Point2f, instead of just point then we have we have to define the name. so let’s call it source and we will define the size of it, so we will have four points inside of it. So let’s create our points the first one will be 529 and 142, then the second one is (771, 190), so these are the points that I’ve already collected from our image (405, 375) and then we have (674, 457). So there are our source points, and then we will have our destination points, so destination points will be basically a rectangular image. So we have to define that what does this point correspond to, so this point corresponds to (0, 0). So this point over here. Let me bring a circle. So this point over here should be the if let’s say this is my card. So this point over here should be this point then the third will be this and the fourth will be this. So there are the corresponding points. so we have to define it. So here we are going to define that this should be zero. So we cannot just write zero because we have to have floating. So this will be width and 0.0f then we will have 0.0f and height and then we will have width and height. So what is this width and what is the height so this should be the size of our card now I have noted down the size of cards. So they are 2.5 by 3.5 inches. So what we can do is we can keep the same aspect ratio, so we can define here that. Let’s define it down can define here the float width is equal to 250 and the height is equals to 350. So there are source points and then we have our destination points. now we can use a transformation matrix to actually find the work. so in order to transform we need a matrix. So whenever we input the values, we whenever we input the points it will output the corresponding transformed. So we need that matrix. So let’s say this is our matrix is equals to , so we need to define it so we can define here matrix and we will also need our image work so let’s define it here. So , that should be good and then we can define here gets perspective transform, so here we are going to input our source points and our destination points. so this will give us a matrix that will that we can input some values and in the output it will give us the corresponding values. So then we are going to use word perspective the corresponding values. So then we are going to use warpPerspective image then image work and then we will write the matrix that we just found out or create and after the matrix. We have the size. So we are going to given a point and we are going to define the width and the height. Last we can simply display our image.

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值