-
Notifications
You must be signed in to change notification settings - Fork 4
/
ms7ScenesUtil.hpp
147 lines (120 loc) · 7.6 KB
/
ms7ScenesUtil.hpp
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
//
// ms7ScenesUtil.hpp
// RGB_RF
//
// Created by jimmy on 2016-06-06.
// Copyright © 2016 jimmy. All rights reserved.
//
#ifndef ms7ScenesUtil_cpp
#define ms7ScenesUtil_cpp
#include <stdio.h>
#include <opencv2/core/core.hpp>
#include <opencv2/core/core_c.h>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/imgproc/imgproc_c.h>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
#include <string>
#include <vector>
#include <Eigen/Dense>
using std::string;
using std::vector;
class Ms7ScenesUtil
{
public:
// read camera pose file
static cv::Mat read_pose_7_scenes(const char *file_name);
//
static bool read_pose_7_scenes(const char *file_name, Eigen::Affine3d& affine);
// invalid depth is 0.0
static cv::Mat camera_depth_to_world_depth(const cv::Mat & camera_depth_img, const cv::Mat & pose);
// camera_depth_img 16 bit
// return CV_64_FC3 for x, y, z, unit in meter
static cv::Mat camera_depth_to_world_coordinate(const cv::Mat & camera_depth_img, const cv::Mat & camera_to_world_pose);
// mask: CV_8UC1 0 --> invalid sample
static cv::Mat camera_depth_to_world_coordinate(const cv::Mat & camera_depth_img,
const cv::Mat & camera_to_world_pose,
cv::Mat & mask);
// mask: CV_8UC1 0 --> invalid sample
static cv::Mat camera_depth_to_camera_coordinate(const cv::Mat & camera_depth_img,
const cv::Mat camera_matrix,
const double depth_factor,
const double min_depth,
const double max_depth,
cv::Mat & mask);
// return CV_64_FC3 for x, y, z, unit in meter
static void camera_depth_to_camera_and_world_coordinate(const cv::Mat & camera_depth,
const cv::Mat & camera_to_world_pose,
cv::Mat & camera_coord,
cv::Mat & world_coord,
cv::Mat & mask);
// camera_depth_img: CV_64FC1
// camera_to_world_pose: 4x4 CV_64FC1
// calibration_matrix: 3x3 CV_64FC1
// depth_factor: e.g. 1000.0 for MS 7 scenes
// camera_xyz: output camera coordinate location, CV_64FC3
// mask: output CV_8UC1 0 -- > invalid, 1 --> valid
// return: CV_64FC3 , x y z in world coordinate
static cv::Mat cameraDepthToWorldCoordinate(const cv::Mat & camera_depth_img,
const cv::Mat & camera_to_world_pose,
const cv::Mat & calibration_matrix,
const double depth_factor,
const double min_depth,
const double max_depth,
cv::Mat & camera_coordinate,
cv::Mat & mask);
static cv::Mat camera_matrix();
static inline int invalid_camera_depth(){return 65535;}
static bool load_prediction_result(const char *file_name, string & rgb_img_file, string & depth_img_file, string & camera_pose_file,
vector<cv::Point2d> & img_pts,
vector<cv::Point3d> & wld_pts_pred,
vector<cv::Point3d> & wld_pts_gt);
// load prediction result from decision trees with color information
static bool load_prediction_result_with_color(const char *file_name,
string & rgb_img_file,
string & depth_img_file,
string & camera_pose_file,
vector<cv::Point2d> & img_pts,
vector<cv::Point3d> & wld_pts_pred,
vector<cv::Point3d> & wld_pts_gt,
vector<cv::Vec3d> & color_pred,
vector<cv::Vec3d> & color_sample);
// load prediction result from all decision trees with color information
static bool load_prediction_result_with_color(const char *file_name,
string & rgb_img_file,
string & depth_img_file,
string & camera_pose_file,
vector<cv::Point2d> & img_pts,
vector<cv::Point3d> & wld_pts_gt,
vector<vector<cv::Point3d> > & candidate_wld_pts_pred,
vector<cv::Vec3d> & color_sample,
vector<vector<cv::Vec3d> > & candidate_color_pred);
// load prediction result form all decision trees with feature distance information
static bool load_prediction_result_with_distance(const char *file_name,
string & rgb_img_file,
string & depth_img_file,
string & camera_pose_file,
vector<cv::Point2d> & img_pts,
vector<cv::Point3d> & wld_pts_gt,
vector<vector<cv::Point3d> > & candidate_wld_pts_pred,
vector<vector<double> > & candidate_feature_dists);
// load prediction result from all decision trees with feature distance and uncertainty
static bool load_prediction_result_with_uncertainty(const char *file_name,
string & rgb_img_file,
string & depth_img_file,
string & camera_pose_file,
vector<Eigen::Vector2d> & img_pts,
vector<Eigen::Vector3d> & wld_pts_gt,
vector<vector<Eigen::Vector3d> > & candidate_wld_pts_pred,
vector<vector<Eigen::Matrix3d> > & candidate_wld_pts_pred_covariance,
vector<vector<double> > & candidate_feature_dists);
// load camera estimation result
static bool load_estimated_camera_pose(const char *file_name,
string & rgb_img_file,
string & depth_img_file,
string & camera_pose_file,
cv::Mat & estimated_pose);
// read file names in a file
static vector<string> read_file_names(const char *file_name);
};
#endif /* ms7ScenesUtil_cpp */