blob: b3c5c4063155fc5f35fbe8f0c6afdb9679f389d0 (
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
61
62
63
64
65
66
67
68
69
|
#ifndef SIGNATURE_HPP
#define SIGNATURE_HPP
#include <memory>
#include <opencv2/core.hpp>
struct signature_config
{
int slices;
int blur_window;
int min_window;
bool crop;
bool compress;
double pr;
double noise_threshold;
double contrast_threshold;
double max_cropping;
};
class signature_priv;
class signature
{
private:
std::shared_ptr<signature_priv> p;
signature(signature_priv* _p);
signature(const signature&)=default;
signature& operator=(const signature&)=default;
public:
signature();
~signature();
signature(signature&&)=default;
signature& operator=(signature&&)=default;
signature clone() const;//do not use unless absolutely needed
void dump() const;
double length() const;
double distance(const signature &o) const;
bool operator ==(const signature &o) const;
static signature from_file(const char *fn, const signature_config &cfg);
/*
* Input will be stripped of alpha channel (by blending with white),
* converted to single channel (rgb2gray).
* Then it will be passed to from_preprocessed_matrix.
* The matrix doesn't have to be continuous.
*/
static signature from_cvmatrix(cv::Mat m, const signature_config &cfg);
/*
* Input must be a single channel, floating point matrix
* (values clamped to 0-1)
* The matrix must be continuous if cropping is used
* STILL *Will* be cropped if config().crop == true
* STILL *Will* be blurred if config().blur_window > 1
*/
static signature from_preprocessed_matrix(cv::Mat m, const signature_config &cfg);
static signature_config default_cfg();
friend class signature_priv;
friend struct signature_hash;
};
struct signature_hash
{
size_t operator()(signature const& sig) const noexcept;
};
#endif
|