34 #include <opencv2/core.hpp>
53 : container(_container), orig(_orig)
57 operator()(
size_t i1,
size_t i2)
59 float x1 = container[i1].first.x - orig.x, x2 = container[i2].first.x - orig.x;
60 float y1 = container[i1].first.y - orig.y, y2 = container[i2].first.y - orig.y;
61 float z1 = container[i1].first.z - orig.z, z2 = container[i2].first.z - orig.z;
62 float d1 = x1 * x1 + y1 * y1 + z1 * z1;
63 float d2 = x2 * x2 + y2 * y2 + z2 * z2;
80 operator()(
size_t i1,
size_t i2)
82 return (container[i1].second->
size() > container[i2].second->
size());
97 : container(_container), orig(_orig), dist_limit(_dist_limit)
101 operator()(
size_t i)
const
103 float x = container[i].first.x - orig.x;
104 float y = container[i].first.y - orig.y;
105 float z = container[i].first.z - orig.z;
106 float d = x * x + y * y + z * z;
107 if (d <= dist_limit * dist_limit)
200 Add(
const cv::Point3f &_pos,
const T &_data)
225 typename std::vector<node_type>::iterator iter_d;
226 iter_d =
data.begin();
227 for (
size_t i = 0; i < index; i++)
233 template <
typename Compare>
242 template <
typename Test>
246 std::vector<size_t>::iterator iter;
263 class Iterator :
public std::iterator<std::forward_iterator_tag, node_type>
267 std::vector<size_t>::iterator iter;
274 : container(_container), iter(_iter)
280 return container->
data[*iter];
285 return &(operator*());
294 operator==(
const Iterator &_m)
const
296 return iter == _m.iter;
299 operator!=(
const Iterator &_m)
const
301 return iter != _m.iter;
335 return iter.GetIndex();
350 for (; i <
data.size(); ++i) {
351 if (
data[i].second.get() == p)
Iterator for going through the items in Container3d in the specified order.
Generic container to store any information in 3D (features, photos, ...)
int Limit(Test test)
Limit the search space with external limitation.
Iterator begin()
Provides an iterator pointing to the beginning of the limited/sorted 3D content.
size_t size() const
Get number of items that can be referenced using operator[]()
void ResetSearchSpace()
Reset the search space to contain whole data.
std::vector< size_t > search_space
Possibly limited set of indices for data in somehow "optimal" search order.
void Add(const cv::Point3f &_pos, const T &_data)
Add _data in the container and associate it with 3D position _pos.
node_type & operator[](size_t index)
Instead of Iterator we can use also absolute references for data with operator[]()
void Clear()
Clear the container.
int Sort(Compare comp)
Sort using external Compare method.
Iterator end()
Provides an iterator pointing to the end of the limited/sorted 3D content.
size_t GetIndex(Iterator &iter)
Get absolute reference usable with operator[]() based on the iterator.
std::vector< node_type > data
the actual data in using node_type: pair<cv::Point3f, T>
size_t GetIndex(T *p)
Get absolute reference usable with operator[]() based on the content.
void Erase(size_t index)
Erase item in the container.
std::pair< cv::Point3f, T > node_type
node_type for storing data. 3D-position is paired with the data content.
Functor class for Container3d Limit() to limit the search space with distance.
Functor class for Container3d Sort() to sort the search base using distance to specified origin.
Functor class for Container3d Sort() to sort the search base using content size.