26 inline bool isEqual(
const Mat &a,
const Mat &b)
29 DGM_ASSERT_MSG(a.size() == b.size(),
"Size mismatch");
30 DGM_ASSERT_MSG(a.type() == b.type(),
"Type mismatch");
33 for (
int j = 0; j < a.rows; j++)
34 if (a.at<T>(j, 0) != b.at<T>(j, 0))
return false;
36 else if (a.rows == 1) {
37 for (
int i = 0; i < a.cols; i++) {
38 if (a.at<T>(0, i) != b.at<T>(0, i))
return false;
42 for (
int j = 0; j < a.rows; j++) {
43 const T *pa = a.ptr<T>(j);
44 const T *pb = b.ptr<T>(j);
45 for (
int i = 0; i < a.cols; i++)
46 if(pa[i] != pb[i])
return false;
61 template <
typename Targ =
float,
typename Tres =
float>
65 DGM_ASSERT_MSG(a.size() == b.size(),
"Size mismatch");
66 DGM_ASSERT_MSG(a.type() == b.type(),
"Type mismatch");
70 for (
int j = 0; j < a.rows; j++)
71 res += (static_cast<Tres>(a.at<Targ>(j, 0)) -
static_cast<Tres
>(b.at<Targ>(j, 0))) * (static_cast<Tres>(a.at<Targ>(j, 0)) - static_cast<Tres>(b.at<Targ>(j, 0)));
73 else if (a.rows == 1) {
74 for (
int i = 0; i < a.cols; i++) {
75 res += (
static_cast<Tres
>(a.at<Targ>(0, i)) -
static_cast<Tres
>(b.at<Targ>(0, i))) * (static_cast<Tres>(a.at<Targ>(0, i)) - static_cast<Tres>(b.at<Targ>(0, i)));
79 for (
int j = 0; j < a.rows; j++) {
80 const Targ *pa = a.ptr<Targ>(j);
81 const Targ *pb = b.ptr<Targ>(j);
82 for (
int i = 0; i < a.cols; i++)
83 res += (static_cast<Tres>(pa[i]) -
static_cast<Tres
>(pb[i])) * (
static_cast<Tres
>(pa[i]) - static_cast<Tres>(pb[i]));
91 inline T
Euclidian(
const std::vector<T> &a,
const std::vector<T> &b)
94 for (
size_t i = 0; i < a.size(); i++)
95 sum += (a[i] - b[i]) * (a[i] - b[i]);
108 for (
int x = 0; x < box1.first.cols; x++) {
109 if (box1.first.at<T>(0, x) > box2.second.at<T>(0, x))
return false;
110 if (box1.second.at<T>(0, x) < box2.first.at<T>(0, x))
return false;
Tres Euclidian(const Mat &a, const Mat &b)
Calculates the Euclidian distance between argument matrices a and b.
bool isEqual(const Mat &a, const Mat &b)
Compares two argument matrices a and b.
bool ifOverlap(pair_mat_t &box1, pair_mat_t &box2)
Checks whether two regions box1 and box2 overlap each other.