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
C++ Compiler: Supports C++11 or higher (recommended
g++
,clang++
or MSVC).CMake: Used to generate the build files for the project.
OpenCV: OpenCV needs to be installed, recommended version is 3.x or 4.x.
Environment setup
Linux / macOS
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
Clone the project
git clone cd Modelforge
Create a build directory
mkdir build && cd build
Run CMake
If OpenCV is installed globally:
cmake ..
If you install OpenCV using vcpkg or other methods, specify the toolchain file:
cmake .. -DCMAKE_TOOLCHAIN_FILE=/path-to-vcpkg/vcpkg.cmake
Compile the project
make -j4
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:
vec
: Display the direction vector of the columnar pixel.disp8
: 8-bit disparity map.result
: Display the superposition of the original image and the result.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