Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
atomoclast committed Apr 13, 2018
0 parents commit a8f71b6
Show file tree
Hide file tree
Showing 50 changed files with 5,855 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .idea/cSfM.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

29 changes: 29 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

232 changes: 232 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
cmake_minimum_required(VERSION 3.10)
project(cSfM)

find_package(OpenCV 3.4.1 REQUIRED)
find_package(Eigen3 REQUIRED)
find_package(Ceres QUIET)

set(CMAKE_CXX_STANDARD 11)

add_definitions("-DCERES_FOUND=1")
list(APPEND LIBMV_LIGHT_LIBS simple_pipeline)
list(APPEND LIBMV_LIGHT_INCLUDES "${CERES_INCLUDE_DIR}")

list (FIND CERES_COMPILED_COMPONENTS "C++11" _index)
if (${_index} GREATER -1)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

set(SOURCE_FILES main.cpp)
add_executable(cSfM main.cpp cSfM.h)
target_link_libraries(cSfM ${OpenCV_LIBS})
74 changes: 74 additions & 0 deletions cSfM.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
//
// Created by Andrew Dahdouh
//

#include "opencv2/core.hpp"
#include "opencv2/features2d.hpp"
#include "opencv2/imgcodecs.hpp"
#include "opencv2/highgui.hpp"
#include "opencv2/xfeatures2d.hpp"
#include "opencv2/calib3d/calib3d.hpp"

#ifndef CSFM_CSFM_H
#define CSFM_CSFM_H

using namespace cv;
using namespace std;
using namespace cv::xfeatures2d;

void findKeypoints(Mat& img1, vector<KeyPoint>& keypoints_1, Mat& img2, vector<KeyPoint>& keypoints_2,
vector<DMatch>& valid_matches )
{

int minHessian = 400;
Ptr<SURF> detector = SURF::create();
detector->setHessianThreshold(minHessian);

// vector<KeyPoint> keypoints_1, keypoints_2;
Mat descriptors_1, descriptors_2;
detector->detectAndCompute( img1, Mat(), keypoints_1, descriptors_1 );
detector->detectAndCompute( img2, Mat(), keypoints_2, descriptors_2 );

//-- Step 2: Matching descriptor vectors using FLANN matcher
FlannBasedMatcher matcher;
std::vector< DMatch > matches;
matcher.match( descriptors_1, descriptors_2, matches );
double max_dist = 0; double min_dist = 100;
//-- Quick calculation of max and min distances between keypoints
for( int i = 0; i < descriptors_1.rows; i++ )
{ double dist = matches[i].distance;
if( dist < min_dist ) min_dist = dist;
if( dist > max_dist ) max_dist = dist;
}
printf("-- Max dist : %f \n", max_dist );
printf("-- Min dist : %f \n", min_dist );
//-- Draw only "good" matches (i.e. whose distance is less than 2*min_dist,
//-- or a small arbitary value ( 0.02 ) in the event that min_dist is very
//-- small)
//-- PS.- radiusMatch can also be used here.
std::vector< DMatch > good_matches;
for( int i = 0; i < descriptors_1.rows; i++ )
{ if( matches[i].distance <= max(2*min_dist, 0.02) )
{ valid_matches.push_back( matches[i]); }
}

//-- Draw only "good" matches
Mat img_matches;
drawMatches( img1, keypoints_1, img2, keypoints_2,
valid_matches, img_matches, Scalar::all(-1), Scalar::all(-1),
vector<char>(), DrawMatchesFlags::NOT_DRAW_SINGLE_POINTS );
//-- Show detected matches
imshow( "Good Matches", img_matches );

waitKey(0);

}

void reconstruct_image_pair(vector<Mat>& points2d, vector<Mat>& Rs_est, vector<Mat>& ts_est, Matx33d& K, vector<Mat>& points3d_estimated)
{
cout << "Reconstructing...." << endl;
}



#endif //CSFM_CSFM_H
Loading

0 comments on commit a8f71b6

Please sign in to comment.