-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit a8f71b6
Showing
50 changed files
with
5,855 additions
and
0 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Oops, something went wrong.