Skip to content

Commit 5a934c1

Browse files
author
tsing
committed
Trying to add doc to CMake
1 parent 0d26aa5 commit 5a934c1

10 files changed

+33
-90
lines changed

CMakeLists.txt

+14-7
Original file line numberDiff line numberDiff line change
@@ -73,23 +73,30 @@ endif(${USE_CUDA})
7373

7474
set(CMAKE_CXX_FLAGS "-std=c++11 -g -Wall -O3")
7575

76+
if (GTEST)
77+
enable_testing()
78+
add_subdirectory(./test)
79+
endif (GTEST)
80+
7681
# Enable code coverage
77-
if (COVERAGE)
82+
option (COVERAGE "Build with coverage test, require GTEST=on" OFF)
83+
if (COVERAGE AND GTEST)
7884
set (CMAKE_CXX_FLAGS "-std=c++11 -g -O0 -fprofile-arcs -ftest-coverage")
7985
set (CMAKE_C_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
80-
endif(COVERAGE)
86+
endif()
87+
88+
# Enable documentation
89+
option (BUILD_DOC "Build documentation" OFF)
90+
if (BUILD_DOC)
91+
add_subdirectory("./doc")
92+
endif(BUILD_DOC)
8193

8294

8395
add_subdirectory(./src/lib/GrayCode)
8496
add_subdirectory(./src/lib/calibration)
8597
add_subdirectory(./src/lib/core)
8698
add_subdirectory(./src/app)
8799

88-
if (GTEST)
89-
enable_testing()
90-
add_subdirectory(./test)
91-
endif (GTEST)
92-
93100

94101
set_target_properties ( SLS
95102
PROPERTIES

doc/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
find_package(Doxygen REQUIRED)
2+
message(STATUS ${DOXYGEN_EXECUTABLE})
3+

src/lib/core/Camera.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ class Camera
5050
Dynamic_Bitset shadowMask_; //Color mask
5151

5252
// An all lit image contains color information of reconstruction object
53-
cv::Mat color_;
53+
cv::Mat litImage_;
5454

5555
// Thresholds are used to filter out invalid pixel.
5656
uchar whiteThreshold_;
@@ -85,11 +85,11 @@ class Camera
8585
uchar getblackThreshold() const {return blackThreshold_;}
8686
virtual const cv::Mat& getColorFrame() const
8787
{
88-
return color_;
88+
return litImage_;
8989
}
9090
glm::vec3 getColor(size_t x, size_t y) const
9191
{
92-
auto color = color_.at<cv::Vec3b>(y, x);
92+
auto color = litImage_.at<cv::Vec3b>(y, x);
9393
// OpenCV BGR
9494
float b = (float)color.val[0];
9595
float g = (float)color.val[1];

src/lib/core/FileReader.cpp

+1-19
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ void FileReader::loadImages(const std::string& folder, std::string prefix, size_
2727
{
2828
if( images_.size() == 0)
2929
//Copy the first image to color
30-
img.copyTo(color_);
30+
img.copyTo(litImage_);
3131

3232
cv::Mat gray;
3333
cv::cvtColor(img, gray, CV_BGR2GRAY);
@@ -41,7 +41,6 @@ void FileReader::loadImages(const std::string& folder, std::string prefix, size_
4141
{
4242
resX_ = images_[0].cols;
4343
resY_ = images_[0].rows;
44-
//rayTable.resize(resX_*resY_);
4544
thresholds_.resize(resY_*resX_, whiteThreshold_);
4645
LOG::writeLog("%d images loaded ...", images_.size());
4746
}
@@ -189,23 +188,6 @@ Ray FileReader::getRay(const size_t &pixelIdx)
189188
}
190189

191190

192-
193-
void FileReader::rayTableToPointCloud(std::string fileName) const
194-
{
195-
196-
std::ofstream of(fileName);
197-
for (size_t i=0; i<rayTable.size(); i++)
198-
{
199-
const auto& ray = rayTable[i];
200-
if (shadowMask_.getBit(i))
201-
{
202-
auto endP = ray.origin+ray.dir*5000.0f;
203-
of<<"v "<<endP.x<<" "<<endP.y<<" "<<endP.z<<std::endl;
204-
}
205-
}
206-
of.close();
207-
}
208-
209191
glm::vec2 FileReader::undistortPixel(const glm::vec2 &distortedPixel) const
210192
{
211193
double k[5] = {0.0};

src/lib/core/FileReader.h

+3-16
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ class FileReader: public Camera
4747
Camera(cName),frameIdx_(0),camTransMat_(glm::mat4(1.0)){}
4848

4949

50-
//Extra functions
5150
/*! Load a sequence of images from `folder` in the order of number
5251
* e.g. for a sequence of images in the folder IMG_001.jpg, IMG_002.jpg ...,
5352
* the prefix is "IMG_", number of digits is 3 , start index is 1 and suffix is "jpg".
@@ -74,22 +73,10 @@ class FileReader: public Camera
7473
//! Get parameters
7574
const std::array<cv::Mat, PARAM_COUNT>& getParams()const{return params_;}
7675

77-
/**
78-
* @brief visualize raytable with point cloud, each ray is a unit vector
79-
*
80-
* @param fileName output obj file
81-
*/
82-
void rayTableToPointCloud(std::string fileName) const;
83-
84-
//Implementing interfaces
85-
~FileReader() override{
86-
for (auto image: images_)
87-
image.release();
88-
for (auto param: params_)
89-
param.release();
90-
}
76+
//! Get a ray by x, y
9177
Ray getRay(const size_t &x, const size_t &y) override;
92-
//Ray getRay(const size_t &idx) override{return rayTable[idx];}
78+
79+
//! Get a ray by column major pixel index
9380
Ray getRay(const size_t &pixelIdx) override;
9481

9582
void loadConfig(const std::string& configFile) override;

src/lib/core/PointCloud.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ namespace SLS
1717
//! A point cloud class
1818
void exportPointCloud2OBJ(std::string fileName, const std::vector<float> &pointCloud);
1919
void exportPointCloud2PLY(std::string fileName, const std::vector<float> &pointCloud);
20+
2021
class PointCloud
2122
{
2223
private:

src/lib/core/Projector.h

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ class Projector
4040
size_t getRequiredNumFrames() const
4141
{
4242
return (size_t)std::ceil(std::log2(width_))+std::ceil(std::log2(height_));
43-
//return (size_t )std::ceil(std::log2((float)width_*(float)height_)); // hmmm TODO: Figure out why it doesn't work
4443
}
4544
};
4645
}

src/lib/core/Ray.h

+6-39
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
#pragma once
22
#define GLM_FORCE_CUDA
33
#include <glm/glm.hpp>
4-
//#include <glm/gtx/string_cast.hpp>
54
#include "Log.hpp"
65
using namespace glm;
76
namespace SLS
@@ -13,36 +12,15 @@ struct Ray
1312
};
1413

1514
/**
16-
* @brief Get mid point of two rays.
15+
*! Get mid point of the segment perpendicular to both rays, i.e. intersection point.
1716
*
18-
* @param r1 Input of ray 1
19-
* @param r2 Input of ray 2
20-
* @param dist distance between two rays
17+
* /param r1 Input of ray 1
18+
* /param r2 Input of ray 2
19+
* /param dist distance between two rays
2120
*
22-
* @return Mid point
21+
* /return Mid point
2322
*/
24-
inline glm::vec4 midPoint(const Ray &r1, const Ray &r2, float &dist)
25-
{
26-
glm::vec3 a (r1.origin);
27-
glm::vec3 b (r1.dir);
28-
glm::vec3 c (r2.origin);
29-
glm::vec3 d (r2.dir);
30-
31-
32-
33-
34-
auto s = ( dot(b,d)*( dot(a,d) - dot(b,c)) - dot(a,d)*dot(c,d)) / (dot (b,d)*dot(b,d)-1.0f);
35-
auto t = ( dot(b,d)*( dot(c,d) - dot(a,d)) - dot(b,c)*dot(a,b)) / (dot(b,d)*dot(b,d)-1.0f);
36-
37-
38-
auto p_1 = a+s*b;
39-
auto q_1 = c+t*d;
40-
41-
dist = distance(p_1, q_1);
42-
return vec4((p_1+q_1)/2.0f, 1.0f);
43-
44-
}
45-
inline glm::vec4 midPointBkp( const Ray &r1, const Ray &r2, float &dist)
23+
inline glm::vec4 midPoint( const Ray &r1, const Ray &r2, float &dist)
4624
{
4725
glm::vec3 v1 (r1.dir);
4826
glm::vec3 v2 (r2.dir);
@@ -69,15 +47,4 @@ inline glm::vec4 midPointBkp( const Ray &r1, const Ray &r2, float &dist)
6947
return vec4((p1+s*v1+p2+t*v2)/2.0f, 1.0);
7048

7149
}
72-
inline glm::vec4 midPointPaper(const Ray &r1, const Ray &r2, float &dist)
73-
{
74-
glm::vec3 p(r1.origin);
75-
glm::vec3 q(r2.origin);
76-
glm::vec3 u(r1.dir);
77-
glm::vec3 v(r2.dir);
78-
auto w = p-q;
79-
auto s = (dot(w,u)*dot(v,v)-dot(u,v)*dot(w,v))/(dot(v,u)*dot(v,u) - dot(v,v)*dot(u,u));
80-
auto t = (dot(v,u)*dot(w,u)-dot(u,u)*dot(w,v))/(dot(v,u)*dot(v,u)-dot(v,v)*dot(u,u));
81-
return vec4( ((p+s*u)+(q+t*v))/2.0f, 1.0);
82-
}
8350
}

src/lib/core/ReconstructorCPU.cpp

+1-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,6 @@ PointCloud ReconstructorCPU::reconstruct()
117117

118118
for ( size_t i=0; i<buckets_[0].size(); i++) // 1024*768
119119
{
120-
//Progress
121120
const auto &cam0bucket = buckets_[0][i];
122121
const auto &cam1bucket = buckets_[1][i];
123122
size_t minCam0Idx=0;
@@ -135,7 +134,7 @@ PointCloud ReconstructorCPU::reconstruct()
135134
{
136135
float dist=-1.0f;
137136

138-
auto midP=midPointBkp(cameras_[0]->getRay(cam0P), cameras_[1]->getRay(cam1P), dist);
137+
auto midP=midPoint(cameras_[0]->getRay(cam0P), cameras_[1]->getRay(cam1P), dist);
139138
if (dist > 0.0) // if dist is valid
140139
{
141140
ptCount += 1.0;

src/lib/core/ReconstructorCPU.h

+1-3
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
namespace SLS
2424
{
2525

26-
/**
27-
* @brief CPU reconstructor
28-
*/
26+
// CPU reconstructor
2927
class ReconstructorCPU: public Reconstructor
3028
{
3129
private:

0 commit comments

Comments
 (0)