Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 27 additions & 23 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ if(BUILD_MATLAB)
endif()
endif()

set(CMAKE_CXX_FLAGS "-std=c++11 -Wall ${CMAKE_CXX_FLAGS}")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang")
set(CMAKE_CXX_FLAGS "-std=c++14 -Wall ${CMAKE_CXX_FLAGS}")
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND NOT ANDROID)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
endif()

Expand Down Expand Up @@ -118,11 +118,12 @@ SET(SOURCES
## Find required dependencies
find_package( Eigen3 REQUIRED )
find_package( Sophus REQUIRED )
find_package( GLog REQUIRED )
find_package( glog REQUIRED CONFIG)
set(HAVE_GLOG 1)
list( APPEND LINK_LIBS glog::glog )

find_package(TinyXML2 REQUIRED)
list(APPEND CALIBU_INC ${TinyXML2_INCLUDE_DIRS} )
list(APPEND LINK_LIBS ${TinyXML2_LIBRARIES} )
find_package(tinyxml2 REQUIRED CONFIG)
list(APPEND LINK_LIBS tinyxml2 )


## Apply project include directories
Expand All @@ -139,7 +140,7 @@ list( APPEND USER_INC ${Sophus_INCLUDE_DIRS} )
## Find optional dependencies

# OpenCV is required for PNP methods and calibration application
find_package( OpenCV REQUIRED core calib3d )
find_package( OpenCV REQUIRED calib3d imgproc core )
if( OpenCV_FOUND )
set( HAVE_OPENCV 1 )
list( APPEND LINK_LIBS ${OpenCV_LIBS})
Expand All @@ -148,20 +149,6 @@ if( OpenCV_FOUND )
list( APPEND SOURCES ${SRC_DIR}/pose/Pnp.cpp ${SRC_DIR}/pose/Tracker.cpp )
endif()

#######################################################
## Setup and configure library
## Generate symbol export helper header on MSVC
IF(MSVC)
string(TOUPPER ${LIBRARY_NAME} LIBRARY_NAME_CAPS)
include(GenerateExportHeader)
GENERATE_EXPORT_HEADER( ${LIBRARY_NAME}
BASE_NAME ${LIBRARY_NAME_CAPS}
EXPORT_MACRO_NAME ${LIBRARY_NAME_CAPS}_EXPORT
EXPORT_FILE_NAME "${CMAKE_CURRENT_BINARY_DIR}/include/${LIBRARY_NAME}/${LIBRARY_NAME}_export.h"
STATIC_DEFINE ${LIBRARY_NAME_CAPS}_BUILT_AS_STATIC
)
ENDIF()

#######################################################
## Optionally create unit tests

Expand Down Expand Up @@ -194,6 +181,22 @@ endif()
add_library( calibu ${SOURCES} )
target_link_libraries( calibu ${LINK_LIBS} )

#######################################################
## Setup and configure library
## Generate symbol export helper header on MSVC
SET(EXPORT_HEADER)
IF(MSVC)
SET(EXPORT_HEADER "${CMAKE_CURRENT_BINARY_DIR}/include/${LIBRARY_NAME}/${LIBRARY_NAME}_export.h")
string(TOUPPER ${LIBRARY_NAME} LIBRARY_NAME_CAPS)
include(GenerateExportHeader)
GENERATE_EXPORT_HEADER( ${LIBRARY_NAME}
BASE_NAME ${LIBRARY_NAME_CAPS}
EXPORT_MACRO_NAME ${LIBRARY_NAME_CAPS}_EXPORT
EXPORT_FILE_NAME ${EXPORT_HEADER}
STATIC_DEFINE ${LIBRARY_NAME_CAPS}_BUILT_AS_STATIC
)
ENDIF()

# install everything
install_package(
PKG_NAME Calibu
Expand All @@ -202,10 +205,11 @@ install_package(
DESCRIPTION "Computer vision camera model library."
# INSTALL_HEADERS ${HEADERS}
INSTALL_INCLUDE_DIR true
INSTALL_GENERATED_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/include/calibu/config.h
INSTALL_GENERATED_HEADERS ${CMAKE_CURRENT_BINARY_DIR}/include/calibu/config.h ${EXPORT_HEADER}
DESTINATION ${CMAKE_INSTALL_PREFIX}
INCLUDE_DIRS ${USER_INC}
INCLUDE_DIRS ${USER_INC} ${CMAKE_INSTALL_PREFIX}/include
LINK_LIBS ${LINK_LIBS}
LINK_DIRS ${CMAKE_INSTALL_PREFIX}/lib
)

if( BUILD_APPLICATIONS )
Expand Down
4 changes: 4 additions & 0 deletions cmake_modules/PackageConfig.cmake.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
include (CMakeFindDependencyMacro)

find_dependency(tinyxml2 @tinyxml2_VERSION@)

SET( @PACKAGE_PKG_NAME@_LIBRARIES "@PACKAGE_LINK_LIBS@" CACHE INTERNAL "@PACKAGE_PKG_NAME@ libraries" FORCE )
SET( @PACKAGE_PKG_NAME@_INCLUDE_DIRS @PACKAGE_INCLUDE_DIRS@ CACHE INTERNAL "@PACKAGE_PKG_NAME@ include directories" FORCE )
SET( @PACKAGE_PKG_NAME@_LIBRARY_DIRS @PACKAGE_LINK_DIRS@ CACHE INTERNAL "@PACKAGE_PKG_NAME@ library directories" FORCE )
Expand Down
17 changes: 13 additions & 4 deletions cmake_modules/install_package.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ function(install_package)
endif()
get_target_property( _target_library ${PACKAGE_LIB_NAME} LOCATION )
get_filename_component( _lib ${_target_library} NAME )
list( APPEND PACKAGE_LINK_LIBS ${PACKAGE_LIB_NAME} )
list( INSERT PACKAGE_LINK_LIBS 0 ${PACKAGE_LIB_NAME} )
endif()

if( PACKAGE_INSTALL_HEADER_DIRS )
Expand Down Expand Up @@ -141,10 +141,19 @@ function(install_package)

# install library itself
if( PACKAGE_LIB_NAME )
install( FILES ${_target_library} DESTINATION ${CMAKE_INSTALL_PREFIX}/lib )

if(MSVC)
string(REPLACE "$(Configuration)" "\${BUILD_TYPE}" _target_library ${_target_library})
endif()

install( TARGETS ${PACKAGE_LIB_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
set( PACKAGE_LIB_LINK "-l${PACKAGE_LIB_NAME}" )
endif()

# build pkg-config file
if( PACKAGE_PKG_NAME )
configure_file( ${modules_dir}/PkgConfig.pc.in ${PACKAGE_PKG_NAME}.pc @ONLY )
Expand Down Expand Up @@ -195,7 +204,7 @@ function(install_package)
cmake_policy( SET CMP0026 OLD )
endif()
get_target_property( _target_library ${PACKAGE_LIB_NAME} LOCATION )
list( APPEND PACKAGE_LINK_LIBS ${_target_library} )
list( INSERT PACKAGE_LINK_LIBS 0 ${_target_library} )
endif()

if( PACKAGE_INSTALL_HEADER_DIRS )
Expand Down
6 changes: 3 additions & 3 deletions include/calibu/cam/rectify_crtp.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ namespace calibu
};

///////////////////////////////////////////////////////////////////////////////
CALIBU_EXPORT
struct LookupTable

struct CALIBU_EXPORT LookupTable
{
inline LookupTable():m_vLutPixels(std::vector<BilinearLutPoint>()),m_nWidth(0){};
inline LookupTable( int nWidth, int nHeight )
Expand Down Expand Up @@ -129,7 +129,7 @@ namespace calibu
/// Rectify image pInputImageData using lookup table generated by
/// 'CreateLookupTable' to output image pOutputRectImageData.
template <typename scalar>
CALIBU_EXPORT void Rectify(
void Rectify(
const LookupTable& lut,
const scalar* pInputImageData,
scalar* pOutputRectImageData,
Expand Down
2 changes: 2 additions & 0 deletions include/calibu/conics/Conic.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ struct Conic {

// center (c1,c2)
Eigen::Vector2d center;
Eigen::Vector3d center_undistorted;
double radius;
};

CALIBU_EXPORT
Expand Down
6 changes: 3 additions & 3 deletions include/calibu/conics/ConicFinder.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ struct ParamsConicFinder
float conic_min_aspect;
};

CALIBU_EXPORT
class ConicFinder

class CALIBU_EXPORT ConicFinder
{
public:
ConicFinder();
void Find(const ImageProcessing& imgs);
void Find(const ImageProcessing& imgs, const std::shared_ptr<calibu::CameraInterface<double>> camera = nullptr);

inline const std::vector<Conic, Eigen::aligned_allocator<Conic> >&
Conics() const {
Expand Down
4 changes: 2 additions & 2 deletions include/calibu/image/ImageProcessing.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ struct ParamsImageProcessing {
bool black_on_white;
};

CALIBU_EXPORT
class ImageProcessing {

class CALIBU_EXPORT ImageProcessing {
public:
ImageProcessing(int maxWidth, int maxHeight);
~ImageProcessing();
Expand Down
1 change: 1 addition & 0 deletions include/calibu/pcalib/base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <algorithm>
#include <sstream>
#include <vector>
#include <Eigen/Eigen>

#include <iostream>
Expand Down
6 changes: 4 additions & 2 deletions include/calibu/pose/Pnp.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,20 @@

#include <vector>
#include <sophus/se3.hpp>
#include <calibu/Platform.h>
#include <calibu/cam/camera_crtp.h>

namespace calibu {

std::vector<int> PosePnPRansac(
std::vector<int> CALIBU_EXPORT PosePnPRansac(
const std::shared_ptr<CameraInterface<double>> cam,
const std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > & img_pts,
const std::vector<Eigen::Vector3d, Eigen::aligned_allocator<Eigen::Vector3d> > & ideal_pts,
const std::vector<int> & candidate_map,
int robust_3pt_its,
float robust_3pt_tol,
Sophus::SE3d * T
Sophus::SE3d * T,
bool calibrate = false
);

double ReprojectionErrorRMS(
Expand Down
12 changes: 10 additions & 2 deletions include/calibu/target/LineGroup.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ struct Vertex
{
EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
inline Vertex(size_t id, const Conic& c)
: id(id), conic(c), pc(c.center), pg(GRID_INVALID,GRID_INVALID), area(0.0), value(-1)
: id(id), conic(c), pc(c.center), pg(GRID_INVALID,GRID_INVALID), area(0.0), value(-1), pc_u(c.center_undistorted)
{
}

Expand All @@ -53,6 +53,7 @@ struct Vertex
size_t id;
Conic conic;
Eigen::Vector2d pc;
Eigen::Vector3d pc_u;
Eigen::Vector2i pg;
std::vector<Triple> triples;
std::set<Vertex*> neighbours;
Expand All @@ -62,9 +63,10 @@ struct Vertex

struct Triple
{
inline Triple(Vertex& o1, Vertex& c, Vertex& o2)
inline Triple(Vertex& o1, Vertex& c, Vertex& o2, Eigen::Vector2d angles = Eigen::Vector2d())
{
vs = {&o1, &c, &o2};
m_angles = angles;
}

Triple(const Triple& triple) = default;
Expand Down Expand Up @@ -104,6 +106,7 @@ struct Triple

// Colinear sequence of vertices, v[0], v[1], v[2]. v[1] is center
std::vector<Vertex*> vs;
Eigen::Vector2d m_angles;
};

inline bool operator==(const Vertex& lhs, const Vertex& rhs)
Expand All @@ -121,6 +124,11 @@ inline double Distance(const Vertex& v1, const Vertex& v2)
return (v2.pc - v1.pc).norm();
}

inline double DistanceUndistorted(const Vertex& v1, const Vertex& v2)
{
return (v2.pc_u - v1.pc_u).squaredNorm();
}

inline std::ostream& operator<<(std::ostream& os, const Vertex& v)
{
os << "(" << v.pg.transpose() << ")";
Expand Down
14 changes: 7 additions & 7 deletions include/calibu/target/TargetGridDot.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ inline bool operator<(const Dist& lhs, const Dist& rhs) { return lhs.dist < rhs.
struct ParamsGridDot
{
ParamsGridDot() :
max_line_dist_ratio(0.3),
max_norm_triple_area(0.03),
max_line_dist_ratio(0.4),
max_norm_triple_area(0.05),
min_cross_area(1.5),
max_cross_area(9.0),
cross_radius_ratio(0.058),
Expand All @@ -65,8 +65,8 @@ struct ParamsGridDot
double cross_line_ratio;
};

CALIBU_EXPORT
class TargetGridDot

class CALIBU_EXPORT TargetGridDot
: public TargetInterface
{
public:
Expand Down Expand Up @@ -166,9 +166,9 @@ class TargetGridDot
void Clear();
void SetGrid(Vertex& v, const Eigen::Vector2i& g);
bool Match(std::map<Eigen::Vector2i const, Vertex*,
std::less<Eigen::Vector2i>,
Eigen::aligned_allocator<std::pair<Eigen::Vector2i const, Vertex*> > >& obs,
const std::array<Eigen::MatrixXi,4>& PG);
std::less<Eigen::Vector2i>,
Eigen::aligned_allocator<std::pair<Eigen::Vector2i const, Vertex*> > >& obs,
const std::array<Eigen::MatrixXi,4>& PG);

std::vector<Eigen::Vector2d, Eigen::aligned_allocator<Eigen::Vector2d> > tpts2d;
std::vector<double> tpts2d_radius;
Expand Down
Loading