Skip to content

Commit 4bde10b

Browse files
author
Louis Fréneau
committed
Improved patch segmentation
- Faster patch segmentation - Add a parameter for depth filtering - Remove the distance 1 check for CC seed - Remove the patch splitting feature - Remove the need of the frame 'patchPartition' - Update CI sha
1 parent 166475e commit 4bde10b

File tree

10 files changed

+452
-649
lines changed

10 files changed

+452
-649
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
3535
set(CMAKE_CXX_EXTENSIONS OFF)
3636

3737
if(${USE_CLANG_TIDY})
38-
set(CLANG_TIDY_DEFAULT "clang-tidy;-checks=*,-llvmlibc-*,-llvm-*,-modernize-*,-fuchsia-*,-altera-*,-hicpp-use-auto,-bugprone-easily-swappable-parameters,-performance-avoid-endl,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-readability-identifier-length,-readability-math-missing-parentheses,-readability-function-cognitive-complexity,-boost-use-ranges,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-avoid-non-const-global-variables,-abseil-string-find-str-contains,-cppcoreguidelines-avoid-do-while,-readability-use-std-min-max,-google-build-using-namespace,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-hicpp-braces-around-statements,-readability-braces-around-statements")
38+
set(CLANG_TIDY_DEFAULT "clang-tidy;-checks=*,-llvmlibc-*,-llvm-*,-modernize-*,-fuchsia-*,-altera-*,-hicpp-use-auto,-bugprone-easily-swappable-parameters,-performance-avoid-endl,-cppcoreguidelines-pro-bounds-constant-array-index,-cppcoreguidelines-avoid-magic-numbers,-readability-magic-numbers,-readability-identifier-length,-readability-math-missing-parentheses,-readability-function-cognitive-complexity,-boost-use-ranges,-misc-non-private-member-variables-in-classes,-cppcoreguidelines-avoid-non-const-global-variables,-abseil-string-find-str-contains,-cppcoreguidelines-avoid-do-while,-readability-use-std-min-max,-google-build-using-namespace,-cppcoreguidelines-pro-bounds-pointer-arithmetic,-hicpp-braces-around-statements,-readability-braces-around-statements,-google-readability-braces-around-statements")
3939
endif()
4040

4141
# Useful for debugging

src/lib/include/uvgvpcc/uvgvpcc.hpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ struct Patch {
6868

6969
bool projectionMode_; // 0: related to the min depth value; 1: related to the max value
7070

71-
size_t sizeD_; // size for depth (TODO(lf): is it the real patch thickness or the maximum possible thickness?)
71+
size_t sizeD_; // while posD_ is the minimum 'depth', sizeD_ store the maximum depth. TODO(lf): check if it is usefull
7272

7373
std::vector<uint8_t> patchOccupancyMap_; // patch occupancy map (boolean vector)
7474

@@ -114,7 +114,7 @@ struct Patch {
114114
projectionMode_ = projectionMode; // TODO(lf): projection mode optimization per patch
115115
}
116116

117-
void setPatchPpi(size_t patchPpi) {
117+
inline void setPatchPpiAndAxis(size_t patchPpi) {
118118
patchPpi_ = patchPpi;
119119
// now set the other variables according to the viewId
120120
switch (patchPpi_) {
@@ -183,7 +183,6 @@ struct Frame {
183183
std::vector<Vector3<uint8_t>> pointsAttribute;
184184

185185
std::vector<Patch> patchList;
186-
std::vector<size_t> patchPartition; // Associate a point index to the index of its patch
187186

188187
size_t mapHeight = 0; // TODO(lf): Will be a gof parameter ?
189188
size_t mapHeightDS = 0;

src/lib/patchGeneration/patchGeneration.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void PatchGeneration::generateFramePatches(std::shared_ptr<uvgvpcc_enc::Frame> f
126126
}
127127

128128
// Patch segmentation //
129-
PatchSegmentation::patchSegmentation(frame, pointsPPIs);
129+
PatchSegmentation::patchSegmentation(frame, pointsPPIs);
130130

131131
// Sort patches //
132132
// Sort patches from the biggest to the smallest // // TODO(lf): might be better to use area ?
@@ -135,7 +135,7 @@ void PatchGeneration::generateFramePatches(std::shared_ptr<uvgvpcc_enc::Frame> f
135135
return std::max(patchA.widthInPixel_, patchA.heightInPixel_) > std::max(patchB.widthInPixel_, patchB.heightInPixel_);
136136
});
137137

138-
139138
std::vector<Vector3<typeGeometryInput>>().swap(frame->pointsGeometry); // Release memory
139+
//TODO(lf): try using noexcept to improve performance
140140

141141
}

src/lib/patchGeneration/patchSegmentation.cpp

Lines changed: 426 additions & 579 deletions
Large diffs are not rendered by default.

src/lib/patchGeneration/patchSegmentation.hpp

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -34,38 +34,12 @@
3434

3535
#pragma once
3636

37-
#include "robin_hood.h"
3837
#include "uvgvpcc/uvgvpcc.hpp"
3938

4039
using namespace uvgvpcc_enc;
4140

4241

4342
class PatchSegmentation {
4443
public:
45-
PatchSegmentation();
46-
4744
static void patchSegmentation(const std::shared_ptr<uvgvpcc_enc::Frame>& frame, const std::vector<size_t>& pointsPPIs);
48-
49-
static void createConnectedComponents(std::vector<std::vector<size_t>>& connectedComponents, std::vector<bool>& flags,
50-
const std::vector<size_t>& rawPoints, const std::vector<size_t>& pointsPPIs,
51-
robin_hood::unordered_map<size_t, size_t>& nnPropagationMapFlagTrue,
52-
const std::vector<uvgvpcc_enc::Vector3<typeGeometryInput>>& pointsGeometry);
53-
static void patchSplitting(std::vector<size_t>& connectedComponent, uvgvpcc_enc::Patch& patch,
54-
const std::vector<uvgvpcc_enc::Vector3<typeGeometryInput>>& pointsGeometry);
55-
static void computePatchBoundingBox(uvgvpcc_enc::Patch& patch, const std::vector<size_t>& connectedComponent,
56-
const std::vector<uvgvpcc_enc::Vector3<typeGeometryInput>>& pointsGeometry);
57-
static void computePatchDepthL1(uvgvpcc_enc::Patch& patch, const std::vector<size_t>& connectedComponent,
58-
std::vector<size_t>& patchPartition,
59-
const std::vector<uvgvpcc_enc::Vector3<typeGeometryInput>>& pointsGeometry, const bool isProjectionMode0);
60-
static void computePatchDepthL2(uvgvpcc_enc::Patch& patch, const std::vector<size_t>& connectedComponent,
61-
const std::vector<uvgvpcc_enc::Vector3<typeGeometryInput>>& pointsGeometry, const bool isProjectionMode0);
62-
static void filterDepth(uvgvpcc_enc::Patch& patch, const bool isProjectionMode0);
63-
static void resampledPointcloud(robin_hood::unordered_set<size_t>& resamplePointSet, uvgvpcc_enc::Patch& patch); // TODO(lf)const patch ?
64-
65-
static void computeAdditionalPatchInfo(uvgvpcc_enc::Patch& patch);
66-
static void refillRawPoints(const robin_hood::unordered_set<size_t>& resamplePointSet, std::vector<size_t>& rawPoints,
67-
const std::vector<uvgvpcc_enc::Vector3<typeGeometryInput>>& pointsGeometry, const size_t& pointCount,
68-
std::vector<bool>& flags, robin_hood::unordered_map<size_t, size_t>& nnPropagationMapFlagTrue);
69-
70-
7145
};

src/lib/utils/parameters.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -193,8 +193,6 @@ void initializeParameterMap(Parameters& param) {
193193
// ___ Patch generation ___ // (patch segmentation)
194194
{"maxAllowedDist2RawPointsDetection", {UINT, "", &param.maxAllowedDist2RawPointsDetection}},
195195
{"minPointCountPerCC", {UINT, "", &param.minPointCountPerCC}},
196-
{"maxPatchSize", {UINT, "", &param.maxPatchSize}},
197-
{"maxNNCountPatchSegmentation", {UINT, "", &param.maxNNCountPatchSegmentation}},
198196
{"patchSegmentationMaxPropagationDistance", {UINT, "", &param.patchSegmentationMaxPropagationDistance}},
199197
{"enablePatchSplitting", {BOOL, "", &param.enablePatchSplitting}},
200198
{"minLevel", {UINT, "", &param.minLevel}},

src/lib/utils/parameters.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ struct Parameters {
100100
// ___ Patch generation ___ // (patch segmentation)
101101
size_t maxAllowedDist2RawPointsDetection = 5; // TODO(lf): add verification to avoid segfault because index out of bound
102102
size_t minPointCountPerCC;
103-
size_t maxPatchSize; // TODO(lf): debug when maxPatchSize = 200
104-
size_t maxNNCountPatchSegmentation = 5; // TODO(lf)check max all NN
105103
size_t patchSegmentationMaxPropagationDistance = 3;
106104
// lf : for reworked function only. If the value is 4, the euclidian distance is 16. // TODO(lf): the default value should be 2 I
107105
// guess // Nop, it should be 1 // TODO(lf): make sure to use <= instead of < in the for loop so to avoid this confusion.
@@ -114,6 +112,7 @@ struct Parameters {
114112
size_t quantizerSizeX = static_cast<size_t>(1) << log2QuantizerSizeX; // TODO(lf): investigate
115113
size_t quantizerSizeY = static_cast<size_t>(1) << log2QuantizerSizeY;
116114
size_t surfaceThickness = 4;
115+
size_t distanceFiltering = 32; // tmp_a in TMC2 // TODO(lf) check impact on quality
117116

118117

119118
// ___ Patch packing ___ //

src/lib/utils/preset.cpp

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,7 @@ Preset preset_vox9_fast = {
6767

6868
// ___ Patch generation ___ // (patch segmentation)
6969
{"minPointCountPerCC","16"}, // TODO(lf)-PRESET: subjective quality and performance only
70-
{"maxPatchSize","608"}, // TODO(lf)-PRESET: subjective quality and performance only
71-
70+
7271
// ___ Patch packing ___ //
7372
{"mapWidth","608"},
7473
{"minimumMapHeight","608"},
@@ -104,8 +103,7 @@ Preset preset_vox9_slow = {
104103

105104
// ___ Patch generation ___ // (patch segmentation)
106105
{"minPointCountPerCC","5"}, // TODO(lf)-PRESET: fixed
107-
{"maxPatchSize","608"},
108-
106+
109107
// ___ Patch packing ___ //
110108
{"mapWidth","608"},
111109
{"minimumMapHeight","608"},
@@ -142,8 +140,7 @@ Preset preset_vox10_fast = {
142140

143141
// ___ Patch generation ___ // (patch segmentation)
144142
{"minPointCountPerCC","16"},
145-
{"maxPatchSize","1024"},
146-
143+
147144
// ___ Patch packing ___ //
148145
{"mapWidth","1024"},
149146
{"minimumMapHeight","1024"},
@@ -179,8 +176,7 @@ Preset preset_vox10_slow = {
179176

180177
// ___ Patch generation ___ // (patch segmentation)
181178
{"minPointCountPerCC","5"},
182-
{"maxPatchSize","1024"},
183-
179+
184180
// ___ Patch packing ___ //
185181
{"mapWidth","1024"},
186182
{"minimumMapHeight","1024"},
@@ -216,8 +212,7 @@ Preset preset_vox11_fast = {
216212

217213
// ___ Patch generation ___ // (patch segmentation)
218214
{"minPointCountPerCC","16"},
219-
{"maxPatchSize","2048"},
220-
215+
221216
// ___ Patch packing ___ //
222217
{"mapWidth","2048"},
223218
{"minimumMapHeight","2048"},
@@ -253,8 +248,7 @@ Preset preset_vox11_slow = {
253248

254249
// ___ Patch generation ___ // (patch segmentation)
255250
{"minPointCountPerCC","16"},
256-
{"maxPatchSize","2048"},
257-
251+
258252
// ___ Patch packing ___ //
259253
{"mapWidth","2048"},
260254
{"minimumMapHeight","2048"},
@@ -351,8 +345,7 @@ void applyPreset(Parameters& param) {
351345
// Adjust the size of the max size of the patch and maps dimension
352346
const std::string scaledSize = std::to_string((1 + param.geoBitDepthInput - 11) * 2048);
353347

354-
setParameterValue("maxPatchSize", scaledSize, true);
355-
setParameterValue("mapWidth", scaledSize, true);
348+
setParameterValue("mapWidth", scaledSize, true);
356349
setParameterValue("minimumMapHeight", scaledSize, true);
357350

358351
Logger::log<LogLevel::WARNING>("LIBRARY INTERFACE",

src/lib/uvgvpcc.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -170,12 +170,6 @@ void verifyConfig() {
170170
throw std::runtime_error("The occupancy maps should not be encoded in lossy mode. (At least, this is a very dangerous things to try.)");
171171
}
172172

173-
if (p_->maxPatchSize > p_->mapWidth && p_->maxPatchSize > p_->minimumMapHeight) {
174-
throw std::runtime_error("The maxPatchSize (" + std::to_string(p_->maxPatchSize) + ") is higher than the mapWidth (" +
175-
std::to_string(p_->mapWidth) + ") and higher than the minimum image height (" +
176-
std::to_string(p_->minimumMapHeight) + ")");
177-
}
178-
179173
if (roundUp(p_->minimumMapHeight, p_->occupancyMapDSResolution) != p_->minimumMapHeight ||
180174
roundUp(p_->minimumMapHeight / p_->occupancyMapDSResolution, 8) != p_->minimumMapHeight / p_->occupancyMapDSResolution) {
181175
throw std::runtime_error(
@@ -452,8 +446,7 @@ void Frame::printInfo() const {
452446
"Frame " + std::to_string(frameId) + " :\n" + "\tPath: " + pointCloudPath + "\n" + "\tFrame Number: " +
453447
std::to_string(frameNumber) + "\n" + "\tpointsGeometry size: " + std::to_string(pointsGeometry.size()) + "\n" +
454448
"\tpointsAttribute size: " + std::to_string(pointsAttribute.size()) + "\n" +
455-
"\tpatchList size: " + std::to_string(patchList.size()) + "\n" + "\tpatchPartition size: " +
456-
std::to_string(patchPartition.size()) + "\n" + "\toccupancyMapDS size: " + std::to_string(occupancyMapDS.size()) + "\n" +
449+
"\tpatchList size: " + std::to_string(patchList.size()) + "\n" + "\toccupancyMapDS size: " + std::to_string(occupancyMapDS.size()) + "\n" +
457450
"\tgeometryMapL1 size: " + std::to_string(geometryMapL1.size()) + "\n" + "\tgeometryMapL2 size: " +
458451
std::to_string(geometryMapL2.size()) + "\n" + "\tattributeMapL1 size: " + std::to_string(attributeMapL1.size()) + "\n" +
459452
"\tattributeMapL2 size: " + std::to_string(attributeMapL2.size()) + "\n");

tests/ref_md5.csv

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
test_name,md5_bitstream,md5_pc;
2-
ReadyForWinter_vox9_fast_RA_16-22-2,333aeb5eb21035bcc2abeeff5c52a573,;
3-
ReadyForWinter_vox9_slow_RA_32-42-4,32353a763ddaebe2e6ff1ce52739d830,;
4-
ReadyForWinter_vox9_fast_AI_32-42-4,b4bab650cd464b2326d0432d7f2eb042,;
5-
ReadyForWinter_vox9_slow_AI_16-22-2,73b01e11299f8b462b206afd7aaf7d34,;
6-
FlowerWave_vox10_fast_RA_32-42-4,29eac2d4198dc7324ad9af4933909f4a,;
7-
Gymnast_vox10_slow_RA_16-22-2,d18d16bb9708fa6dad78995604f4c819,;
8-
Gymnast_vox10_fast_AI_32-42-4,7c488e8c9a8912ecceb0bab74c4040a6,;
9-
FlowerWave_vox10_fast_AI_16-22-2,9b8dfcc76e9d4f0d96d941582b2e0428,;
10-
CasualSquat_vox11_fast_RA_16-22-2,7d5ab945791e466e329cc93658235f87,;
11-
BlueBackpack_vox11_slow_RA_16-22-2,d972384afdc565760457e724e6aa6076,;
12-
BlueBackpack_vox11_slow_AI_32-42-4,2615e98fd2dc5f3e96633f306522e9f6,;
13-
CasualSquat_vox11_slow_AI_32-42-4,0f8b0f48e9a9405d897d89dd9b87f194,;
2+
ReadyForWinter_vox9_fast_RA_16-22-2,e2733465733127770bffc9dfc5a50a02,;
3+
ReadyForWinter_vox9_slow_RA_32-42-4,294ea4a9af88a688a256fe6ec2986da0,;
4+
ReadyForWinter_vox9_fast_AI_32-42-4,0a509b057003bbbf8237e7c991b59627,;
5+
ReadyForWinter_vox9_slow_AI_16-22-2,7b86fa43a005889ab801faf2c585ee98,;
6+
FlowerWave_vox10_fast_RA_32-42-4,869239ace9530e9fcf1027db3a83a79f,;
7+
Gymnast_vox10_slow_RA_16-22-2,c3f0ecd6faa22a172fa791d4e11357eb,;
8+
Gymnast_vox10_fast_AI_32-42-4,bfb4952094daaa2d824dce08dd020d8f,;
9+
FlowerWave_vox10_fast_AI_16-22-2,d58ee550c201fd72e114fb576fb56f08,;
10+
CasualSquat_vox11_fast_RA_16-22-2,cead9feeccca59da9d1c3ff47933197e,;
11+
BlueBackpack_vox11_slow_RA_16-22-2,bc8a39a74df2079253b1e0531486d9b7,;
12+
BlueBackpack_vox11_slow_AI_32-42-4,7a5c727fd008f76ed71c96e2485c16a9,;
13+
CasualSquat_vox11_slow_AI_32-42-4,d5aa84d58efbc8273af2f9198b7b8fd0,;

0 commit comments

Comments
 (0)