Krotos Modules 3
Loading...
Searching...
No Matches
NearestNeighbourSearch2D.h
Go to the documentation of this file.
1#pragma once
2
3#include <array>
4#include <cassert>
5#include <vector>
6#include "hnswlib/hnswlib.h"
7
8namespace krotos
9{
11{
12 std::vector<float> data;
13 int index = 0;
14 static constexpr int dim = 2;
15};
16
18{
19 // Hnswlib - fast approximate nearest neighbor search
20 // https://github.com/nmslib/hnswlib
21
22 public:
23 NearestNeighbourSearch2D(int max_elements);
25
26 void addDatasetItem(float x, float y);
27 int knnQuery(float x, float y);
28 std::vector<int> knnQuery(float x, float y, int k);
29
30 private:
32 std::unique_ptr<hnswlib::BruteforceSearch<float>> alg;
34
35 std::unique_ptr<hnswlib::L2Space> m_spaceInstance;
36};
37
38} // namespace krotos
Definition hnswlib.h:142
Definition NearestNeighbourSearch2D.h:18
std::unique_ptr< hnswlib::L2Space > m_spaceInstance
Definition NearestNeighbourSearch2D.h:35
void addDatasetItem(float x, float y)
Definition NearestNeighbourSearch2D.cpp:26
Dataset2D dataset
Definition NearestNeighbourSearch2D.h:31
int knnQuery(float x, float y)
Definition NearestNeighbourSearch2D.cpp:34
hnswlib::SpaceInterface< float > * space
Definition NearestNeighbourSearch2D.h:33
~NearestNeighbourSearch2D()
Definition NearestNeighbourSearch2D.cpp:20
NearestNeighbourSearch2D(int max_elements)
Definition NearestNeighbourSearch2D.cpp:6
std::unique_ptr< hnswlib::BruteforceSearch< float > > alg
Definition NearestNeighbourSearch2D.h:32
Definition AirAbsorptionFilter.cpp:2
Definition NearestNeighbourSearch2D.h:11
static constexpr int dim
Definition NearestNeighbourSearch2D.h:14
int index
Definition NearestNeighbourSearch2D.h:13
std::vector< float > data
Definition NearestNeighbourSearch2D.h:12