Skip to content

Commit

Permalink
fix warnings and modify cpp_flags options
Browse files Browse the repository at this point in the history
  • Loading branch information
Silvano Galliani committed Jan 8, 2016
1 parent dd74ae4 commit fd50dd2
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 60 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS};-O3 --use_fast_math --ptxas-options=-v -s

if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-std=c++11)
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -ffast-math -march=native") # extend release-profile with fast-math
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -Wall") # extend debug-profile with -Wall
add_definitions(-Wall)
add_definitions(-Wextra)
add_definitions(-pedantic)
add_definitions(-Wno-unused-function)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3 -ffast-math -march=native") # extend release-profile with fast-math
endif()

find_package(OpenMP)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ because it allows to render points cloud with normals.

## Examples
### Middlebury
inside gipuma directory first download middlebury data
inside gipuma directory first download middlebury data:
```bash
./scripts/download-middlebury.sh
./scripts/download-middlebury.sh
```
Then run the model you prefer. For example for the dino sparse ring:
Then run the model you prefer (see the list of available scripts inside the script folder).
For example for the dino sparse ring:
```bash
./scripts/dinoSparseRing.sh
```
Expand Down
22 changes: 8 additions & 14 deletions cameraGeometryUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,7 @@ inline Vec3f get3Dpoint ( Camera &cam, int x, int y, float depth ){
}

// get the viewing ray for a pixel position of the camera
static inline Vec3f getViewVector ( Camera &cam, int x, int y, bool rectified ) {

#ifdef RECTIFIED
if ( rectified )
return Vec3f ( 0.0f,0.0f,1.0f );
#endif
static inline Vec3f getViewVector ( Camera &cam, int x, int y) {

//get some point on the line (the other point on the line is the camera center)
Vec3f ptX = get3Dpoint ( cam,x,y,1.0f );
Expand Down Expand Up @@ -176,7 +171,11 @@ void copyOpencvMatToFloatArray ( Mat_<float> &m, float **a)
* scaleFactor - if image was rescaled we need to adapt calibration matrix K accordingly
* Output: camera parameters
*/
CameraParameters getCameraParameters ( CameraParameters_cu &cpc, InputFiles inputFiles, float depthMin, float depthMax, float scaleFactor = 1.0f, bool transformP = true ) {
CameraParameters getCameraParameters ( CameraParameters_cu &cpc,
InputFiles inputFiles,
float scaleFactor = 1.0f,
bool transformP = true )
{

CameraParameters params;
size_t numCameras = 2;
Expand Down Expand Up @@ -249,7 +248,7 @@ CameraParameters getCameraParameters ( CameraParameters_cu &cpc, InputFiles inpu
vector<Mat_<float> > C ( numCameras );
vector<Mat_<float> > t ( numCameras );

for ( int i = 0; i < numCameras; i++ ) {
for ( size_t i = 0; i < numCameras; i++ ) {
decomposeProjectionMatrix ( params.cameras[i].P,K[i],R[i],T[i] );

//cout << "K: " << K[i] << endl;
Expand Down Expand Up @@ -282,14 +281,11 @@ CameraParameters getCameraParameters ( CameraParameters_cu &cpc, InputFiles inpu
// get focal length from calibration matrix
params.f = params.K ( 0,0 );

for ( int i = 0; i < numCameras; i++ ) {
for ( size_t i = 0; i < numCameras; i++ ) {
params.cameras[i].K = scaleK(K[i],scaleFactor);
params.cameras[i].K_inv = params.cameras[i].K.inv ( );
//params.cameras[i].f = params.cameras[i].K(0,0);

//params.cameras[i].depthMin = depthMin;
//params.cameras[i].depthMax = depthMax;

if ( !inputFiles.bounding_folder.empty () ) {
Vec3f ptBL, ptTR;
readBoundingVolume ( inputFiles.bounding_folder + inputFiles.img_filenames[i] + ".bounding",ptBL,ptTR );
Expand Down Expand Up @@ -320,8 +316,6 @@ CameraParameters getCameraParameters ( CameraParameters_cu &cpc, InputFiles inpu
cpc.cameras[i].f = params.K(0,0);
cpc.cameras[i].fx = params.K(0,0);
cpc.cameras[i].fy = params.K(1,1);
//cpc.cameras[i].depthMin = params.cameras[i].depthMin;
//cpc.cameras[i].depthMax = params.cameras[i].depthMax;
cpc.cameras[i].baseline = params.cameras[i].baseline;
cpc.cameras[i].reference = params.cameras[i].reference;

Expand Down
8 changes: 4 additions & 4 deletions displayUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Mat correctGamma( Mat& img, double gamma ) {
LUT( img, lut_matrix, result );

return result;
};
}


static void getDisparityForDisplay(const Mat_<float> &disp, Mat &dispGray, Mat &dispColor, float numDisparities, float minDisp = 0.0f){
Expand All @@ -45,7 +45,7 @@ static void getDisparityForDisplay(const Mat_<float> &disp, Mat &dispGray, Mat &
dispColor.at<Vec3b>(y,x) = Vec3b(0,0,0);
}
}
};
}

static void convertDisparityDepthImage(const Mat_<float> &dispL, Mat_<float> &d, float f, float baseline){
d = Mat::zeros(dispL.rows, dispL.cols, CV_32F);
Expand All @@ -54,7 +54,7 @@ static void convertDisparityDepthImage(const Mat_<float> &dispL, Mat_<float> &d,
d(y,x) = disparityDepthConversion(f,baseline,dispL(y,x));
}
}
};
}

static string getColorString(uint8_t color){
stringstream ss;
Expand Down Expand Up @@ -242,4 +242,4 @@ static void getNormalsForDisplay(const Mat &normals, Mat &normals_display, int r
else
normals.convertTo(normals_display,CV_16U,32767,32767);
cvtColor(normals_display,normals_display,COLOR_RGB2BGR);
};
}
17 changes: 8 additions & 9 deletions fileIoUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ static void getProjectionMatrix(char* line, Mat_<float> &P){

idx++;
}
};
}

static int read3Dpoint(char* line, Vec3f &pt){
const char* p;
Expand Down Expand Up @@ -51,7 +51,7 @@ static void readCalibFileKitti(const string calib_filename, Mat_<float> &P1, Mat
myfile.getline(line,512);
getProjectionMatrix(line,P2);
myfile.close();
};
}

static void readBoundingVolume(const string filename, Vec3f &ptBL, Vec3f & ptTR){
ifstream myfile;
Expand All @@ -65,7 +65,7 @@ static void readBoundingVolume(const string filename, Vec3f &ptBL, Vec3f & ptTR)
read3Dpoint(line,ptTR);

myfile.close();
};
}


static void readCameraFileStrecha(const string camera_filename, float &focalLength){
Expand Down Expand Up @@ -136,7 +136,7 @@ static void readKRtFileMiddlebury(const string filename, vector<Camera> cameras,
/*cout << "t is " << vt << endl;*/
//cout << "Filename is " << tmp << endl;
//cout << "image Filename is " << inputFiles.img_filenames[i] << endl;
for( int j = 0; j < inputFiles.img_filenames.size(); j++) {
for( size_t j = 0; j < inputFiles.img_filenames.size(); j++) {
if( tmp == inputFiles.img_filenames[j]) {
truei=j;
break;
Expand Down Expand Up @@ -171,15 +171,14 @@ static void readCalibFileDaisy(const string calib_filename, Mat_<float> &P){
getProjectionMatrix(line,P);
}


myfile.close();
}

static void writeImageToFile(const char* outputFolder,const char* name,const Mat &img){
char outputPath[256];
sprintf(outputPath, "%s/%s.png", outputFolder,name);
imwrite(outputPath,img);
};
}

static void writeParametersToFile(char* resultsFile, InputFiles inputFiles, AlgorithmParameters &algParameters, GTcheckParameters &gtParameters, uint32_t numPixels){

Expand All @@ -188,7 +187,7 @@ static void writeParametersToFile(char* resultsFile, InputFiles inputFiles, Algo
myfile << "Number of images: " << inputFiles.img_filenames.size() << endl;
myfile << "Image folder: " << inputFiles.images_folder << endl;
myfile << "Images: ";
for(int i=0; i < inputFiles.img_filenames.size(); i++)
for(size_t i=0; i < inputFiles.img_filenames.size(); i++)
myfile << inputFiles.img_filenames[i] << ", " ;
myfile << endl;
if(numPixels != 0)
Expand Down Expand Up @@ -243,7 +242,7 @@ static void writeParametersToFile(char* resultsFile, InputFiles inputFiles, Algo
myfile << "no" << endl;
myfile << " GT disparity tolerance: " << gtParameters.dispTolGT << "\n" << endl;
myfile.close();
};
}
// read ground truth depth map file (dmb) (provided by Tola et al. "DAISY: A Fast Local Descriptor for Dense Matching" http://cvlab.epfl.ch/software/daisy)
static int readDmbNormal (const char *filename, Mat_<Vec3f> &img)
{
Expand Down Expand Up @@ -473,4 +472,4 @@ static int readPfm( const char *filename,
fclose(inimage);
return 0;

};
}
6 changes: 3 additions & 3 deletions groundTruthUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ float computeError(const Mat_<float>& gtDisp, const Mat_<uint8_t>& occImg, Mat_<
errorValidAll = (errorValid + (numGtPixels-numValidPixels)) / (float)numGtPixels;
errorValid = errorValid / (float)numValidPixels;
return (float)numValidPixels/(float)numGtPixels;
};
}

static float computeNormalError(const Mat_<Vec3f> &normals, const Mat_<Vec3f> &gtNormals, float gtNormTol, float gtNormTol2, Mat_<float> &errorMap, float &error2){
int numGtPixels = 0;
Expand Down Expand Up @@ -132,8 +132,8 @@ static float computeNormalError(const Mat_<Vec3f> &normals, const Mat_<Vec3f> &g
}
error2 = (float)error2_count/ (float) numGtPixels;
return (float)error / (float) numGtPixels;
};
}

static void getNoccGTimg(const Mat_<float> &groundTruthDisp, const Mat_<uint8_t> &occlusionImg, Mat_<float> &groundTruthDispNocc){
bitwise_and(groundTruthDisp,groundTruthDisp,groundTruthDispNocc,occlusionImg);
};
}
Loading

0 comments on commit fd50dd2

Please sign in to comment.