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/constants.hpp"
41#include "uvgutils/utils.hpp"
42#include "uvgvpcc/uvgvpcc.hpp"
43
44using namespace uvgvpcc_enc;
45
46
47enum class VoxClass : uint8_t {
48 NO_EDGE = 0x00, // one ppi-vaue in a voxel
49 INDIRECT_EDGE = 0x01, // adjcent voxels of M_DIRECT_EDGE, S_DIRECT_EDGE
50 M_DIRECT_EDGE = 0x10, // multiple points && more than two ppi-values in a voxel TODO(lf)verify if typo -> (more than one instead no ?)
51 S_DIRECT_EDGE = 0x11 // single-point in a voxel, considered as a direct edge-voxel
52};
53// TODO(lf): why to distinguish M and S direct edge ?
54// 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
55// iteration focus on all single direct edge voxel ?
56
59 // size_t nbPoint_; // TODO(lf): not used ?
61 size_t voxPPI_;
62 std::vector<size_t> voxScore_; // TODO(lf): should be an array ?
63 // Voxel score is a PPI histogram : how many points inside the voxel is associated with each projection planes //
64
65 explicit VoxelAttribute(const size_t projectionPlaneCount_);
66};
67
69 public:
70 PPISegmenter(const std::vector<uvgutils::VectorN<typeGeometryInput, 3>>& pointsGeometry,
71 const std::vector<uvgutils::VectorN<double, 3>>& pointsNormals);
72
73 void initialSegmentation(const std::shared_ptr<uvgvpcc_enc::Frame>& frame,std::vector<size_t>& pointsPPIs, const size_t& frameId);
74 void refineSegmentation(const std::shared_ptr<uvgvpcc_enc::Frame>& frame,std::vector<size_t>& pointsPPIs, const size_t& frameId);
75
76 private:
77 static void voxelizationWithBitArray(const std::vector<uvgutils::VectorN<typeGeometryInput, 3>>& inputPointsGeometry,
78 std::vector<bool>& occFlagArray, robin_hood::unordered_map<size_t, size_t>& voxelIdxMap,
79 std::vector<size_t>& filledVoxels, std::vector<std::vector<size_t>>& pointListInVoxels);
80
81 static void fillNeighborAndAdjacentLists(
82 std::vector<size_t>& filledVoxels, std::vector<bool>& occFlagArray, robin_hood::unordered_map<size_t, size_t>& voxelIdxMap,
83 std::vector<std::vector<size_t>>& ADJ_List, std::vector<std::vector<size_t>>& IDEV_List,
84 std::vector<std::vector<size_t>>& pointListInVoxels, std::vector<double>& voxWeightList,
85 std::vector<VoxelAttribute>& voxAttributeList, const std::vector<size_t>& pointsPPIs);
86
87 static void computeExtendedScore(std::vector<size_t>& voxExtendedScore, const std::vector<size_t>& ADJ_List,
88 const std::vector<VoxelAttribute>& voxAttributeList);
89
90 static void updateAdjacentVoxelsClass(std::vector<VoxelAttribute>& voxAttributeList,
91 const std::vector<size_t>& voxExtendedScore,
92 const std::vector<size_t>& IDEV_List);
93 static inline bool checkNEV(const VoxClass voxClass, const size_t voxPPI,
94 const std::vector<size_t>& voxExtendedScore);
95
96 inline void refinePointsPPIs(std::vector<size_t>& pointsPPIs, const std::vector<size_t>& pointsIndices,
97 const double weight, const std::vector<size_t>& voxExtendedScore) const;
98 static inline void updateVoxelAttribute(VoxelAttribute& voxAttribute, const std::vector<size_t>& voxPoints,
99 const std::vector<size_t>& pointsPPIs);
100
101 const std::vector<uvgutils::VectorN<double, 3>>& pointsNormals_;
102 const std::vector<uvgutils::VectorN<typeGeometryInput, 3>>& pointsGeometry_;
103 const typeGeometryInput geoMax_;
104 const typeGeometryInput geoRange_;
105};
Definition ppiSegmenter.hpp:68
void initialSegmentation(const std::shared_ptr< uvgvpcc_enc::Frame > &frame, std::vector< size_t > &pointsPPIs, const size_t &frameId)
Definition ppiSegmenter.cpp:85
void refineSegmentation(const std::shared_ptr< uvgvpcc_enc::Frame > &frame, std::vector< size_t > &pointsPPIs, const size_t &frameId)
Definition ppiSegmenter.cpp:370
Definition robin_hood.h:921
Definition utils.hpp:49
Definition uvgvpcc.hpp:55
uint16_t typeGeometryInput
Definition constants.hpp:47
VoxClass
Definition ppiSegmenter.hpp:47
Definition ppiSegmenter.hpp:57
bool updateFlag_
Definition ppiSegmenter.hpp:58
std::vector< size_t > voxScore_
Definition ppiSegmenter.hpp:62
size_t voxPPI_
Definition ppiSegmenter.hpp:61
VoxClass voxClass_
Definition ppiSegmenter.hpp:60