@@ -17,53 +17,54 @@ namespace albatross {
17
17
18
18
template <typename GroupKey>
19
19
inline typename RansacFunctions<ConditionalFit, GroupKey>::FitterFunc
20
- get_gp_ransac_fitter (const ConditionalGaussian &model,
20
+ get_gp_ransac_fitter (const std::shared_ptr< ConditionalGaussian> &model,
21
21
const GroupIndexer<GroupKey> &indexer) {
22
22
23
23
return [&, model, indexer](const std::vector<GroupKey> &groups) {
24
24
auto indices = indices_from_groups (indexer, groups);
25
- return model. fit_from_indices (indices);
25
+ return model-> fit_from_indices (indices);
26
26
};
27
27
}
28
28
29
29
template <typename IsValidCandidateMetric, typename GroupKey>
30
30
inline typename RansacFunctions<ConditionalFit, GroupKey>::IsValidCandidate
31
- get_gp_ransac_is_valid_candidate (const ConditionalGaussian &model,
32
- const GroupIndexer<GroupKey> &indexer,
33
- const IsValidCandidateMetric &metric) {
31
+ get_gp_ransac_is_valid_candidate (
32
+ const std::shared_ptr<ConditionalGaussian> &model,
33
+ const GroupIndexer<GroupKey> &indexer,
34
+ const IsValidCandidateMetric &metric) {
34
35
35
36
return [&, model, indexer](const std::vector<GroupKey> &groups) {
36
37
const auto indices = indices_from_groups (indexer, groups);
37
- const auto prior = model. get_prior (indices);
38
- const auto truth = model. get_truth (indices);
38
+ const auto prior = model-> get_prior (indices);
39
+ const auto truth = model-> get_truth (indices);
39
40
return metric (prior, truth);
40
41
};
41
42
}
42
43
43
44
template <typename InlierMetricType, typename GroupKey>
44
45
inline typename RansacFunctions<ConditionalFit, GroupKey>::InlierMetric
45
- get_gp_ransac_inlier_metric (const ConditionalGaussian &model,
46
+ get_gp_ransac_inlier_metric (const std::shared_ptr< ConditionalGaussian> &model,
46
47
const GroupIndexer<GroupKey> &indexer,
47
48
const InlierMetricType &metric) {
48
49
49
50
return [&, indexer, model](const GroupKey &group, const ConditionalFit &fit) {
50
51
const auto indices = indexer.at (group);
51
- const auto pred = get_prediction_reference (model, fit, indices);
52
- const auto truth = model. get_truth (indices);
52
+ const auto pred = get_prediction_reference (* model, fit, indices);
53
+ const auto truth = model-> get_truth (indices);
53
54
return metric (pred, truth);
54
55
};
55
56
}
56
57
57
58
template <typename ConsensusMetric, typename GroupKey>
58
59
inline typename RansacFunctions<ConditionalFit, GroupKey>::ConsensusMetric
59
- get_gp_ransac_consensus_metric (const ConditionalGaussian &model,
60
- const GroupIndexer<GroupKey > &indexer ,
61
- const ConsensusMetric &metric) {
60
+ get_gp_ransac_consensus_metric (
61
+ const std::shared_ptr<ConditionalGaussian > &model ,
62
+ const GroupIndexer<GroupKey> &indexer, const ConsensusMetric &metric) {
62
63
63
64
return [&, model, indexer](const std::vector<GroupKey> &groups) {
64
65
const auto indices = indices_from_groups (indexer, groups);
65
- const auto prior = model. get_prior (indices);
66
- const auto truth = model. get_truth (indices);
66
+ const auto prior = model-> get_prior (indices);
67
+ const auto truth = model-> get_truth (indices);
67
68
return metric (prior, truth);
68
69
};
69
70
}
@@ -120,7 +121,9 @@ inline RansacFunctions<ConditionalFit, GroupKey> get_gp_ransac_functions(
120
121
static_assert (is_prediction_metric<InlierMetric>::value,
121
122
" InlierMetric must be an PredictionMetric." );
122
123
123
- const ConditionalGaussian model (std::forward<PriorDistribution>(prior), truth);
124
+ const std::shared_ptr<ConditionalGaussian> model =
125
+ std::make_shared<ConditionalGaussian>(
126
+ std::forward<PriorDistribution>(prior), truth);
124
127
125
128
const auto fitter = get_gp_ransac_fitter<GroupKey>(model, indexer);
126
129
0 commit comments