Page cover

Compile and Run

This section details how to compile and run this project on different platforms, including solutions to common problems.

Compile Preparation

Before compiling the project, make sure you have installed the following tools and dependencies:

Required Tools

  1. C++ Compiler: Supports C++11 or higher (recommended g++, clang++ or MSVC).

  2. CMake: Used to generate the build files for the project.

  3. OpenCV: OpenCV needs to be installed, recommended version is 3.x or 4.x.

Environment setup

Linux / macOS

  • Install dependencies using the package manager: ```bash

    For Ubuntu/Debian systems:

    sudo apt update sudo apt install build-essential cmake libopencv-dev

For macOS systems (using Homebrew):

brew install cmake opencv


#### Windows
- Install OpenCV using vcpkg and configure CMake:
```bash
git clone
cd vcpkg
./bootstrap-vcpkg.bat
./vcpkg install opencv
  • Add during CMake configuration:

    cmake .. -DCMAKE_TOOLCHAIN_FILE=/path-to-vcpkg/vcpkg.cmake

Compile the project

General steps

  1. Clone the project

    git clone
    cd Modelforge
  2. Create a build directory

    mkdir build && cd build
  3. Run CMake

  4. If OpenCV is installed globally:

    cmake ..
  5. If you install OpenCV using vcpkg or other methods, specify the toolchain file:

    cmake .. -DCMAKE_TOOLCHAIN_FILE=/path-to-vcpkg/vcpkg.cmake
  6. Compile the project

    make -j4
  7. On Windows, you can directly use Visual Studio to open the generated solution file and build it.


Run the project

Default run

After the compilation is complete, execute the generated executable file:

./Modelforge

Data path

The data read by the project is placed in the data/left and data/right folders by default, and the image file name format is 0000000000.png. Make sure the data directory structure is correct, otherwise the program may have a path error.


Common problems and solutions

1. OpenCV library cannot be found

  • Make sure OpenCV is correctly installed and found by CMake.

  • If the OpenCV installation path is not the default path, you can manually specify it through CMAKE_PREFIX_PATH:

    cmake .. -DCMAKE_PREFIX_PATH=/path-to-opencv

2. Dataset path error

  • Check the image path logic in main.cpp to ensure that it matches the local data structure.

  • Example:

    sprintf(chLeftImageName, "./data/left/%010d.png", cntFrame);
    sprintf(chRightImageName, "./data/right/%010d.png", cntFrame);

3. Image display abnormality

  • Make sure the image data format is correct (such as PNG format).

  • In the server environment, check whether the graphical interface support (such as X11) is enabled.

4. Error during compilation

  • Error example: fatal error: opencv2/opencv.hpp: No such file or directory

  • Reason: OpenCV header file not found.

  • Solution: Check the installation path of OpenCV and reconfigure CMake.

  • Error example: undefined reference to cv::xxx

  • Reason: OpenCV library is not linked correctly.

  • Solution: Make sure the library path of OpenCV is added to the linker.


Running results

After successful running, the program will output the current frame number and open the following window:

  1. vec: Display the direction vector of the columnar pixel.

  2. disp8: 8-bit disparity map.

  3. result: Display the superposition of the original image and the result.

  4. stixel: Display the columnar pixel segmentation result.

Key operation:

  • ESC: Exit the program.

  • Spacebar: Pause or continue playing.

  • [ key: Return to the previous frame.

Last updated