8 #ifdef BUILD_EASYLOGGINGPP 10 #ifdef BUILD_SHARED_LIBS 18 int main(
int argc,
const char * argv[])
try 30 "Fill-Rate", 0, 100,
false,
"%",
32 "Percentage of pixels with valid depth\n" 33 "values out of all pixels within the ROI\n");
36 "Z Accuracy", -10, 10,
true,
"%",
37 "Z-Accuracy given Ground Truth (GT)\n" 38 " as percentage of the range.\n" 40 "1. Transpose Z values from the Fitted to the GT plane\n" 41 "2. Calculate depth errors:\n" 42 " err= signed(Transposed Z - GT).\n" 43 "3. Retrieve the median of the depth errors:\n" 44 "4. Interpret results:\n" 45 " - Positive value indicates that the Plane Fit\n" 46 "is further than the Ground Truth (overshot)\n" 47 " - Negative value indicates the Plane Fit\n" 48 "is in front of Ground Truth (undershot)\n");
51 "Plane Fit RMS Error", 0.
f, 5.
f,
true,
"%",
52 "Plane Fit RMS Error .\n" 53 "This metric provides RMS of Z-Error (Spatial Noise)\n" 54 "and is calculated as follows:\n" 55 "Zi - depth range of i-th pixel (mm)\n" 56 "Zpi -depth of Zi projection onto plane fit (mm)\n" 58 "RMS = SQRT((SUM(Zi-Zpi)^2)/n)\n" 62 "Subpixel RMS Error", 0.
f, 1.
f,
true,
"pixel",
63 "Subpixel RMS Error .\n" 64 "This metric provides the subpixel accuracy\n" 65 "and is calculated as follows:\n" 66 "Zi - depth range of i-th pixel (mm)\n" 67 "Zpi -depth of Zi projection onto plane fit (mm)\n" 68 "BL - optical baseline (mm)\n" 69 "FL - focal length, as a multiple of pixel width\n" 70 "Di = BL*FL/Zi; Dpi = Bl*FL/Zpi\n" 72 "RMS = SQRT((SUM(Di-Dpi)^2)/n)\n" 80 const std::vector<rs2::float3>&
points,
83 const float baseline_mm,
84 const float focal_length_pixels,
85 const int ground_truth_mm,
87 const float plane_fit_to_ground_truth_mm,
88 const float distance_mm,
90 std::vector<single_metric_data>&
samples)
93 static const float TO_MM = 1000.f;
94 static const float TO_PERCENT = 100.f;
97 auto fill_rate = points.size() / float((roi.
max_x - roi.
min_x)*(roi.
max_y - roi.
min_y)) * TO_PERCENT;
98 fill->add_value(fill_rate);
99 if(record) samples.push_back({fill->get_name(), fill_rate });
101 if (!plane_fit)
return;
103 const float bf_factor = baseline_mm * focal_length_pixels * TO_METERS;
105 std::vector<rs2::float3> points_set =
points;
106 std::vector<float> distances;
107 std::vector<float> disparities;
108 std::vector<float> gt_errors;
111 distances.reserve(points.size());
112 disparities.reserve(points.size());
113 if (ground_truth_mm) gt_errors.reserve(points.size());
117 size_t outliers = points_set.size() / 200;
118 points_set.erase(points_set.begin(), points_set.begin() + outliers);
119 points_set.resize(points_set.size() - outliers);
124 for (
auto point : points_set)
130 float(
point.y - dist2plane*p.
b),
131 float(
point.z - dist2plane*p.
c) };
134 distances.push_back(dist2plane * TO_MM);
135 disparities.push_back(bf_factor /
point.length() - bf_factor / plane_intersect.
length());
137 if (ground_truth_mm) gt_errors.push_back(plane_fit_to_ground_truth_mm + (dist2plane * TO_MM));
141 z_accuracy->enable(ground_truth_mm > 0);
145 auto gt_median = gt_errors[gt_errors.size() / 2];
146 auto accuracy = TO_PERCENT * (gt_median / ground_truth_mm);
147 z_accuracy->add_value(accuracy);
148 if (record) samples.push_back({ z_accuracy->get_name(), accuracy });
152 double total_sq_disparity_diff = 0;
157 auto rms_subpixel_val =
static_cast<float>(std::sqrt(total_sq_disparity_diff / disparities.size()));
158 sub_pixel_rms_error->add_value(rms_subpixel_val);
159 if (record) samples.push_back({ sub_pixel_rms_error->get_name(), rms_subpixel_val });
162 double plane_fit_err_sqr_sum = std::inner_product(distances.begin(), distances.end(), distances.begin(), 0.);
163 auto rms_error_val =
static_cast<float>(std::sqrt(plane_fit_err_sqr_sum / distances.size()));
164 auto rms_error_val_per = TO_PERCENT * (rms_error_val / distance_mm);
165 plane_fit_rms_error->add_value(rms_error_val_per);
168 samples.push_back({ plane_fit_rms_error->get_name(), rms_error_val_per });
169 samples.push_back({ plane_fit_rms_error->get_name() +
" mm", rms_error_val });
180 return model.
start(window);
195 catch (
const std::exception& e)
GLboolean GLboolean GLboolean b
std::function< bool()> on_load
static GLFWwindow * window
void sort(sort_type m_sort_type, const std::string &in, const std::string &out)
GLboolean GLboolean GLboolean GLboolean a
const std::string & get_failed_args() const
#define INITIALIZE_EASYLOGGINGPP
int main(int argc, const char *argv[])
std::shared_ptr< metric_plot > metric
const std::string & get_failed_function() const
GLdouble GLdouble GLint GLint const GLdouble * points