-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathstereo-matching-libelas.cc
91 lines (82 loc) · 3.81 KB
/
stereo-matching-libelas.cc
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
// Copyright (c) 2017-2023 California Institute of Technology ("Caltech"). U.S.
// Government sponsorship acknowledged. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
#include <elas.h>
extern "C"
{
#include "stereo-matching-libelas.h"
};
void
mrcal_stereo_matching_libelas( // output
float* disparity0,
float* disparity1,
// input
const uint8_t* image0,
const uint8_t* image1,
// image dimensions. The stride applies to the
// input only. The output is stored densely
uint32_t width, uint32_t height, uint32_t stride,
// parameters. These are the fields in
// Elas::Elas::parameters. This function provides
// no defaults: eerything must be set
int32_t disparity_min,
int32_t disparity_max,
float support_threshold,
int32_t support_texture,
int32_t candidate_stepsize,
int32_t incon_window_size,
int32_t incon_threshold,
int32_t incon_min_support,
bool add_corners,
int32_t grid_size,
float beta,
float gamma,
float sigma,
float sradius,
int32_t match_texture,
int32_t lr_threshold,
float speckle_sim_threshold,
int32_t speckle_size,
int32_t ipol_gap_width,
bool filter_median,
bool filter_adaptive_mean,
bool postprocess_only_left,
bool subsampling )
{
Elas::Elas::parameters param;
param.disp_min = disparity_min;
param.disp_max = disparity_max;
param.support_threshold = support_threshold;
param.support_texture = support_texture;
param.candidate_stepsize = candidate_stepsize;
param.incon_window_size = incon_window_size;
param.incon_threshold = incon_threshold;
param.incon_min_support = incon_min_support;
param.add_corners = add_corners;
param.grid_size = grid_size;
param.beta = beta;
param.gamma = gamma;
param.sigma = sigma;
param.sradius = sradius;
param.match_texture = match_texture;
param.lr_threshold = lr_threshold;
param.speckle_sim_threshold = speckle_sim_threshold;
param.speckle_size = speckle_size;
param.ipol_gap_width = ipol_gap_width;
param.filter_median = filter_median;
param.filter_adaptive_mean = filter_adaptive_mean;
param.postprocess_only_left = postprocess_only_left;
param.subsampling = subsampling;
Elas::Elas elas(param);
const int32_t dimensions[] = { (int32_t)width,
(int32_t)height,
(int32_t)stride };
elas.process((uint8_t*)image0, // these really are const
(uint8_t*)image1,
disparity0, disparity1,
dimensions);
}