Skip to content

Commit 7f1857f

Browse files
committed
Invert depth map visualization
1 parent 51e236b commit 7f1857f

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

sapiens-node/assets/depth.png

-20 Bytes
Loading

sapiens-node/index.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ let maxAbsNormal = -Infinity;
6767
for (let i = 0; i < depth_map_data.length; ++i) {
6868
if (segmentation.data[i] === 0) {
6969
// Background
70-
depth_map_data[i] = -Infinity;
70+
depth_map_data[i] = Infinity;
7171

7272
for (let j = 0; j < 3; ++j) {
7373
normal_map_data[j * stride + i] = -Infinity;
@@ -88,7 +88,8 @@ for (let i = 0; i < depth_map_data.length; ++i) {
8888
// Normalize the depth map to [0, 1]
8989
const depth_tensor = depth_map
9090
.sub_(minDepth)
91-
.div_(maxDepth - minDepth)
91+
.div_(-(maxDepth - minDepth)) // Flip for visualization purposes
92+
.add_(1)
9293
.clamp_(0, 1)
9394
.mul_(255)
9495
.round_()

0 commit comments

Comments
 (0)