Python使用新的相机位置创建图像 [英] Python create image with new camera position

查看:110
本文介绍了Python使用新的相机位置创建图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在为一项特定的计算机视觉任务而苦苦挣扎.想象一下,例如,我们有一条道路的摄像机镜框.现在,我想用水平移动的假想摄像机生成一个新帧.此外,还增加了一个微小的摄像头角度.为了说明这一点,我上传了一个演示图像:

I'm struggling with a specific computer vision task right now. Imagine we have a camera frame of a road for example. Now I want to generate a new frame with the imaginary camera translated horizontally. In addition, there's also a tiny camera angle added. To illustrate this, I uploaded a demonstration image:

如何用python中的原始框架创建新框架? 对于其他计算机视觉任务,我已经在使用OpenCV.

How can I create the new frame out of the original one in python? For my other computer vision tasks I was using OpenCV already.

推荐答案

如果您要平移,请更改图像的平面,这可以使用Homography矩阵来完成.检查透视变换. 此处.

If you are trying to translate, change the plane of the image, that can be done with Homography matrix. Check about perspective transform. Here .

您需要使用矩阵的H(0,2)和H(2,0)值沿X进行平移,然后将图像更改为一个角度,就像在图像中一样.

You need to play with the values H(0,2) and H(2,0) of the matrix to translate along X and then change the image to an angle, like in your image.

首先找到具有相同图像的Homography矩阵,然后更改矩阵的上述位置值并将其变形.你会得到想要的.

First find the Homography matrix with the same image and then change the above position values of the matrix and warp it. You will get as you wanted.

编辑:全息摄影术只是一个3x3矩阵.每个矩阵元素对应于图像上的特定操作.

Edit: Homography is simply a 3x3 matrix. Each matrix element corresponds to a specific manipulation on the image.

Like处于0x0位置的元素将水平拉伸图像.位于1x0位置的元素会使图像倾斜.就像保持左边缘静止不动,然后向下拉右边缘一样.同样,其他元素也会执行各自的操作.

Like The element in 0x0 position stretches the image horizontally. The element at 1x0 position skew'es the image. Like keeping the left edge still and pulling down the right edge. Like wise, other elements do their respective operations.

现在在单应性矩阵中,将2x0和0x2处的元素分配给您想要的任务.即,移动平面并沿X方向移动.通过使用这些值进行更改(播放),您将获得不同的图像视角.因此,这也称为透视变换.

Now in the homography matrix, the elements at 2x0 and 0x2 are assigned for the task you wanted. ie, Shifting the plane and Moving along the X direction. By changing (playing) with those values, you get different perspectives of the image. This is hence also called perspective transform.

这篇关于Python使用新的相机位置创建图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆