74 const std::vector<vpRBSilhouettePoint> &previousPoints,
long randomSeed)
const
76 const unsigned int rows = validSilhouette.
getHeight();
77 const unsigned int cols = validSilhouette.
getWidth();
78 std::vector<std::pair<unsigned int, unsigned int>> finalCandidates;
79 std::vector<std::pair<unsigned int, unsigned int>> candidates;
81 finalCandidates.reserve(m_maxNumPoints);
82 candidates.reserve(m_maxNumPoints);
85 if (m_preferPreviousPoints) {
87 double x = 0.0, y = 0.0;
94 unsigned nu =
static_cast<unsigned int>(round(x)), nv =
static_cast<unsigned int>(round(y));
95 if (nu > 0 && nv > 0 && nv < rows && nu < cols) {
96 if (validSilhouette[nv][nu] > 0 && fabs((renderDepth[nv][nu] / p.Z) - 1.0) < 0.01) {
97 finalCandidates.push_back(std::make_pair(nv, nu));
102 if (m_maxNumPoints > 0 && finalCandidates.size() >=
static_cast<unsigned int>(m_maxNumPoints)) {
103 return finalCandidates;
106 for (
unsigned int n = m_border; n < rows - m_border; n += m_sampleStep) {
107 for (
unsigned int m = m_border; m < cols - m_border; m += m_sampleStep) {
108 if (validSilhouette[n][m] > 0) {
109 candidates.push_back(std::make_pair(n, m));
113 if (m_maxNumPoints > 0) {
115 std::vector<size_t> indices(m_maxNumPoints - finalCandidates.size());
116 sampleWithoutReplacement(
static_cast<size_t>(m_maxNumPoints) - finalCandidates.size(), candidates.size(), indices, random);
117 for (
unsigned int i = 0; i < indices.size(); ++i) {
118 finalCandidates.push_back(candidates[indices[i]]);
122 for (
unsigned int i = 0; i < candidates.size(); ++i) {
123 finalCandidates.push_back(candidates[i]);
126 return finalCandidates;