美文网首页
(九)pcl-common篇-norms.h

(九)pcl-common篇-norms.h

作者: GoodTekken | 来源:发表于2022-03-03 11:23 被阅读0次

(1)计算两点之间向量的 各种 范数(里面还有各种范数可以选择)

#include<pcl/point_cloud.h>
#include<pcl/point_types.h>
#include<pcl/visualization/pcl_visualizer.h> //cout endl

#include <pcl/common/norms.h>

typedef pcl::PointXYZ PointT;

int main()
{
    //(1)计算两点之间向量的 各种 范数(里面还有各种范数可以选择)
    // brief Enum that defines all the types of norms available.
    // float pcl::selectNorm (FloatVectorT A, FloatVectorT B, int dim, NormType norm_type)
    //{L1, L2_SQR, L2, LINF, JM, B, SUBLINEAR, CS, DIV, PF, K, KL, HIK};
    //http://pointclouds.org/documentation/norms_8hpp_source.html
    //brief Compute the L1 norm of the vector between two points
    Eigen::Vector3f  A(0, 0, 0);
    Eigen::Vector3f  B(1, 2, 3);
    //float a = pcl::selectNorm(A, B, 3, pcl::L1);  //norm += std::abs(a[i] - b[i]);
    float a = pcl::selectNorm(A, B, 3, pcl::SUBLINEAR);  //norm += std::sqrt (std::abs (a[i] - b[i]));

    //(2)以下的函数都是根据第1个函数进行包装
    //float pcl::L1_Norm (FloatVectorT A, FloatVectorT B, int dim)
    float b = pcl::L1_Norm(A, B, 3);

    //2.1 float L1_Norm(FloatVectorT A, FloatVectorT B, int dim)
    //brief Compute the L1 norm of the vector between two points
    //norm += std::abs(a[i] - b[i]);

    //2.2 float L2_Norm_SQR(FloatVectorT A, FloatVectorT B, int dim);
    //brief Compute the squared L2 norm of the vector between two points
    //float diff  =  a[i] - b[i];
    //norm += diff * diff;

    //2.3 float L2_Norm(FloatVectorT A, FloatVectorT B, int dim);
    //brief Compute the L2 norm of the vector between two points
    //return std::sqrt (L2_Norm_SQR(a, b, dim));

    //2.4 float Linf_Norm (FloatVectorT A, FloatVectorT B, int dim);
    //brief Compute the L-infinity norm of the vector between two points
    //norm = (std::max)(std::abs(a[i] - b[i]), norm);

    //2.5 float JM_Norm(FloatVectorT A, FloatVectorT B, int dim);
    //brief Compute the JM norm of the vector between two points
    //norm += (std::sqrt (a[i]) - std::sqrt (b[i])) * (std::sqrt (a[i]) - std::sqrt (b[i]));

    //2.6 float B_Norm(FloatVectorT A, FloatVectorT B, int dim);
    //brief Compute the B norm of the vector between two points
    //for (int i = 0; i < dim; ++i)
    //norm += std::sqrt(a[i] * b[i]);

    //if (norm > 0)
    //  result = -std::log(norm);
    //else
    //  result = 0;

    //2.7 float Sublinear_Norm(FloatVectorT A, FloatVectorT B, int dim);
    //brief Compute the sublinear norm of the vector between two points
    //norm += std::sqrt (std::abs (a[i] - b[i]));

    //2.8 float CS_Norm(FloatVectorT A, FloatVectorT B, int dim);
    //brief Compute the CS norm of the vector between two points
    //for (int i = 0; i < dim; ++i)
    //if ((a[i] + b[i]) != 0)
    //  norm += (a[i] - b[i]) * (a[i] - b[i]) / (a[i] + b[i]);
    //else
    //  norm += 0;

    //2.9 float Div_Norm(FloatVectorT a, FloatVectorT b, int dim)
    //brief Compute the div norm of the vector between two points
    //for (int i = 0; i < dim; ++i)
    //if ((a[i] / b[i]) > 0)
    //  norm += (a[i] - b[i]) * std::log(a[i] / b[i]);
    //else
    //  norm += 0;

    //2.10 float PF_Norm(FloatVectorT a, FloatVectorT b, int dim, float P1, float P2)
    //brief Compute the PF norm of the vector between two points
    //norm += (P1 * a[i] - P2 * b[i]) * (P1 * a[i] - P2 * b[i]);

    //2.11 float K_Norm(FloatVectorT A, FloatVectorT B, int dim, float P1, float P2);
    //brief Compute the K norm of the vector between two points
    //norm += std::abs (P1 * a[i] - P2 * b[i]);

    //2.12 float KL_Norm(FloatVectorT A, FloatVectorT B, int dim);
    //brief Compute the KL between two discrete probability density functions
    //if ((b[i] != 0) && ((a[i] / b[i]) > 0))
    //  norm += a[i] * std::log(a[i] / b[i]);
    //else
    //  norm += 0;

    //2.13  float HIK_Norm(FloatVectorT A, FloatVectorT B, int dim);
    //brief Compute the HIK norm of the vector between two points
    //norm += (std::min)(a[i], b[i]);

    system("pause");
    return 0;
}

参考文章:
http://pointclouds.org/documentation/norms_8h.html
http://pointclouds.org/documentation/norms_8h_source.html
http://pointclouds.org/documentation/norms_8hpp_source.html

相关文章

网友评论

      本文标题:(九)pcl-common篇-norms.h

      本文链接:https://www.haomeiwen.com/subject/aoiyrrtx.html