且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Matlab中将世界坐标转换为像素索引

更新时间:2023-02-11 11:10:25

我讨厌破灭您的泡沫,但您要的是不可能的.我能想到的在现实世界中的坐标和像素坐标之间能够对应的唯一方法是校准用于捕获图像的相机.一旦知道了内在和外在参数,便有了一个转换矩阵,可以将现实世界的坐标映射到像素坐标.

I hate to burst your bubble, but what you are asking for is impossible. The only way that I can think of where you are able to get a correspondence between real-world co-ordinates and pixel co-ordinates is if you calibrate the camera that was used to capture the images. Once you know the intrinsic and extrinsic parameters, you then have a transformation matrix that can map real-world co-ordinates to pixel co-ordinates.

我假设您没有相机的校准信息,因此另一种方法是知道图像中的哪些像素映射到实际坐标.您将需要知道在真实世界和图像之间映射的那些点之间的点对应关系.一旦知道了这一点,便可以通过最小二乘法计算相机变换矩阵,然后使用该矩阵确定从现实世界到图像的点映射.

I'm assuming you don't have calibration information for your camera, and so an alternative approach would be knowing which pixels in your image map to which real-world co-ordinates. You would need to know point correspondences between those points that map between the real-world and to your image. Once you know this, you would then compute the camera transformation matrix through least-squares and then you would use this matrix to determine which points map from the real-world to your image.

除非您与每个现实世界坐标都有像素对应,否则您将无法完成自己要问的事情.

Unless you have pixel correspondences to each of your real-world co-ordinates, it is impossible to do what you're asking.

FWIW,如果您想查看有关如何获取转换矩阵的过程,请查看以下注释: http://www.peterhillman.org.uk/downloads/whitepapers/calibration.pdf .当我开始学习相机校准时,这对我来说是一个很好的起点.看一下第5节(第8页),因为我相信这是您正在寻找的....但是您将需要在真实坐标和图像之间建立对应关系.

FWIW, if you want to see the procedure on how to obtain the transformation matrix, check out these notes: http://www.peterhillman.org.uk/downloads/whitepapers/calibration.pdf. This was a great starting point for me when I started learning about camera calibration. Take a look at Section #5 (Page #8), as this is what I believe you are looking for.... but you will need to have correspondences between the real-world co-ordinates and your image.

祝你好运!