Files
opencv-MIRROR/modules/ptcloud/perf/perf_normal_estimation.cpp
kirtijindal14 90add0d6fe normal cleanup
2026-09-25 15:56:49 +05:30

40 lines
1.2 KiB
C++

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
#include "perf_precomp.hpp"
#include "opencv2/geometry/segment.hpp" // cv::normalEstimate
namespace opencv_test { namespace {
using namespace perf;
// Evenly sampled unit sphere (Fibonacci) of the requested size.
static Mat makeSphere(int n)
{
std::vector<Point3f> pts;
pts.reserve(n);
const float ga = (float)(CV_PI * (3.0 - std::sqrt(5.0)));
for (int i = 0; i < n; i++)
{
float z = 1.f - 2.f * (i + 0.5f) / n;
float r = std::sqrt(std::max(0.f, 1.f - z * z));
float t = ga * i;
pts.emplace_back(r * std::cos(t), r * std::sin(t), z);
}
return Mat(pts).clone();
}
typedef TestBaseWithParam<int> Ptcloud_NormalPerf;
PERF_TEST_P(Ptcloud_NormalPerf, orient_consistent, testing::Values(50000, 150000))
{
Mat cloud = makeSphere(GetParam());
Mat normals, curv;
normalEstimate(normals, curv, cloud, noArray(), 30); // normals to orient (geometry)
TEST_CYCLE() orientNormalsConsistent(cloud, normals, 30);
SANITY_CHECK_NOTHING();
}
}} // namespace