使用固有矩阵从等距矩形图像中查找与球面坐标相对应的相机内像素

问题描述

我如何知道球坐标是否在针孔相机/内在矩阵的视图内? 我有一个大小为 2048 x 1024 的空等距柱状图。我想遍历等距柱状图像素并将像素位置转换为球面坐标,并找出尺寸为 1280 x 720 像素的相机,以及具有已知偏航、俯仰和滚转的 90 x 45 度 FOV 看到这一点。如果点可见,我们将对应于球面坐标的正确像素复制到等距柱状图图像中。由于相机在游戏内,因此相机 FOV 和尺寸已知且 100% 准确,因此无需校准等。

Mat eul2rotm(double rotx,double roty,double rotz)//pitch,yaw,roll ///industry standard is Z-Y-X because that corresponds to yaw,pitch and roll :/
{
    cv::Mat R_x = (cv::Mat_<double>(3,3) << 
        1,cos(rotx),-sin(rotx),sin(rotx),cos(rotx));

    cv::Mat R_y = (cv::Mat_<double>(3,3) << 
        cos(roty),sin(roty),1,-sin(roty),cos(roty));

    cv::Mat R_z = (cv::Mat_<double>(3,3) << 
        cos(rotz),-sin(rotz),sin(rotz),cos(rotz),1);

    cv::Mat R = R_z * R_y * R_x;

    return R;
}

double radians(double degrees)
{
        return degrees * pi / 180;
}




double yaw,pitch,roll;
yaw = radians(0);  
pitch = radians(0); 
roll = radians(0);


Mat Rot = eul2rotm(pitch,roll);

int w,h;
w = 1280;
h = 720;

#define FOV2FOCAL(pixelssensorsize,fov) ((pixelssensorsize) / (2 * tan((fov) / 2)))
double fx = FOV2FOCAL(w,radians(90));
double fy = FOV2FOCAL(h,radians(45));

Mat K = (cv::Mat_<double>(3,3) <<//Camera 1280 x 720 pixels / 90 x 45 degrees
            fx,w / 2,fy,h / 2,1);






//function loops through all the pixels inside the EquirectangularImage/EquirectangularCanvas.
for (int v = 0; v < EquirectangularImageHeight; ++v)//EquirectangularImageHeight = 1024
    {
        for (int u = 0; u < EquirectangularImageWidth; ++u)//EquirectangularImageWidth = 2048
        {
           /*This posision 0,0 at center*/
           double Longitude = -M_PI + 2 * M_PI * u / _EquirectangularImage.Width;
           double Latitude = M_PI / 2 - M_PI * v / _EquirectangularImage.Height;


           RK = Rot * K.inv();
           //Than here we should check if camera see point corresponding to the spherical coordinates.
           //and if point is visible we find the corresponding pixel and copy it into the Equirectangular image.
           //This is the place i am stuck at. How can i know if point is visible and anslo find the correct point in the camera/image to copy the pixel from?

        }
    }

如果使用内在矩阵不是最好的方法,那么其他方法也可以。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...