Skip to content

Commit 88fb458

Browse files
committed
Revise README.md and add instruction to run example codes
1 parent 14ea11c commit 88fb458

22 files changed

Lines changed: 159 additions & 104 deletions

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
data/KITTI07/image_0
22
slides
3-
build
43

4+
__pycache__
5+
build
56
x64
67
Debug
78
Release

CMakeLists.txt

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,32 @@
1-
cmake_minimum_required(VERSION 2.6)
2-
1+
cmake_minimum_required(VERSION 3.8)
32
project(3dv_tutorial)
4-
set(CMAKE_CXX_STANDARD 11)
5-
set(CMAKE_BUILD_TYPE Release)
3+
4+
# Find external packages and specify their locations
65
find_package(OpenCV REQUIRED)
76
find_package(Ceres REQUIRED)
87

9-
set(SRC_DIR "${CMAKE_SOURCE_DIR}/examples")
10-
set(BIN_DIR "${CMAKE_SOURCE_DIR}/bin")
8+
# Specify project files and locations
9+
set(EXAMPLE_DIR "${CMAKE_SOURCE_DIR}/examples")
10+
file(GLOB EXAMPLE_FILES ${EXAMPLE_DIR}/*.cpp)
11+
12+
# Set common configuration
13+
include_directories(
14+
${OpenCV_INCLUDE_DIRS}
15+
${Ceres_INCLUDE_DIRS}
16+
)
17+
link_directories(
18+
${OpenCV_LIB_DIRS}
19+
${Ceres_LIB_DIRS}
20+
)
21+
link_libraries(
22+
${OpenCV_LIBS}
23+
${CERES_LIBRARIES}
24+
)
25+
add_compile_definitions(GLOG_NO_ABBREVIATED_SEVERITIES)
1126

12-
file(GLOB APP_SOURCES "${SRC_DIR}/*.cpp")
13-
foreach(app_source ${APP_SOURCES})
14-
string(REPLACE ".cpp" "" app_name ${app_source})
15-
string(REPLACE "${SRC_DIR}/" "" app_name ${app_name})
16-
add_executable(${app_name} ${app_source})
17-
target_include_directories(${app_name} ${CERES_INCLUDE_DIRS})
18-
target_link_libraries(${app_name} ${OpenCV_LIBS} ${CERES_LIBRARIES})
19-
install(TARGETS ${app_name} DESTINATION ${BIN_DIR})
20-
endforeach(app_source ${APP_SOURCES})
27+
# Add an executable
28+
foreach(example_file ${EXAMPLE_FILES})
29+
string(REPLACE ".cpp" "" example_name ${example_file})
30+
string(REPLACE "${EXAMPLE_DIR}/" "" example_name ${example_name})
31+
add_executable(${example_name} ${example_file})
32+
endforeach()

HOWTO_RUN.md

Lines changed: 0 additions & 32 deletions
This file was deleted.

HOWTO_RUN_CPP.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
## How to Run Example Codes with Microsoft Visual Studio
2+
### Prerequisites
3+
* Install [Microsoft Visual Studio](https://www.visualstudio.com/) (shortly MSVS)
4+
* :memo: Note) Microsoft Visual Studio **Community** is _free_ for students, open-source contributors, and individual developers.
5+
* Install [Git](https://git-scm.com/) and [CMake](https://cmake.org/)
6+
* You need to [add their directory to PATH environment in Windows](https://stackoverflow.com/questions/44272416/how-to-add-a-folder-to-path-environment-variable-in-windows-10-with-screensho).
7+
* Install [vcpkg](https://vcpkg.io/) ([more details](https://vcpkg.io/en/getting-started))
8+
* You need to move your working directory where you want to install _vcpkg_ (I assume your working directory as `C:/`).
9+
```bash
10+
git clone https://github.com/Microsoft/vcpkg.git
11+
.\vcpkg\bootstrap-vcpkg.bat
12+
```
13+
* Install [OpenCV](https://opencv.org/) and [Ceres Solver](http://ceres-solver.org/) using _vcpkg_
14+
```bash
15+
cd vcpkg
16+
vcpkg install opencv[world,contrib]:x64-windows --recurse
17+
vcpkg install ceres[suitesparse,cxsparse,eigensparse,tools]:x64-windows
18+
vcpkg integrate install
19+
```
20+
21+
### Compiling and Running Examples
22+
1. Clone the repository: `git clone https://github.com/mint-lab/3dv_tutorial.git`
23+
* You need to move your working directory where you want to copy the repository.
24+
* Or you can download [example codes and slides as a ZIP file](https://github.com/sunglok/3dv_tutorial/archive/master.zip) and unzip it where you want.
25+
1. Generate MSVS solution and project files
26+
* You need to specify the _vcpkg_ directory where you installed it. (I assume you install it at `C:/`)
27+
```bash
28+
cd 3dv_tutorial
29+
mkdir build
30+
cd build
31+
cmake .. "-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake"
32+
```
33+
1. Run your MSVS and open the generated solution file, `build/3dv_tutorial.sln`.
34+
1. Build the example codes in the solution (Menu > `Build` > `Build Solution`)
35+
1. Run the examples using `F5` after specify your target as the startup project (Project Context Menu > `Set as Startup Project`)
36+
37+
38+
39+
## How to Run Example Codes in Linux
40+
### Prerequisites
41+
* Install [GCC](https://gcc.gnu.org/), [Git](https://git-scm.com/), [CMake](https://cmake.org/), [OpenCV](https://opencv.org/), and [Ceres Solver](http://ceres-solver.org/)
42+
43+
### Running Examples
44+
1. Clone the repository: `git clone https://github.com/mint-lab/3dv_tutorial.git`
45+
* You need to move your working directory where you want to copy the repository.
46+
* Or you can download [example codes and slides as a ZIP file](https://github.com/sunglok/3dv_tutorial/archive/master.zip) and unzip it where you want.
47+
1. Generate `Makefile` and project files
48+
```bash
49+
cd 3dv_tutorial
50+
mkdir build
51+
cd build
52+
cmake ..
53+
make install
54+
```
55+
1. Run the examples

HOWTO_RUN_PYTHON.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## How to Run Python Example Codes
2+
3+
### Prerequisites
4+
* Install [Python](https://www.python.org/) (or [Anaconda](https://www.anaconda.com/))
5+
* Install the following required packages: `pip install -r requirements.txt`
6+
```
7+
numpy
8+
matplotlib
9+
scipy
10+
opencv-python
11+
opencv-contrib-python
12+
```
13+
* Clone the repository: `git clone https://github.com/mint-lab/3dv_tutorial.git`
14+
* You need to move your working directory where you want to copy the repository.
15+
* Or you can download [example codes and slides as a ZIP file](https://github.com/sunglok/3dv_tutorial/archive/master.zip) and unzip it where you want.
16+
17+
18+
### Running Examples in Console
19+
1. Move to the directory where example codes exist: `cd examples`
20+
2. Run an example (e.g. `image_formation.py`): `python image_formation.py`
21+
* Or you can run an example on your favorite Python IDE or editor.

0 commit comments

Comments
 (0)