CVB++ 14.0
DNC/CppDncConsole
1// ---------------------------------------------------------------------------
5// ---------------------------------------------------------------------------
6
7#include <iostream>
8
9#include <cvb/point_cloud_factory.hpp>
10#include <cvb/point_cloud.hpp>
11#include <cvb/dense_point_cloud.hpp>
12#include <cvb/dnc/finder.hpp>
13
14int main(int /*argc*/, char* /*argv*/[])
15{
16 try
17 {
18 const auto path = Cvb::InstallPath();
19
20 // Load DNC search pattern
21 std::cout << "Load the search pattern...\n";
22 auto finder = Cvb::Dnc::Finder::Load(path + CVB_LIT("tutorial/DNC/Images/Genie/GenieTest.dnc"));
23
24 // Create a dense point cloud
25 std::cout << "Create a dense point cloud...\n";
26 auto densePointCloud = Cvb::PointCloudFactory::Load<Cvb::DensePointCloud>(path + CVB_LIT("tutorial/DNC/Images/Genie/GenieTest.tif"),
28
29 // Define the search parameteres
30 std::cout << "Define the search parameters...\n";
32 params.SetHypothesesThreshold(0.7);
33 params.SetDerivativePatchSize(3);
34 params.SetIndifferentRadius(1.0);
35 params.SetPartsToFind(0); // find all objects
36 params.SetRawResultsOnly(false);
37 params.SetICPShrink(4);
38 params.SetICPMaxIterations(10);
39 params.SetPrecisionThreshold(2.0);
40 params.SetMinCoverage(0.70);
41 params.SetMaxOcclusion(0.20);
42 params.SetMaxInconsistency(0.20);
43 params.SetMinScore(0.70);
44
45 // Start the search
46 std::cout << "Run the search on the point cloud...\n";
47 auto searchResult = finder->Find(*densePointCloud, params);
48
49 // Output of the search result
50 std::cout << "Number of search results: " << searchResult.size() << "\n";
51
52 int counter = 0;
53 for (const auto& result : searchResult) {
54 std::cout << counter
55 << ": position(x=" << result.Position().X()
56 << ",y=" << result.Position().Y()
57 << ",z=" << result.Position().Z()
58 << "), rotation(x=" << result.RotationVector().X()
59 << ",y=" << result.RotationVector().Y()
60 << ",z=" << result.RotationVector().Z()
61 << "), theta=" << result.Theta().Deg()
62 << "\370, score=" << result.Score() << "\n";
63 // \370 = to display on console
64 ++counter;
65 }
66 }
67 catch (const std::exception& error)
68 {
69 std::cout << error.what() << std::endl;
70 }
71}
static std::unique_ptr< Finder > Load(const String &fileName)
Loads a finder from the given file name.
Definition: finder.hpp:47
Definition of search parameters.
Definition: search_parameters.hpp:23
void SetMaxInconsistency(double value)
Set maximum inconsistency.
Definition: search_parameters.hpp:309
void SetPrecisionThreshold(double value)
Set precision threshold.
Definition: search_parameters.hpp:229
void SetMaxOcclusion(double value)
Set maximum occlusion.
Definition: search_parameters.hpp:282
void SetHypothesesThreshold(double value)
Set minimum feature score for hypotheses generation.
Definition: search_parameters.hpp:52
void SetMinScore(double value)
Set minimum score.
Definition: search_parameters.hpp:335
void SetDerivativePatchSize(int value)
Set smoothing area in pixels for gradient and normal calculation.
Definition: search_parameters.hpp:78
void SetICPMaxIterations(int value)
Set the maximum number of iterations of the ICP algorithm.
Definition: search_parameters.hpp:203
void SetICPShrink(int value)
Set the subsample factor for ICP.
Definition: search_parameters.hpp:177
void SetMinCoverage(double value)
Set minimum coverage.
Definition: search_parameters.hpp:255
void SetPartsToFind(int value)
Set the maximum number of objects to find.
Definition: search_parameters.hpp:126
void SetRawResultsOnly(bool value) noexcept
Set the raw results flag.
Definition: search_parameters.hpp:152
void SetIndifferentRadius(double value)
Set fraction of template size which accounts for a single object.
Definition: search_parameters.hpp:102