获取View Frustum的6个平面

 在3D图形学中,一种优化的手法,叫做物体剔除(Object Culling)。这种技术的提出是基于这样的策略:我们不希望将不存在View Frustum里面的物体送往流水线中进行处理。虽然,你可能会说,现在的图形卡都已近支持了三角形剔除的技术。但是,不要忘了流水线的步骤。我们是先进行Vertex Processing,然后才进行Geometry Processing。而图形卡对三角形的剔除是在Geometry Processing这个阶段进行的。也就是说,即使能够剔除它们,我们依然要在Vertex Processing中对这些将来需要丢弃的顶点进行Vertex Processing处理。而我们知道,Vertex Processing这个阶段往往会进行坐标变换,光照计算等等费时的操作。所以,如果能够在Vertex Processing之前,也就是在Application阶段,在我们的CPU中将这些根本不需要处理的物体剔除的话,会大大的提高程序的效率。而想要将物体剔除,我们就需要知道这个物体是否在View Frustum中。而为了判断这个条件,我们就需要确定构成View Frustum的6个平面的方程。所以,本篇文章,就向大家讲述,如何获取View Frustum的6个平面方程。


void Frustum::createPlane(const Camera* camera)

{

    const Mat4& mat = camera->getViewProjectionMatrix();  //获得视图投影矩阵

    //ref http://www.lighthouse3d.com/tutorials/view-frustum-culling/clip-space-approach-extracting-the-planes/

    //extract frustum plane

    //  (X x a11 + Y x a12 + Z x a13 + a14) + (X x a41 + Y x a42 + Z x a43 + a44) > 0

    //  X(a11 + a41) + Y(a12 + a42) + Z(a13 + a43) + a14 + a44 > 0

    // 负数大概是因为 p.n = d p就是(x,y,z,n就是(a11 + a41a12 + a42a13 + a43 d如果不变的话,n就应该取负数

    _plane[0].initPlane(-Vec3(mat.m[3] + mat.m[0], mat.m[7] + mat.m[4], mat.m[11] + mat.m[8]), (mat.m[15] + mat.m[12]));//left

    _plane[1].initPlane(-Vec3(mat.m[3] - mat.m[0], mat.m[7] - mat.m[4], mat.m[11] - mat.m[8]), (mat.m[15] - mat.m[12]));//right

    _plane[2].initPlane(-Vec3(mat.m[3] + mat.m[1], mat.m[7] + mat.m[5], mat.m[11] + mat.m[9]), (mat.m[15] + mat.m[13]));//bottom

    _plane[3].initPlane(-Vec3(mat.m[3] - mat.m[1], mat.m[7] - mat.m[5], mat.m[11] - mat.m[9]), (mat.m[15] - mat.m[13]));//top

    _plane[4].initPlane(-Vec3(mat.m[3] + mat.m[2], mat.m[7] + mat.m[6], mat.m[11] + mat.m[10]), (mat.m[15] + mat.m[14]));//near

    _plane[5].initPlane(-Vec3(mat.m[3] - mat.m[2], mat.m[7] - mat.m[6], mat.m[11] - mat.m[10]), (mat.m[15] - mat.m[14]));//far

}








Clip Space Approach – Extracting the Planes

  

In here another approach to extract the view frustum planes is presented based on the properties of clip space.

Consider a point p =(x,y,z,1) on the 3D world. Consider also a modelview matrix Mand a projection matrix P. The point p is transformed by matrices M and P as point pc =(xc,yc,zc,wc) in clip space using:

The point pc is in homogeneous coordinates, and when normalised becomes pcn:

In normalised clip space the view frustum is an axis aligned box centered in the origin, and bounded by the following planes:

  • Left Plane: x’ = -1
  • Right Plane: x’ = 1
  • Top Plane: y’ = 1
  • Bottom Plane: y’ = -1
  • Near Plane: z’ = -1
  • Far Plane: z’ = 1

This implies that the point pcn =(x’,y’,z’) is inside the view frustum if:

Then the point pc, in non-normalized coordinates, must obbey the following conditions in order to be inside the view frustum:

Based on this information it is possible to extract the six planes, in world coordinates, that bound the view frustum. The point pc is on the “right” side of the left plane if

Consider p and A=MP as described below

Then xc and wc can be defined as a function of p = (x,y,z,w), and A.

Therefore the following inequation must be true if p is on the right side of the left plane.

A little algebraic manipulation gives

So the left plane (Ax+By+Cz+D=0) is defined as:

where col1 and col4 are the first and forth columns of matrix A, respectively.

If the only objective is to find out if a point is inside or outside of the frustum then the plane as defined is ok. However when testing spheres, which require computing the distance from the center of the sphere to the plane, it is advisable to normalize the plane.

The right plane can be obtained in a similar manner:

The following coefficients are obtained for the right plane:

The remaining planes are obtained as follows:

  • Bottom Plane

  • Top Plane

  • Near Plane

  • Far Plane

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
### 回答1: Frustum PointNet是一种基于点云的3D物体检测算法,它可以在给定的3D场景中检测出相对于相机的视锥体(frustum)内的物体。它是由Charles R. Qi等人于2018年提出的,是PointNet的改进版本。 Frustum PointNet的输入是点云,它首先对点云进行预处理,将点云中的点转换到相机坐标系下,并将点云裁剪成视锥体内的点。然后,它使用PointNet对裁剪后的点云进行处理,得到每个点的特征向量。这些特征向量被组合成一个点云特征图(point cloud feature map)。 接下来,Frustum PointNet使用一个3D卷积神经网络(Conv3D)对点云特征图进行处理,以便从中提取3D物体的特征。该3D卷积神经网络由多个3D卷积层和池化层组成,最终输出一个包含物体检测结果的向量。 Frustum PointNet还使用了一种称为ROI pooling的技术,以提高检测准确率。ROI pooling可以将特征图中与视锥体内的物体相对应的区域提取出来,并将这些区域汇总成固定长度的向量。这个向量被送入一个全连接网络(fully connected network)进行分类,最终得到物体的类别和位置。 总的来说,Frustum PointNet是一种有效的3D物体检测算法,它通过点云和3D卷积神经网络对物体进行特征提取,并能够在相机视锥体内准确地检测出物体。 ### 回答2: Frustum PointNet是一种基于PointNet网络的目标检测方法,主要用于三维点云数据中的物体检测和定位。它的核心思想是将点云数据转换为局部坐标系中的规范化点云,并通过PointNet来提取特征并预测目标的属性。 首先,Frustum PointNet使用视锥体(frustum)来将三维点云数据进行裁剪,只保留与摄像机视角有重叠的部分点云。这样可以将点云数据减少到相对较小的规模,提高计算效率。 其次,Frustum PointNet对裁剪后的点云进行预处理,将点云转换到局部坐标系中。通过坐标变换和旋转操作,将点云对齐到统一的参考坐标系中,使点云的位置信息与摄像机视角一致。 接下来,裁剪和对齐后的点云数据通过PointNet网络进行处理。PointNet网络是一种深度学习网络架构,用于对点云数据提取特征。通过使用多层感知机和最大池化操作,PointNet网络可以学习点云数据的全局特征和局部特征。 最后,Frustum PointNet利用PointNet网络提取的点云特征来预测目标物体的属性,例如类别、位置和姿态。这些属性可以用于实现目标检测和定位。此外,Frustum PointNet还采用了一些技巧来提高检测的精度和效率,例如使用投影损失和多尺度训练等。 总结来说,Frustum PointNet是一种基于PointNet网络的三维目标检测方法,通过裁剪和对齐点云数据,使用PointNet网络提取特征,并通过预测目标属性来实现物体检测和定位。它具有高效的计算和良好的检测精度,在三维物体识别和场景理解领域具有广泛的应用前景。 ### 回答3: Frustum PointNet是一种用于物体检测的神经网络架构。它旨在从点云数据中准确地检测和定位物体,尤其是在自动驾驶和机器人技术中有着重要的应用。 Frustum PointNet的核心思想是将三维空间中的物体表示为从相机视角获取的视锥体(frustum)。首先,利用2D物体检测方法,从图像中确定目标物体的边界框。接下来,通过投影将边界框对应到点云中,从而得到相应的三维视锥体。然后,Frustum PointNet将这些视锥体内的点云输入网络进行处理。 在Frustum PointNet中,首先通过一个全连接神经网络对输入的点云进行特征提取。然后,使用PointNet提取每个点的特征表示。PointNet是一种先进的点云处理网络,能够学习到点云的全局特征和局部特征。之后,对每个视锥体内的点云特征进行池化操作,得到整个视锥体的特征表示。最后,通过一个全连接神经网络进行分类和回归,实现目标物体的检测和定位。 Frustum PointNet的优点是可以直接从点云数据中进行物体检测,避免了传统图像方法中的二维到三维转换问题。此外,它能够从点云中学习到点的全局和局部特征,更好地适应不同形状和尺寸的物体。通过使用视锥体,Frustum PointNet能够根据不同相机视角下的点云数据进行物体检测,具有更好的泛化能力。 总结来说,Frustum PointNet是一种利用视锥体和PointNet网络的神经网络架构,用于点云数据中的物体检测和定位。它能够从点云中学习到全局和局部特征,并根据不同相机视角的数据进行准确的物体检测和定位。在自动驾驶和机器人技术等领域具有重要的应用价值。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值