Skip to content

Commit

Permalink
Added CMakeLists.txt and more structure to source files
Browse files Browse the repository at this point in the history
  • Loading branch information
eivan committed Mar 1, 2019
1 parent 6bcac73 commit 9669785
Show file tree
Hide file tree
Showing 16 changed files with 161 additions and 38 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Expand Up @@ -342,4 +342,7 @@ ASALocalRun/
healthchecksdb

# Backup folder for Package Reference Convert tool in Visual Studio 2017
MigrationBackup/
MigrationBackup/

# Specific to this report
results/*
121 changes: 121 additions & 0 deletions CMakeLists.txt
@@ -0,0 +1,121 @@
cmake_minimum_required(VERSION 3.8)

project(GraphCut_RANSAC LANGUAGES CXX)

# indicate if OPENMP should be enabled
option(USE_OPENMP "Use OPENMP" ON)

# ==============================================================================
# Check C++17 support
# ==============================================================================
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

# ==============================================================================
# Find OpenCV
# ==============================================================================
find_package(OpenCV 3.3 REQUIRED)

# ==============================================================================
# Find OpenMP
# ==============================================================================
find_package(OpenMP)
if (USE_OPENMP)
if(NOT OPENMP_FOUND)
message(FATAL_ERROR "OPENMP not found.")
endif()
add_definitions(-DUSE_OPENMP)
set(TRGT_LNK_LBS_ADDITIONAL OpenMP::OpenMP_CXX)
endif (USE_OPENMP)

# ==============================================================================
# Includes
# ==============================================================================
include_directories (
${PROJECT_SOURCE_DIR}/include/GraphCut_RANSAC
)

# ==============================================================================
# Structure: Library
# ==============================================================================
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/lib)

# Set header files for the library
file(GLOB_RECURSE HDRS_GCRANSAC
"include/GraphCut_RANSAC/*.h"
"include/GraphCut_RANSAC/*.cpp"
)

# Set source files to be added to the library
file(GLOB_RECURSE SRCS_GCRANSAC
"src/GraphCut_RANSAC/*.cpp"
)

source_group(third_pary\\GCOptimization FILES
src/GraphCut_RANSAC/GCoptimization.cpp
include/GraphCut_RANSAC/graph.cpp
src/GraphCut_RANSAC/LinkedBlockList.cpp
include/GraphCut_RANSAC/maxflow.cpp
include/GraphCut_RANSAC/block.h
include/GraphCut_RANSAC/energy.h
include/GraphCut_RANSAC/GCoptimization.h
include/GraphCut_RANSAC/graph.h
include/GraphCut_RANSAC/LinkedBlockList.h
)

source_group(third_pary\\Theia FILES
include/GraphCut_RANSAC/prosac.h
include/GraphCut_RANSAC/prosac_sampler.h
include/GraphCut_RANSAC/quality_measurement.h
include/GraphCut_RANSAC/sample_consensus_estimator.h
include/GraphCut_RANSAC/sampler.h
include/GraphCut_RANSAC/inline_support.h
include/GraphCut_RANSAC/estimator.h
)

add_library(${PROJECT_NAME} STATIC
${HDRS_GCRANSAC}
${SRCS_GCRANSAC}
)

target_link_libraries(${PROJECT_NAME}
${OpenCV_LIBS}
)

# ==============================================================================
# Structure: Applications
# ==============================================================================
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_SOURCE_DIR}/bin)


# five_point
file(GLOB_RECURSE HDRSSRCS_FIVE_POINT
"src/Sample_FundamentalEstimator/five_point/*.*"
)
source_group(third_pary\\five_point FILES
${HDRSSRCS_FIVE_POINT}
)

# estimators
source_group("Estimators" FILES
src/Sample_FundamentalEstimator/essential_estimator.h
src/Sample_FundamentalEstimator/fundamental_estimator.h
src/Sample_FundamentalEstimator/homography_estimator.h
src/Sample_FundamentalEstimator/line_estimator.h
)


add_executable(Sample_FundamentalEstimator
${HDRSSRCS_FIVE_POINT}
src/Sample_FundamentalEstimator/essential_estimator.h
src/Sample_FundamentalEstimator/fundamental_estimator.h
src/Sample_FundamentalEstimator/homography_estimator.h
src/Sample_FundamentalEstimator/line_estimator.h
src/Sample_FundamentalEstimator/main.cpp)

target_link_libraries(Sample_FundamentalEstimator
${OpenCV_LIBS}
${PROJECT_NAME}
)
add_dependencies(Sample_FundamentalEstimator ${PROJECT_NAME})
8 changes: 5 additions & 3 deletions include/GraphCut_RANSAC/GCRANSAC.h
Expand Up @@ -681,8 +681,10 @@ Score GCRANSAC<ModelEstimator, Model>::get_score(const cv::Mat &points_,

std::vector<Score> process_scores(process_number, { 0,0 });

concurrency::parallel_for(0, process_number, [&](int process)
{
#ifdef USE_OPENMP
#pragma omp for
#endif
for (int process = 0; process < process_number; process++) {
if (store_inliers_)
process_inliers[process].reserve(step_size);
const int start_idx = process * step_size;
Expand All @@ -702,7 +704,7 @@ Score GCRANSAC<ModelEstimator, Model>::get_score(const cv::Mat &points_,
process_scores[process].J += 1.0f - distance * distance / truncated_threshold_2; // Truncated quadratic cost
}
}
});
}

for (auto i = 0; i < process_number; ++i)
{
Expand Down
8 changes: 5 additions & 3 deletions include/GraphCut_RANSAC/estimator.h
Expand Up @@ -98,11 +98,13 @@ namespace theia
const Model& model) const
{
std::vector<double> residuals(data.size());
concurrency::parallel_for(0, (int)data.size(), [&](int i)
//for (int i = 0; i < data.size(); i++)
#ifdef USE_OPENMP
#pragma omp parallel for
#endif
for (int i = 0; i < data.size(); i++)
{
residuals[i] = Error(data[i], model);
});
}
return residuals;
}

Expand Down
1 change: 0 additions & 1 deletion include/GraphCut_RANSAC/prosac_sampler.h
Expand Up @@ -42,7 +42,6 @@
#include <vector>

#include "sampler.h"
#include "random.h"

namespace theia
{
Expand Down
@@ -1,12 +1,10 @@
#include "stdafx.h"

#include <iostream>
#include <math.h>
#include <chrono>
#include <random>
#include <vector>

#include "5point.h"
#include "five_point/5point.h"
#include "estimator.h"
#include "prosac.h"

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,3 @@
#include "stdafx.h"

#include <iostream>
#include <math.h>
#include <chrono>
Expand Down
@@ -1,8 +1,8 @@
#include "stdafx.h"

#include "estimator.h"
#include "prosac.h"

#include <opencv2/calib3d/calib3d.hpp>

using namespace theia;

struct Homography
Expand Down
@@ -1,5 +1,3 @@
#include "stdafx.h"

#include <iostream>
#include <math.h>
#include <chrono>
Expand Down
44 changes: 23 additions & 21 deletions src/Sample/main.cpp → src/Sample_FundamentalEstimator/main.cpp
@@ -1,24 +1,24 @@
// VisionFrameWork.cpp : Defines the entry point for the console application.
// main.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"

#include <sstream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <set>
#include <opencv2\highgui\highgui.hpp>
#include <opencv2\features2d.hpp>
#include "opencv2/xfeatures2d.hpp"
#include <functional>
#include <algorithm>
#include <set>
#include <sstream>
#include <vector>

#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/xfeatures2d.hpp>

#include "GCRANSAC.h"
#include <ppl.h>
#include <ctime>
#include "line_estimator.cpp"
#include "essential_estimator.cpp"
#include "fundamental_estimator.cpp"
#include "homography_estimator.cpp"
#include "line_estimator.h"
#include "essential_estimator.h"
#include "fundamental_estimator.h"
#include "homography_estimator.h"

#include <direct.h>
#include <sys/types.h>
Expand Down Expand Up @@ -69,8 +69,10 @@ int main(int argc, const char* argv[])

std::string task = "head";

const std::string root_dir = "../";

// Create the task directory of doesn't exist
std::string dir = "results/" + task;
std::string dir = root_dir + "results/" + task;

if (stat(dir.c_str(), &info) != 0)
if (_mkdir(dir.c_str()) != 0)
Expand All @@ -79,11 +81,11 @@ int main(int argc, const char* argv[])
return -1;
}

std::string srcImagePath = "data/" + task + "/" + task + "1.jpg";
std::string dstImagePath = "data/" + task + "/" + task + "2.jpg";
std::string input_correspondence_path = "results/" + task + "/" + task + "_points_with_no_annotation.txt";
std::string output_correspondence_path = "results/" + task + "/result_" + task + ".txt";
std::string output_matchImagePath = "results/" + task + "/matches_" + task + ".png";
std::string srcImagePath = root_dir + "data/" + task + "/" + task + "1.jpg";
std::string dstImagePath = root_dir + "data/" + task + "/" + task + "2.jpg";
std::string input_correspondence_path = root_dir + "results/" + task + "/" + task + "_points_with_no_annotation.txt";
std::string output_correspondence_path = root_dir + "results/" + task + "/result_" + task + ".txt";
std::string output_matchImagePath = root_dir + "results/" + task + "/matches_" + task + ".png";

const float confidence = 0.99f;
const int fps = -1;
Expand Down

0 comments on commit 9669785

Please sign in to comment.