-
Notifications
You must be signed in to change notification settings - Fork 4
/
cvx_rgbd.h
114 lines (99 loc) · 4.31 KB
/
cvx_rgbd.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
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
//
// cvx_rgbd.h
// PointLineReloc
//
// Created by jimmy on 2017-03-30.
// Copyright (c) 2017 Nowhere Planet. All rights reserved.
//
#ifndef __PointLineReloc__cvx_rgbd__
#define __PointLineReloc__cvx_rgbd__
#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 Eigen::Vector3d;
using Eigen::Vector2d;
using std::vector;
class CvxRGBD
{
public:
struct RGBDLineSegment
{
Vector2d img_p1;
Vector2d img_p2;
Vector3d cam_p1;
Vector3d cam_p2;
Vector3d wld_p1;
Vector3d wld_p2;
};
struct RGBDLineParameter
{
double min_length; // 2D image space, pixel
double min_camera_points; // 3D camera coordiante points, number
double inlier_point_threshold; // 3D point to estiamted 3D line, meter
double inlier_ratio; // 3D point on 3D line, percentage
double sample_densitiy; // sample point on the line, (0, 1.0)
double line_area_width; // line area with, pixel, calculate line direction, bright in left side
double brightness_contradict_threshold; // brightness contradict of left and right side of linesegment
RGBDLineParameter()
{
min_length = 40.0;
min_camera_points = 15.0;
inlier_point_threshold = 0.02;
inlier_ratio = 0.5;
sample_densitiy = 0.5;
line_area_width = 15;
brightness_contradict_threshold = 0.02;
}
};
public:
// 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
// world_coordinate: CV_64FC3 , x y z in world coordinate
// mask: output CV_8UC1 0 -- > invalid, 1 --> valid
static bool 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 & world_coordinate,
cv::Mat & mask);
// depth image to camera coordinate
static bool cameraDepthToCameraCoordinate(const cv::Mat & camera_depth_img,
const cv::Mat & calibration_matrix,
const double depth_factor,
const double min_depth,
const double max_depth,
cv::Mat & camera_coordinate,
cv::Mat & mask);
// color_img: CV_8UC3 in default BGR format
// detect 3D lines in camera coordinate
// depth_img: CV_64FC1, in meter
// mask: CV_8UC1, 0 or 1
// calibration_matrix: camera intrinsic parameter, check line segment end points in image space
// camera_coordinate: CV_64FC3
// return: line segment in image coordinate and camera coordinate
// todo: RANSAC 3D line estimation, wider lines
static bool detect3DLines(const cv::Mat & color_img,
const cv::Mat & depth_img,
const cv::Mat & mask,
const cv::Mat & calibration_matrix,
const cv::Mat & camera_coordinate,
const RGBDLineParameter & line_param,
vector<RGBDLineSegment> & lines);
// depth_img: input and output
static bool depthInpaint(cv::Mat & depth_img,
const unsigned char no_depth_mask);
};
#endif /* defined(__PointLineReloc__cvx_rgbd__) */