uvgVPCCenc 1.1.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-present, 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 <vector>
40#include "utils/utils.hpp"
41#include "uvgvpcc/uvgvpcc.hpp"
42
43using namespace uvgvpcc_enc;
44
45
46enum class VoxClass : uint8_t {
47 NO_EDGE = 0x00, // one ppi-vaue in a voxel
48 INDIRECT_EDGE = 0x01, // adjcent voxels of M_DIRECT_EDGE, S_DIRECT_EDGE
49 M_DIRECT_EDGE = 0x10, // multiple points && more than two ppi-values in a voxel TODO(lf)verify if typo -> (more than one instead no ?)
50 S_DIRECT_EDGE = 0x11 // single-point in a voxel, considered as a direct edge-voxel
51};
52// TODO(lf): why to distinguish M and S direct edge ?
53// 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
54// iteration focus on all single direct edge voxel ?
55
58 // size_t nbPoint_; // TODO(lf): not used ?
60 size_t voxPPI_;
61 std::vector<size_t> voxScore_; // TODO(lf): should be an array ?
62 // Voxel score is a PPI histogram : how many points inside the voxel is associated with each projection planes //
63
64 explicit VoxelAttribute(const size_t projectionPlaneCount_);
65};
66
68 public:
69 PPISegmenter(const std::vector<Vector3<typeGeometryInput>>& pointsGeometry,
70 const std::vector<Vector3<double>>& pointsNormals);
71
72 void initialSegmentation(const std::shared_ptr<uvgvpcc_enc::Frame>& frame,std::vector<size_t>& pointsPPIs, const size_t& frameId);
73 void refineSegmentation(const std::shared_ptr<uvgvpcc_enc::Frame>& frame,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, robin_hood::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, robin_hood::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>& voxWeightList,
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:67
void initialSegmentation(const std::shared_ptr< uvgvpcc_enc::Frame > &frame, std::vector< size_t > &pointsPPIs, const size_t &frameId)
Definition ppiSegmenter.cpp:83
void refineSegmentation(const std::shared_ptr< uvgvpcc_enc::Frame > &frame, std::vector< size_t > &pointsPPIs, const size_t &frameId)
Definition ppiSegmenter.cpp:369
Definition robin_hood.h:921
Definition utils.hpp:56
Definition log.hpp:48
uint16_t typeGeometryInput
Definition utils.hpp:46
VoxClass
Definition ppiSegmenter.hpp:46
Definition ppiSegmenter.hpp:56
bool updateFlag_
Definition ppiSegmenter.hpp:57
std::vector< size_t > voxScore_
Definition ppiSegmenter.hpp:61
size_t voxPPI_
Definition ppiSegmenter.hpp:60
VoxClass voxClass_
Definition ppiSegmenter.hpp:59