Small C++ tool to denoise depth images and convert them into ASCII PLY point clouds.
- Supports 16-bit (mm) and 32-bit depth images.
- Simple denoising pipeline: median blur followed by bilateral filter.
- Optional per-pixel RGB color when matching RGB images are provided.
- CMake (>= 3.10)
- OpenCV (installed on your system)
mkdir -p build && cd build
# If OpenCV is installed via Homebrew, you may need to point CMake to the OpenCV config:
cmake -DOpenCV_DIR="$(brew --prefix opencv)/lib/cmake/opencv4" ..
make -j./build/depth2ply --input test_data/depths --rgb test_data/rgb --output out \
--fx 525 --fy 525 --cx 159.5 --cy 119.5 --scale 1000--input: Path to depth images (PNG/TIFF/EXR supported).--output: Output directory for PLY files.--fx/--fy/--cx/--cy: Camera intrinsics.--scale: Depth scale factor (e.g.1000if depth is stored in millimeters).--rgb: Optional path to RGB images. The tool will try to pair by filename, and will also attempt to replace a leadingdepth_prefix withrgb_if the direct match is missing.--median: Median filter kernel size (default3).--bd: Bilateral filter diameter (default5).--bsc: Bilateral filter sigmaColor (default10).--bsp: Bilateral filter sigmaSpace (default10).
- Point coordinates are computed with: x = (u - cx) * z / fx, y = (v - cy) * z / fy, where z is in meters.
- Output format: ASCII PLY (can be opened in MeshLab or CloudCompare).
- Use
tools/generate_test_images.pyto generate sample depth and RGB images intotest_data/depthsandtest_data/rgb.
- If the editor reports missing standard headers or OpenCV headers, ensure CMake has been run and
build/compile_commands.jsonis generated:cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DOpenCV_DIR="$(brew --prefix opencv)/lib/cmake/opencv4" build - Then in VSCode run:
Developer: Reload WindoworC/C++: Reset IntelliSense Database.
- "Could not find OpenCVConfig.cmake": on macOS install OpenCV via Homebrew and point CMake to
$(brew --prefix opencv)/lib/cmake/opencv4. bilateralFilterassertions: the code converts depth toCV_32Fbefore filtering; if you still see errors, please paste the terminal output.