uvgVPCCenc 1.0.0
uvgVPCCenc is an open-source real-time V-PCC encoder library written in C++ from scratch.
Loading...
Searching...
No Matches
ppiSegmenter.hpp
Go to the documentation of this file.
1/*****************************************************************************
2 * This file is part of uvgVPCCenc V-PCC encoder.
3 *
4 * Copyright (c) 2024, Tampere University, ITU/ISO/IEC, project contributors
5 * All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without modification,
8 * are permitted provided that the following conditions are met:
9 *
10 * * Redistributions of source code must retain the above copyright notice, this
11 * list of conditions and the following disclaimer.
12 *
13 * * Redistributions in binary form must reproduce the above copyright notice, this
14 * list of conditions and the following disclaimer in the documentation and/or
15 * other materials provided with the distribution.
16 *
17 * * Neither the name of the Tampere University or ITU/ISO/IEC nor the names of its
18 * contributors may be used to endorse or promote products derived from
19 * this software without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
24 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26 * INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION HOWEVER CAUSED AND ON
28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 * INCLUDING NEGLIGENCE OR OTHERWISE ARISING IN ANY WAY OUT OF THE USE OF THIS
31 ****************************************************************************/
32
34
35#pragma once
36
37#include <cstdint>
38#include <unordered_map>
39#include <vector>
40#include "utils/utils.hpp"
41
42using namespace uvgvpcc_enc;
43
44
45enum class VoxClass : uint8_t {
46 NO_EDGE = 0x00, // one ppi-vaue in a voxel
47 INDIRECT_EDGE = 0x01, // adjcent voxels of M_DIRECT_EDGE, S_DIRECT_EDGE
48 M_DIRECT_EDGE = 0x10, // multiple points && more than two ppi-values in a voxel TODO(lf)verify if typo -> (more than one instead no ?)
49 S_DIRECT_EDGE = 0x11 // single-point in a voxel, considered as a direct edge-voxel
50};
51// TODO(lf): why to distinguish M and S direct edge ?
52// TODO(lf): Are S DIRECT EGDE always considered as direct edge ? Even if they share the same PPI as their neighbor ? Does this mean each
53// iteration focus on all single direct edge voxel ?
54
57 // size_t nbPoint_; // TODO(lf): not used ?
59 size_t voxPPI_;
60 std::vector<size_t> voxScore_; // TODO(lf): should be an array ?
61 // Voxel score is a PPI histogram : how many points inside the voxel is associated with each projection planes //
62
63 explicit VoxelAttribute(const size_t projectionPlaneCount_);
64};
65
67 public:
68 PPISegmenter(const std::vector<Vector3<typeGeometryInput>>& pointsGeometry,
69 const std::vector<Vector3<double>>& pointsNormals);
70
71
72 void initialSegmentation(std::vector<size_t>& pointsPPIs, const size_t& frameId);
73 void refineSegmentation(std::vector<size_t>& pointsPPIs, const size_t& frameId);
74
75 private:
76 static void voxelizationWithBitArray(const std::vector<Vector3<typeGeometryInput>>& inputPointsGeometry,
77 std::vector<bool>& occFlagArray, std::unordered_map<size_t, size_t>& voxelIdxMap,
78 std::vector<size_t>& filledVoxels, std::vector<std::vector<size_t>>& pointListInVoxels);
79
80 static void fillNeighborAndAdjacentLists(
81 std::vector<size_t>& filledVoxels, std::vector<bool>& occFlagArray, std::unordered_map<size_t, size_t>& voxelIdxMap,
82 std::vector<std::vector<size_t>>& ADJ_List, std::vector<std::vector<size_t>>& IDEV_List,
83 std::vector<std::vector<size_t>>& pointListInVoxels, std::vector<double>& voxWeightListOptimPaper,
84 std::vector<VoxelAttribute>& voxAttributeList, const std::vector<size_t>& pointsPPIs);
85
86 static void computeExtendedScore(std::vector<size_t>& voxExtendedScore, const std::vector<size_t>& ADJ_List,
87 const std::vector<VoxelAttribute>& voxAttributeList);
88
89 static void updateAdjacentVoxelsClass(std::vector<VoxelAttribute>& voxAttributeList,
90 const std::vector<size_t>& voxExtendedScore,
91 const std::vector<size_t>& IDEV_List);
92 static inline bool checkNEV(const VoxClass voxClass, const size_t voxPPI,
93 const std::vector<size_t>& voxExtendedScore);
94
95 inline void refinePointsPPIs(std::vector<size_t>& pointsPPIs, const std::vector<size_t>& pointsIndices,
96 const double weight, const std::vector<size_t>& voxExtendedScore) const;
97 static inline void updateVoxelAttribute(VoxelAttribute& voxAttribute, const std::vector<size_t>& voxPoints,
98 const std::vector<size_t>& pointsPPIs);
99
100 const std::vector<Vector3<double>>& pointsNormals_;
101 const std::vector<Vector3<typeGeometryInput>>& pointsGeometry_;
102 const typeGeometryInput geoMax_;
103 const typeGeometryInput geoRange_;
104};
Definition ppiSegmenter.hpp:66
void refineSegmentation(std::vector< size_t > &pointsPPIs, const size_t &frameId)
Definition ppiSegmenter.cpp:381
void initialSegmentation(std::vector< size_t > &pointsPPIs, const size_t &frameId)
Definition ppiSegmenter.cpp:85
Definition utils.hpp:59
Definition log.hpp:43
uint16_t typeGeometryInput
Definition utils.hpp:49
VoxClass
Definition ppiSegmenter.hpp:45
Definition ppiSegmenter.hpp:55
bool updateFlag_
Definition ppiSegmenter.hpp:56
std::vector< size_t > voxScore_
Definition ppiSegmenter.hpp:60
size_t voxPPI_
Definition ppiSegmenter.hpp:59
VoxClass voxClass_
Definition ppiSegmenter.hpp:58