【发布时间】:2023-01-18 01:25:39
【问题描述】:
因此,我尝试通过首先考虑将相机放置在地面上并捕获图像来实现逻辑,我首先计算图像上最底部像素沿 y 轴与图像上的 px 和 py 坐标之间的距离,然后我将该距离乘以结果转化为现实生活该图像的像素所覆盖的真实生活距离的值。现在我的任务是重新计算当现在相机被提升到一定高度(与地面成 90 度角)时的距离。现在我如何重新计算新相机位置(即在某个高度)与该相机在新位置拍摄的图像上的点之间的距离?
// point of image along y-axis until ground is visible
const int groundY = 50;
// real life distance from origin (i.e. from where camera is placed and image bottom most point along y-axis) to point where ground is visible in image
const int realLifeGroundDist = 200;
const int cameraHeight = 40;
void geoLocation(int ***a, int x, int y, int z, int px, int py){
double onePixelDistance = realLifeGroundDist/groundY;
// double distBtwPixels = sqrt(pow(px - ((x/2)-1), 2) + pow(py - (y-1), 2) * 1);
// Distance formula to calculate dist btw origin and (px,py) pixel
double distBtwPixels = sqrt(pow(px - (x-1), 2) + pow(py - ((y/2)-1), 2) * 1);
//translating pixel distance to real life distance
double h = distBtwPixels * onePixelDistance;
//considering that camera is placed above ground at some height i.e. cameraHeight variable at angle = 90deg and calculating distance btw that point and camera i.e. hypteneuse
double realLifeDist = sqrt(pow(h, 2) + pow(cameraHeight, 2));
cout<<"Distance between camera and px and py coordinates in image = "<<realLifeDist;
}
根据我的逻辑,realLifeDist 保持放置在新位置的相机捕获的图像上的点之间的距离,即在距地面一定高度处,与地面成 90 度角。我的逻辑正确吗?如果不是,那我该如何计算呢?
【问题讨论】:
-
这似乎是一道数学题而不是编程题。考虑改为询问math.stackexchange.com。
-
由于您的视锥通常是金字塔,因此给定 dstBtwPixels 的 realLifeDist 取决于与相机的距离。如果该距离在您的场景中可以改变,则无法计算 realLifeDist。
-
你有深度信息吗?图像上的一个像素对应于整条射线在 3D 中。