-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSolver.h
65 lines (57 loc) · 1.37 KB
/
Solver.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
//
// Created by chuguanyi on 18-3-21.
//
#pragma once
#include <opencv2/opencv.hpp>
#include <random>
#include <numeric>
#include "types.h"
class Solver
{
public:
Solver()
{
for (int i = 0; i < p_num_; i++)
{
particle.emplace_back(new double[6]);
weight_[i] = 1.0 / p_num_;
}
e = std::default_random_engine(seed_());
};
~Solver()
{
for (size_t i = 0; i < p_num_; i++)
{
delete[] particle[i];
}
}
void init(double* pose)
{
for (size_t i = 0; i < p_num_; i++)
{
std::copy(pose, pose + 6, particle[i]);
}
}
void Normalize(double* weight, int num)
{
double sum = std::accumulate(weight, weight + num, 0.0);
for (size_t i = 0; i < num; i++)
{
weight[i] /= sum;
}
}
void Resample(std::vector<double*> particle, double* weight, const int p_num);
void Optimize(double* pose_parameter, std::vector<vec3> support_points,
mat3 K, cv::Mat distance_map);
private:
int optimal_index_ = 0;
static const int p_num_ = 3;
std::vector<double*> particle;
double weight_[p_num_];
std::random_device seed_;
std::default_random_engine e;
std::normal_distribution<double> gassuia_distrubtion[6]{
std::normal_distribution<double>(0,0.2), std::normal_distribution<double>(0,0.1), std::normal_distribution<double>(0,0.1),
std::normal_distribution<double>(0,0.01), std::normal_distribution<double>(0,0.01), std::normal_distribution<double>(0,0.01)
};
};