blob: f7259bbab17fba15dc2bd7f73f3c77218ee7bfad (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
//Chris Xiong 2022
//License: MPL-2.0
#ifndef SIGNATURE_DB_HPP
#define SIGNATURE_DB_HPP
#include <filesystem>
#include <vector>
#include "signature.hpp"
namespace fs = std::filesystem;
struct subslice_t {size_t id; size_t slice;};
struct dupe_t {size_t id1, id2; double distance;};
struct signature_db_priv;
class signature_db
{
private:
signature_db_priv *p;
public:
signature_db();
~signature_db();
//insert image signature into database
//id must be unique
void put_signature(size_t id, const fs::path &path, const signature &sig);
//get image signature from database
std::pair<fs::path, signature> get_signature(size_t id);
//place batch_put_subslice_begin() and batch_end() around a group of
//put_subslice() calls to improve performance
void batch_put_subslice_begin();
//insert subslice into database
//(id, slice) must be unique
//calling put_subslice_begin() before this is NOT required, but
//will improve performance
void put_subslice(size_t id, size_t slice, const signature &slicesig);
//same thing as put_subslice_begin()
void batch_find_subslice_begin();
//find identical subslices from database
std::vector<subslice_t> find_subslice(const signature &slicesig);
//call this to finish a batch
void batch_end();
void put_dupe_pair(size_t ida, size_t idb, double dist);
std::vector<dupe_t> dupe_pairs();
void lock();
void unlock();
bool to_db_file(const fs::path &path);
bool from_db_file(const fs::path &path);
};
#endif
|