-
Notifications
You must be signed in to change notification settings - Fork 17
/
ACMH.h
83 lines (72 loc) · 2.83 KB
/
ACMH.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
#ifndef _ACMH_H_
#define _ACMH_H_
#include "main.h"
int readDepthDmb(const std::string file_path, cv::Mat_<float> &depth);
int readNormalDmb(const std::string file_path, cv::Mat_<cv::Vec3f> &normal);
int writeDepthDmb(const std::string file_path, const cv::Mat_<float> depth);
int writeNormalDmb(const std::string file_path, const cv::Mat_<cv::Vec3f> normal);
Camera ReadCamera(const std::string &cam_path);
void RescaleImageAndCamera(cv::Mat_<cv::Vec3b> &src, cv::Mat_<cv::Vec3b> &dst, cv::Mat_<float> &depth, Camera &camera);
float3 Get3DPointonWorld(const int x, const int y, const float depth, const Camera camera);
void ProjectonCamera(const float3 PointX, const Camera camera, float2 &point, float &depth);
float GetAngle(const cv::Vec3f &v1, const cv::Vec3f &v2);
void StoreColorPlyFileBinaryPointCloud (const std::string &plyFilePath, const std::vector<PointList> &pc);
#define CUDA_SAFE_CALL(error) CudaSafeCall(error, __FILE__, __LINE__)
#define CUDA_CHECK_ERROR() CudaCheckError(__FILE__, __LINE__)
void CudaSafeCall(const cudaError_t error, const std::string& file, const int line);
void CudaCheckError(const char* file, const int line);
struct cudaTextureObjects {
cudaTextureObject_t images[MAX_IMAGES];
};
struct PatchMatchParams {
int max_iterations = 3;
int patch_size = 11;
int num_images = 5;
int max_image_size=3200;
int radius_increment = 2;
float sigma_spatial = 5.0f;
float sigma_color = 3.0f;
int top_k = 4;
float baseline = 0.54f;
float depth_min = 0.0f;
float depth_max = 1.0f;
float disparity_min = 0.0f;
float disparity_max = 1.0f;
bool geom_consistency = false;
};
class ACMH {
public:
ACMH();
~ACMH();
void InuputInitialization(const std::string &dense_folder, const Problem &problem);
void Colmap2MVS(const std::string &dense_folder, std::vector<Problem> &problems);
void CudaSpaceInitialization(const std::string &dense_folder, const Problem &problem);
void RunPatchMatch();
void SetGeomConsistencyParams();
int GetReferenceImageWidth();
int GetReferenceImageHeight();
cv::Mat GetReferenceImage();
float4 GetPlaneHypothesis(const int index);
float GetCost(const int index);
private:
int num_images;
std::vector<cv::Mat> images;
std::vector<cv::Mat> depths;
std::vector<Camera> cameras;
cudaTextureObjects texture_objects_host;
cudaTextureObjects texture_depths_host;
float4 *plane_hypotheses_host;
float *costs_host;
PatchMatchParams params;
Camera *cameras_cuda;
cudaArray *cuArray[MAX_IMAGES];
cudaArray *cuDepthArray[MAX_IMAGES];
cudaTextureObjects *texture_objects_cuda;
cudaTextureObjects *texture_depths_cuda;
float4 *plane_hypotheses_cuda;
float *costs_cuda;
curandState *rand_states_cuda;
unsigned int *selected_views_cuda;
float *depths_cuda;
};
#endif // _ACMH_H_