You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
55 lines
1.4 KiB
55 lines
1.4 KiB
#pragma once
|
|
|
|
#include "image_io.hpp"
|
|
|
|
#include <boost/serialization/access.hpp>
|
|
#include <boost/serialization/array.hpp>
|
|
#include <boost/serialization/utility.hpp>
|
|
|
|
#include <utility>
|
|
#include <array>
|
|
#include <iosfwd>
|
|
|
|
namespace boost {
|
|
namespace serialization {
|
|
template<class Archive, class T, size_t N>
|
|
void serialize(Archive & ar, std::array<T,N> & a, const unsigned int /*version*/) {
|
|
ar & make_array(a.data(), a.size());
|
|
}
|
|
} // namespace serialization
|
|
} // namespace boost
|
|
|
|
// Default implementation
|
|
template <typename Fingerprint>
|
|
struct fingerprint_traits {
|
|
static Fingerprint calculate(raw_rgb_image const & image) {
|
|
return Fingerprint::calculate(image);
|
|
}
|
|
|
|
static auto distance(Fingerprint const & x, Fingerprint const & y) {
|
|
return x.distance_to(y);
|
|
}
|
|
};
|
|
|
|
struct rgb_wavelet_coefficients {
|
|
// a double for (x, y) location represented in a single int
|
|
using coefficient = std::pair<int, double>;
|
|
|
|
std::array<coefficient, 20> reds;
|
|
std::array<coefficient, 20> greens;
|
|
std::array<coefficient, 20> blues;
|
|
|
|
static rgb_wavelet_coefficients calculate(raw_rgb_image const & image);
|
|
double distance_to(rgb_wavelet_coefficients const & y) const;
|
|
|
|
private:
|
|
friend class boost::serialization::access;
|
|
template<class Archive>
|
|
void serialize(Archive & ar, const unsigned int /*version*/){
|
|
ar & reds;
|
|
ar & greens;
|
|
ar & blues;
|
|
}
|
|
};
|
|
|
|
std::ostream& operator<<(std::ostream& out, rgb_wavelet_coefficients const & x);
|
|
|