-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpatch.h
77 lines (58 loc) · 2.06 KB
/
patch.h
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
70
71
72
73
74
75
76
77
#pragma once
#include "image.h"
#ifdef BOOST
#include <boost/archive/text_oarchive.hpp>
#include <boost/archive/text_iarchive.hpp>
#include <boost/serialization/array.hpp>
#include <boost/serialization/split_member.hpp>
#include <fstream>
#endif
class Patch : public Image {
public:
int32_t theta_;
double * heat_map_;
bool * foreground;
Patch(int32_t x, int32_t y, uint8_t *rgb, double * heatmap);
Patch() = default;
bool operator==(const Patch &o) const;
size_t Hash(void);
static size_t Hash(int32_t theta, int32_t id);
inline double * getHeatMapRef(int32_t *x, int32_t *y) {
return &heat_map_[*x * (y_) + *y];
}
inline size_t heatMapSize(void) const {
#ifdef DEBUG
if (x_ * y_ == 0)
printf("ERROR NO HEATMAP MEMORY\n");
#endif
return (x_ * y_ * sizeof(double));
}
#ifdef BOOST
friend class boost::serialization::access;
private:
//need to add the foreground dumping/loading
template <typename Archive>
void load(Archive &ar, const unsigned int version) {
ar & id_;
ar & x_;
ar & y_;
ar & n_;
rgb_ =(unsigned char *) malloc(imageSize());
ar & boost::serialization::make_array(rgb_, (size_t)imageSize());
heat_map_ = (double *)malloc(heatMapSize());
ar & boost::serialization::make_array(heat_map_, (size_t)heatMapSize());
ar & theta_;
}
template <typename Archive>
void save (Archive &ar, const unsigned int version) const {
ar & id_;
ar & x_;
ar & y_;
ar & n_;
ar & boost::serialization::make_array(rgb_, imageSize());
ar & boost::serialization::make_array(heat_map_, heatMapSize());
ar & theta_;
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
#endif
};