Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows build #78

Merged
merged 72 commits into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
72 commits
Select commit Hold shift + click to select a range
7642122
[cmake] add NOMINMAX flag for windows build
simogasp Jun 9, 2018
990f6a9
[utils] update pcg to a recent version MSVC compliant
simogasp Jun 9, 2018
59d32b3
[cctag] unused includes
simogasp Jun 9, 2018
79d621d
[utils] new definition for ssize_t
simogasp Jun 9, 2018
1769949
[cctag] fix float for hardcoded values
simogasp Jun 9, 2018
06746b3
[utils] win does not support "not"
simogasp Jun 9, 2018
4d0b39c
[c++] variable size array not standard (only gcc/clang?)
simogasp Jun 9, 2018
b7c711b
[cctag] use boost for M_PI
simogasp Jun 9, 2018
c56da4c
[cctag] std::numeric_limits<float>::max() instead of arbitrary value
simogasp Jun 9, 2018
36ee94f
[cctag] type coherence
simogasp Jun 9, 2018
68cb46b
[cctag] using std c++ exceptions
simogasp Jun 9, 2018
22ed609
[cctag] casting
simogasp Jun 9, 2018
260595b
[utils] missing return statement
simogasp Jun 9, 2018
750f77a
[cctag] using boost filesystem instead of posix to create directories
simogasp Jun 9, 2018
5a38092
[cctag] using struct for params, they were mixed between hpp and cpp
simogasp Jun 9, 2018
fb796ec
[applications] using string() instead of native()
simogasp Jun 9, 2018
7f97e00
[applications] CmdLine using boost instead gnu getopt
simogasp Jun 9, 2018
444cf20
[cmake] add option to build the application
simogasp Jun 9, 2018
3a54fc7
[ci] test build on appveyor
simogasp Jun 9, 2018
41c9ff1
[doc] update dependencies
simogasp Jun 10, 2018
2804564
[applications] missing return
simogasp Jun 10, 2018
c51fc04
[cmake] pthread and dl only for *nix
simogasp Jun 10, 2018
cbaa9fb
[cuda] "not" is not supported
simogasp Jun 10, 2018
cc49a54
[cuda] removed unused *nix header
simogasp Jun 10, 2018
f16c560
fixup! [cmake] pthread and dl only for *nix
simogasp Jun 10, 2018
09f59c3
[cctag] better refactoring
simogasp Jun 10, 2018
24de6a2
[ci] enable apps on windows
simogasp Jun 10, 2018
1c43ccb
[ci] test boost on vcpkg
simogasp Jun 15, 2018
a168b06
Merge branch 'develop' into devWindozeFixes
fabiencastan Oct 6, 2018
e1d58cd
Merge remote-tracking branch 'origin/develop' into devWindozeFixes
yann-lty May 15, 2019
04e0fd8
minor syntax fix: remove "not" keyword
fabiencastan May 15, 2019
3069ab8
ssize_t compatibility with MSVC
fabiencastan May 15, 2019
4295529
Replace boost thread by std thread
fabiencastan May 15, 2019
c934a11
Compatibility: use std::rand
fabiencastan May 15, 2019
086d9a5
minor includes clean
fabiencastan May 15, 2019
560850d
[windows] new cctag_cuda_runtime.h header to set define for compatibi…
fabiencastan May 19, 2019
32c094f
[windows] workaround for MSVC compatibility
fabiencastan May 19, 2019
d1e18a2
[utils] replace custom code for backtrace with boost::stacktrace
fabiencastan May 19, 2019
0efae48
[cmake] workaround for TBB build error on windows
fabiencastan May 19, 2019
e4b3b88
[travis] update cmake version to 3.14.4
fabiencastan May 19, 2019
30d09fc
[cuda] always use cctag_cuda_runtime.h
fabiencastan Jul 2, 2019
9f31170
[cuda] define BOOST_NO_CXX11_DEFAULTED_FUNCTIONS on linux
fabiencastan Jul 2, 2019
02b0fc1
[cctag] minor include fixes
fabiencastan Jul 2, 2019
48ff995
[cmake] change boost::stacktrace link on linux
fabiencastan Jul 2, 2019
60588ca
[travis] update dependencies versions
fabiencastan Jul 2, 2019
a224fe8
[travis] use boost 1.70
fabiencastan Jul 3, 2019
4f4005c
[travis] enable build_shared_libs
fabiencastan Jul 3, 2019
b1c940e
Update deprecated boost include
fabiencastan Jul 3, 2019
e631622
[cmake] same check for boost in top level and app folder
fabiencastan Jul 3, 2019
b2b8b1a
[travis] build lib without apps first
fabiencastan Jul 3, 2019
8525049
[cmake] fix minimum cmake version
fabiencastan Jul 3, 2019
ae285e9
[cmake] print boost variables
fabiencastan Jul 3, 2019
f6a5621
[build] replace usage of "not" keyword for windows compatibility
fabiencastan Jul 3, 2019
6f653cd
[build] windows compatibility: use VirtualLock as an equivalent to mlock
fabiencastan Jul 3, 2019
88697d6
[cmake] Boost 1.70 compatibility workaround
fabiencastan Jul 4, 2019
2aa76ed
[doc] fix merge error in INSTALL.md
fabiencastan Jul 4, 2019
3b8fea2
[travis] add CTEST_OUTPUT_ON_FAILURE
fabiencastan Jul 4, 2019
237727d
[cmake] use boost TARGETS
fabiencastan Jul 4, 2019
57033b7
[cmake] only use boost TARGETS
fabiencastan Jul 4, 2019
d2a34cc
[cmake] remove undefined boost targets
fabiencastan Jul 4, 2019
0331bec
[cmake] use only boost TARGETS
fabiencastan Jul 4, 2019
0e9e8ed
[test] disable test_throw_repeated_points for now
fabiencastan Jul 4, 2019
eb9f8c8
[cmake] fix boost targets in applications
fabiencastan Jul 4, 2019
b9dce30
[cmake] fix USE_DEVIL define
fabiencastan Jul 5, 2019
a480b9a
Replace deprecated boost::timer
fabiencastan Jul 5, 2019
93dc0eb
[cmake] add missing dep
fabiencastan Jul 5, 2019
8fbd8bf
[travis] check build of applications in the global context
fabiencastan Jul 6, 2019
b9106c5
[doc] Update INSTALL.md requirements
fabiencastan Jul 6, 2019
2b8a942
[doc] Readme: add Simone Gasparini to authors list
fabiencastan Jul 11, 2019
678dded
[doc] Update INSTALL.md: Cuda is optional and GPU part is problematic…
fabiencastan Jul 11, 2019
ee16bc5
Use throw instead of BOOST_THROW_EXCEPTION
fabiencastan Jul 11, 2019
cdd97d2
[cmake] enable exception handling on windows
fabiencastan Jul 11, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions BUILD.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,13 @@ $ git clone https://github.com/alicevision/CCTag.git
Most of the dependencies can be installed from the common repositories (apt, yum etc):

- Eigen3 (libeigen3-dev)
- Boost >= 1.53 ([core, thread, system, filesystem, serialization, thread, exception, chrono, date-time, program-options, timer]-dev)
- Boost >= 1.53 ([accumulators, atomic, chrono, core, date-time, exception, filesystem, math, program-options, ptr-container, system, serialization, timer, thread]-dev)
- OpenCV >= 3.1
- tbb >= 4.0

On a recent Ubuntu-like distribution (e.g. 14.04), you may want to try to run:
```shell
$ sudo apt-get install g++ git-all libpng12-dev libjpeg-dev libeigen3-dev libboost-atomic-dev libboost-chrono-dev libboost-date-time-dev libboost-dev libboost-program-options-dev libboost-exception-dev libboost-filesystem-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev libboost-timer-dev
$ sudo apt-get install g++ git-all libpng12-dev libjpeg-dev libeigen3-dev libboost-atomic-dev libboost-chrono-dev libboost-date-time-dev libboost-dev libboost-program-options-dev libboost-exception-dev libboost-filesystem-dev libboost-serialization-dev libboost-system-dev libboost-thread-dev libboost-timer-dev libtbb-dev
```

OpenCV need to be compiled separately and installed in some `OPENCV_INSTALL` path. Then, when running cmake you need to provide the path to the location where `OpenCVConfig.cmake` is installed, usually `${OPENCV_INSTALL}/share/share/OpenCV/` (see below).
Expand All @@ -43,7 +44,7 @@ You now just need to be in the CCTag folder and run cmake:
$ mkdir build && cd build
$ cmake .. -DOpenCV_DIR=${OPENCV_INSTALL}/share/share/OpenCV/
$ make -j `nproc`
```
```

If you want to install the library to, say, a CCTAG_INSTALL path, just add `-DCMAKE_INSTALL_PREFIX=$CCTAG_INSTALL` at cmake command line.
If you want to build CCTag as a shared library: `-DBUILD_SHARED_LIBS=ON`.
Expand All @@ -56,7 +57,7 @@ When you install CCTag a file `CCTagConfig.cmake` is installed in `$CCTAG_INSTAL
In your `CMakeLists.txt` file you can add the dependency in this way:

```cmake
# Find the package from the CCTagConfig.cmake
# Find the package from the CCTagConfig.cmake
# in <prefix>/lib/cmake/CCTag/. Under the namespace CCTag::
# it exposes the target CCTag that allows you to compile
# and link with the library
Expand All @@ -80,4 +81,3 @@ Note 1: CCTag uses NVidia CUB (CCTag includes a copy of CUB from CUDA 7.0).
Several CUB functions are known to fail with a few NVidia cards including our reference card,
the GTX 980 Ti.
The CUB that is included with CUDA 7.5 does not solve this problem.

1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ option(CCTAG_SERIALIZE "Store all the output" OFF)
option(VISUAL_DEBUG "Enable visual debug" OFF)
option(CCTAG_NO_COUT "Disable output stream" ON)
option(WITH_CUDA "Compile the library with CUDA support" ON)
option(BUILD_APPS "Build the sample applications" ON)

option(CCTAG_USE_POSITION_INDEPENDENT_CODE "Generate position independent code." ON)
option(CCTAG_ENABLE_SIMD_AVX2 "Enable AVX2 optimizations" OFF)
Expand Down
58 changes: 58 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version: '1.0.{build}'

image: Visual Studio 2015

platform:
- x64

configuration:
- Release

install:
# - cmd: >-
# call cudaInstallAppveyor.cmd

- vcpkg upgrade --no-dry-run
- vcpkg list
- vcpkg install
boost-accumulators
boost-algorithm
boost-container
boost-date-time
boost-exception
boost-filesystem
boost-iterator
boost-lexical-cast
boost-math
boost-mpl
boost-multi-array
boost-ptr-container
boost-program-options
boost-serialization
boost-spirit
boost-static-assert
boost-test
boost-thread
boost-throw-exception
boost-timer
boost-type-traits
boost-unordered
opencv
tbb
eigen3
--triplet %PLATFORM%-windows
- vcpkg list

before_build:
- md build
- cd build
- cmake -G "Visual Studio 14 2015" -A x64 -T v140,host=x64 -DCMAKE_BUILD_TYPE=%configuration% -DCMAKE_TOOLCHAIN_FILE=c:/tools/vcpkg/scripts/buildsystems/vcpkg.cmake -DBUILD_APPS:BOOL=ON -DWITH_CUDA:BOOL=OFF -DCCTAG_SERIALIZE:BOOL=ON -DVISUAL_DEBUG:BOOL=ON ..
- ls -l

build:
verbosity: detailed
project: $(APPVEYOR_BUILD_FOLDER)\build\CCTag.sln
parallel: true

cache:
c:\tools\vcpkg\installed\
56 changes: 35 additions & 21 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ set( CCTag_cpp

if(WITH_CUDA)

set(CUDA_cpp
set(CUDA_cpp
./cctag/cuda/debug_macros.cpp
./cctag/cuda/device_prop.cpp)

Expand Down Expand Up @@ -87,32 +87,36 @@ if(WITH_CUDA)
# set(BUILD_SHARED_LIBS ON)

set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-DSM_ARCH=${CCTAG_SM_ARCH};-DSM=${CCTAG_SM};-DCUB_CDP")

# this must go before CUDA_ADD_LIBRARY otherwise we won't be able to add it
# after
# https://github.com/Kitware/CMake/blob/master/Modules/FindCUDA.cmake#L147
# INCLUDE_DIRECTORIES -- "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
# INCLUDE_DIRECTORIES -- "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
include_directories(${CMAKE_CURRENT_LIST_DIR}
${Boost_INCLUDE_DIRS} ${OpenCV_INCLUDE_DIRS} ${Eigen_INCLUDE_DIR}
${TBB_INCLUDE_DIRS}
"${CMAKE_SOURCE_DIR}/src"
"${CMAKE_SOURCE_DIR}/3rdparty/Cuda-7.0-cub")

CUDA_ADD_LIBRARY(CCTag ${CUDA_cpp} ${CUDA_cu} ${CCTag_cpp})

# since we used CUDA_ADD_LIBRARY we cannot use PUBLIC or PRIVATE here
target_link_libraries(CCTag
${OpenCV_LIBS} ${Boost_LIBRARIES} ${Eigen_LIBRARIES}
${TBB_LIBRARIES} ${CUDA_CUDADEVRT_LIBRARY} pthread dl)
target_link_libraries(CCTag
${OpenCV_LIBS} ${Boost_LIBRARIES} ${Eigen_LIBRARIES}
${TBB_LIBRARIES} ${CUDA_CUDADEVRT_LIBRARY})

target_compile_definitions(CCTag
PUBLIC ${Boost_DEFINITIONS}
if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_link_libraries(CCTag pthread dl)
endif()

target_compile_definitions(CCTag
PUBLIC ${Boost_DEFINITIONS}
PUBLIC -DWITH_CUDA -DSM_ARCH=${CCTAG_SM_ARCH} -DSM=${CCTAG_SM} -DCUB_CDP
PRIVATE ${TBB_DEFINITIONS})
PRIVATE ${TBB_DEFINITIONS})

# This is nececessary for the CCTagConfig.cmake to correctly export the
# includes, always because we used CUDA_ADD_LIBRARY
set_target_properties(CCTag PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
set_target_properties(CCTag PROPERTIES INTERFACE_INCLUDE_DIRECTORIES
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>;${CUDA_INCLUDE_DIRS};${Boost_INCLUDE_DIRS};${Eigen_INCLUDE_DIR};${OpenCV_INCLUDE_DIRS}")
get_target_property(testprop CCTag INTERFACE_INCLUDE_DIRECTORIES )
message(STATUS "testprop: ${testprop}")
Expand All @@ -125,25 +129,33 @@ else(WITH_CUDA)
add_library(CCTag ${CCTag_cpp})
set_target_properties(CCTag PROPERTIES VERSION ${PROJECT_VERSION})

target_include_directories(CCTag
target_include_directories(CCTag
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}>"
"$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
PUBLIC ${Boost_INCLUDE_DIRS} ${Eigen_INCLUDE_DIR} ${OpenCV_INCLUDE_DIRS}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${Boost_INCLUDE_DIRS} can now be removed. When you specify the target Boost::boost in target_link_libraries() it automagically add the relevant includes and definitions

PRIVATE ${TBB_INCLUDE_DIRS})
PRIVATE ${TBB_INCLUDE_DIRS})

get_target_property(testprop CCTag INTERFACE_INCLUDE_DIRECTORIES )
message(STATUS "testprop: ${testprop}")

target_compile_definitions(CCTag
PUBLIC ${Boost_DEFINITIONS}
PRIVATE ${TBB_DEFINITIONS})

target_link_libraries(CCTag
PUBLIC ${OpenCV_LIBS} ${Boost_LIBRARIES} ${Eigen_LIBRARIES}
PRIVATE ${TBB_LIBRARIES} pthread dl)
target_compile_definitions(CCTag
PUBLIC ${Boost_DEFINITIONS}
PRIVATE ${TBB_DEFINITIONS})

target_link_libraries(CCTag
PUBLIC ${OpenCV_LIBS} ${Boost_LIBRARIES} ${Eigen_LIBRARIES}
PRIVATE ${TBB_LIBRARIES})

if(NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_link_libraries(CCTag PRIVATE pthread dl)
endif()

endif(WITH_CUDA)

if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
target_compile_definitions(CCTag PUBLIC "-DNOMINMAX")
endif()

# enable serialization
if(CCTAG_SERIALIZE)
target_compile_definitions(CCTag PUBLIC "-DCCTAG_SERIALIZE")
Expand Down Expand Up @@ -246,4 +258,6 @@ install(EXPORT "${targets_export_name}"
NAMESPACE "${namespace}"
DESTINATION "${config_install_dir}")

add_subdirectory(applications)
if(BUILD_APPS)
add_subdirectory(applications)
endif()
124 changes: 48 additions & 76 deletions src/applications/detection/CmdLine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,19 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
#include <getopt.h>
#include <iostream>
#include <string>
#include <memory>


#include "CmdLine.hpp"

namespace cctag {

#define no_argument 0
#define required_argument 1
#define optional_argument 2


static const struct option longopts[] =
{
{"input", required_argument, 0, 'i'},
{"nbrings", required_argument, 0, 'n'},
{"bank", required_argument, 0, 'b'},
{"parameters", required_argument, 0, 'p'},
{"output", optional_argument, 0, 'o'},
#ifdef WITH_CUDA
{"sync", no_argument, 0, 0xd0 },
{"debug-dir", required_argument, 0, 0xd1 },
{"use-cuda", no_argument, 0, 0xd2 },
{"parallel", required_argument, 0, 0xd3 },
#endif
{0,0,0,0},
};

CmdLine::CmdLine( )
: _filename( "" )
, _nCrowns( "" )
, _nRings( 0 )
, _cctagBankFilename( "" )
, _paramsFilename( "" )
, _outputFolderName( "" )
Expand All @@ -45,52 +27,64 @@ CmdLine::CmdLine( )
, _useCuda( false )
, _parallel( 1 )
#endif
{ }
, _allParams("Program for detecting CCTags in images or in a video")
{
using namespace boost::program_options;

bool CmdLine::parse( int argc, char* argv[] )
{
int index;
int iarg=0;
options_description required("Required input parameters");
required.add_options()
("input,i", value<std::string>(&_filename)->required(), "Path to an image (JPG, PNG) or video (avi, mov) or camera index for live capture (0, 1...)")
("nbrings,n", value<std::size_t>(&_nRings)->required(), "Number of rings of the CCTags to detect");

// bools to check that mandatory parameters are present
bool has_i = false;
bool has_n = false;
options_description optional("Optional parameters");
optional.add_options()
("bank,b", value<std::string>(&_cctagBankFilename)->default_value(_cctagBankFilename), "Path to a bank parameter file, e.g. 4Crowns/ids.txt")
("params,p", value<std::string>(&_paramsFilename)->default_value(_paramsFilename), "Path to configuration XML file")
("output,o", value<std::string>(&_outputFolderName)->default_value(_outputFolderName), "Output folder name")
#ifdef WITH_CUDA
("sync", bool_switch(&_switchSync), "CUDA debug option, run all CUDA ops synchronously")
("use-cuda", bool_switch(&_useCuda), "Select GPU code instead of CPU code")
("debug-dir", value<std::string>(&_debugDir)->default_value(_debugDir), "Path storing image to debug intermediate GPU results")
("parallel", value<int>(&_parallel)->default_value(_parallel), "Use <n> CUDA pipes concurrently (default 1)")
#endif
;

_allParams.add(required).add(optional);
}

//turn off getopt error message
// opterr=1;
bool CmdLine::parse( int argc, char* argv[] )
{

while(iarg != -1)
{
iarg = getopt_long(argc, argv, "i:n:b:p:o:", longopts, &index);
using namespace boost::program_options;

switch (iarg)
{
case 'i' : _filename = optarg; has_i = true; break;
case 'n' : _nCrowns = optarg; has_n = true; break;
case 'b' : _cctagBankFilename = optarg; break;
case 'p' : _paramsFilename = optarg; break;
case 'o' : _outputFolderName = optarg; break;
#ifdef WITH_CUDA
case 0xd0 : _switchSync = true; break;
case 0xd1 : _debugDir = optarg; break;
case 0xd2 : _useCuda = true; break;
case 0xd3 : _parallel = strtol( optarg, NULL, 0 ); break;
#endif
default : break;
}
}
return ( has_i && has_n );
variables_map vm;
try
{
store(parse_command_line(argc, argv, _allParams), vm);
if (vm.count("help") || (argc == 1))
{
return false;
}
notify(vm);
}
catch (const std::exception& e)
{
std::cout << e.what() << std::endl;
return false;
}
return true;
}

void CmdLine::print( const char* const argv0 )
{
std::cout << "You called " << argv0 << " with:" << std::endl
<< " --input " << _filename << std::endl
<< " --nbrings " << _nCrowns << std::endl
<< " --nbrings " << _nRings << std::endl
<< " --bank " << _cctagBankFilename << std::endl
<< " --params " << _paramsFilename << std::endl
<< " --output " << _outputFolderName << std::endl;
#ifdef WITH_CUDA
std::cout << " --parallel " << _parallel << std::endl;
if( _switchSync )
std::cout << " --sync " << std::endl;
if( _debugDir != "" )
Expand All @@ -103,29 +97,7 @@ void CmdLine::print( const char* const argv0 )

void CmdLine::usage( const char* const argv0 )
{
std::cerr << "Usage: " << argv0 << "<parameters>\n"
" Mandatory:\n"
" [-i|--input] <imgpath>\n"
" [-n|--nbrings] <nbrings>\n"
" Optional:\n"
" [-p|--params <confpath>]\n"
" [-b|--bank] <bankpath>\n"
" [-o|--output] <outputfoldername>\n"
" [--sync]\n"
" [--debug-dir <debugdir>]\n"
" [--use-cuda]\n"
" [--parallel <n>]\n"
"\n"
" <imgpath> - path to an image (JPG, PNG) or video (avi, mov) or camera index for live capture (0, 1...)\n"
" <nbrings> - number of rings of the CCTags to detect\n"
" <bankpath> - path to a bank parameter file, e.g. 4Crowns/ids.txt \n"
" <output> - output folder name \n"
" <confpath> - path to configuration XML file \n"
" --sync - CUDA debug option, run all CUDA ops synchronously\n"
" <debugdir> - path storing image to debug intermediate GPU results\n"
" --use-cuda - select GPU code instead of CPU code\n"
" --parallel - use <n> CUDA pipes concurrently (default 1)\n"
"\n" << std::endl;
std::cout << _allParams << std::endl;
}

}
Expand Down