37 #ifndef PCL_GPU_FEATURES_DEVICE_PAIR_FEATURES_HPP_
38 #define PCL_GPU_FEATURES_DEVICE_PAIR_FEATURES_HPP_
40 #include <pcl/gpu/utils/device/vector_math.hpp>
41 #include <pcl/gpu/features/device/rodrigues.hpp>
47 __device__ __host__ __forceinline__
48 bool computePairFeatures (
const float3& p1,
const float3& n1,
const float3& p2,
const float3& n2,
float &f1,
float &f2,
float &f3,
float &f4)
50 f1 = f2 = f3 = f4 = 0.0f;
52 float3 dp2p1 = p2 - p1;
58 float3 n1_copy = n1, n2_copy = n2;
59 float angle1 =
dot(n1_copy, dp2p1) / f4;
62 float angle2 =
dot(n2_copy, dp2p1) / f4;
63 if (std::acos (std::abs (angle1)) > std::acos (std::abs (angle2)))
76 float3 v =
cross(dp2p1, n1_copy);
77 float v_norm =
norm(v);
87 float3 w =
cross(n1_copy, v);
89 f1 = std::atan2 (
dot(w, n2_copy),
dot(n1_copy, n2_copy));
94 __device__ __host__ __forceinline__
95 bool computeRGBPairFeatures (
const float3& p1,
const float3& n1,
const int& colors1,
const float3& p2,
const float3& n2,
const int& colors2,
96 float &f1,
float &f2,
float &f3,
float &f4,
float &f5,
float &f6,
float &f7)
98 float3 dp2p1 = p2 - p1;
103 f1 = f2 = f3 = f4 = f5 = f6 = f7 = 0.0f;
107 float3 n1_copy = n1, n2_copy = n2;
108 float angle1 =
dot(n1_copy, dp2p1) / f4;
114 float3 v =
cross(dp2p1, n1_copy);
115 float v_norm =
norm(v);
118 f1 = f2 = f3 = f4 = f5 = f6 = f7 = 0.0f;
124 float3 w =
cross(n1_copy, v);
127 f2 =
dot(v, n2_copy);
130 f1 = std::atan2 (
dot(w, n2_copy),
dot (n1_copy, n2_copy));
135 f5 = ((float) ((colors1 ) & 0xFF)) / ((colors2 ) & 0xFF);
136 f6 = ((float) ((colors1 >> 8) & 0xFF)) / ((colors2 >> 8) & 0xFF);
137 f7 = ((float) ((colors1 >> 16) & 0xFF)) / ((colors2 >> 16) & 0xFF);
140 if (f5 > 1.f) f5 = - 1.f / f5;
141 if (f6 > 1.f) f6 = - 1.f / f6;
142 if (f7 > 1.f) f7 = - 1.f / f7;
147 __device__ __host__ __forceinline__
150 f5 = ((float) ((colors1 ) & 0xFF)) / ((colors2 ) & 0xFF);
151 f6 = ((float) ((colors1 >> 8) & 0xFF)) / ((colors2 >> 8) & 0xFF);
152 f7 = ((float) ((colors1 >> 16) & 0xFF)) / ((colors2 >> 16) & 0xFF);
155 if (f5 > 1.f) f5 = - 1.f / f5;
156 if (f6 > 1.f) f6 = - 1.f / f6;
157 if (f7 > 1.f) f7 = - 1.f / f7;
160 __device__ __host__ __forceinline__
bool computePPFPairFeature(
const float3& p1,
const float3& n1,
const float3& p2,
const float3& n2,
161 float& f1,
float& f2,
float& f3,
float& f4)
163 float3 delta = p2 - p1;
179 __device__ __host__ __forceinline__
void computeAlfaM(
const float3& model_reference_point,
const float3& model_reference_normal,
180 const float3& model_point,
float& alpha_m)
182 float acos_value = std::acos (model_reference_normal.x);
185 float3 cross_vector = make_float3(0, model_reference_normal.z, - model_reference_normal.y);
186 float3 cross_vector_norm =
normalized(cross_vector);
191 float3 row1, row2, row3;
192 AngleAxisf(acos_value, cross_vector_norm, row1, row2, row3);
196 translation.y = row2.x * -model_reference_point.x + row2.y * -model_reference_point.y + row2.z * -model_reference_point.z;
197 translation.z = row3.x * -model_reference_point.x + row3.y * -model_reference_point.y + row3.z * -model_reference_point.z;
199 float3 model_point_transformed;
201 model_point_transformed.y = translation.y + row2.x * model_point.x + row2.y * model_point.y + row2.z * model_point.z;
202 model_point_transformed.z = translation.z + row3.x * model_point.x + row3.y * model_point.y + row3.z * model_point.z;
205 float angle = std::atan2 ( -model_point_transformed.z, model_point_transformed.y);
207 if (sinf(angle) * model_point_transformed.z < 0.0f)
__device__ __host__ __forceinline__ bool computePPFPairFeature(const float3 &p1, const float3 &n1, const float3 &p2, const float3 &n2, float &f1, float &f2, float &f3, float &f4)
__device__ __forceinline__ float3 normalized(const float3 &v)
__device__ __host__ __forceinline__ bool computePairFeatures(const float3 &p1, const float3 &n1, const float3 &p2, const float3 &n2, float &f1, float &f2, float &f3, float &f4)
__device__ __host__ __forceinline__ void computeAlfaM(const float3 &model_reference_point, const float3 &model_reference_normal, const float3 &model_point, float &alpha_m)
__device__ __forceinline__ float dot(const float3 &v1, const float3 &v2)
__device__ __host__ __forceinline__ float norm(const float3 &v1, const float3 &v2)
__device__ __host__ __forceinline__ bool computeRGBPairFeatures(const float3 &p1, const float3 &n1, const int &colors1, const float3 &p2, const float3 &n2, const int &colors2, float &f1, float &f2, float &f3, float &f4, float &f5, float &f6, float &f7)
__device__ __host__ __forceinline__ void computeRGBPairFeatures_RGBOnly(const int &colors1, const int &colors2, float &f5, float &f6, float &f7)
__device__ __host__ __forceinline__ float3 cross(const float3 &v1, const float3 &v2)
__device__ __host__ __forceinline__ void AngleAxisf(float angle, const float3 &r, float3 &row1, float3 &row2, float3 &row3)