Files
opencv-MIRROR/modules/ptcloud/src/io_splat.cpp
Savya Sanchi Sharma 303f83ef92 Merge pull request #29729 from SavyaSanchi-Sharma:vizsplat
Added Gaussian Splat Renderer Support - #29729

Adds 3D Gaussian Splatting support to `ptcloud`: a loader for trained scenes and a `viz3d` renderer that draws them alpha-blended and depth-sorted alongside existing opaque geometry.

### Result

<img width="1842" height="811" alt="splat" src="https://github.com/user-attachments/assets/abfa5c01-6dbb-4367-b426-a618e3748649" />

[.splat source](https://huggingface.co/cakewalk/splat-data/resolve/main/train.splat)

### Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

- [x] I agree to contribute to the project under Apache 2 License.
- [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
- [x] The PR is proposed to the proper branch
- [ ] There is a reference to the original bug report and related work
- [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable
      Patch to opencv_extra has the same branch name.
- [x] The feature is well documented and sample code can be built with the project CMake
2026-10-12 16:33:54 +03:00

50 lines
1.3 KiB
C++

// This file is part of OpenCV project.
// It is subject to the license terms in the LICENSE file found in the top-level directory
// of this distribution and at http://opencv.org/license.html.
// Copyright (C) 2026, BigVision LLC, all rights reserved.
// Third party copyrights are property of their respective owners.
#include "precomp.hpp"
#include "io_splat.hpp"
#include "splat.hpp"
#include <opencv2/core/utils/logger.hpp>
#include <fstream>
#include <vector>
namespace cv {
bool readSplatFile(const std::string& filename, Mat& splats)
{
splats.release();
std::ifstream file(filename, std::ios::binary | std::ios::ate);
if (!file)
{
CV_LOG_ERROR(NULL, "Failed to open '" << filename << "'");
return false;
}
const std::streamoff size = file.tellg();
if (size <= 0 || size % (int)splat::PACKED_STRIDE != 0)
{
CV_LOG_ERROR(NULL, "'" << filename << "' is not a .splat file: size " << size
<< " is not a positive multiple of " << (int)splat::PACKED_STRIDE);
return false;
}
file.seekg(0);
std::vector<uchar> buf((size_t)size);
if (!file.read((char*)buf.data(), size))
{
CV_LOG_ERROR(NULL, "Failed to read '" << filename << "'");
return false;
}
decodeGaussianSplatsPacked(buf, splats);
return true;
}
} /* namespace cv */