Skip to content

Commit

Permalink
DepthCloud: support custom resolutions properly
Browse files Browse the repository at this point in the history
  • Loading branch information
Viktor Kunovski authored and viktorku committed Jan 29, 2019
1 parent 80f6fde commit 27dbf62
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/depthcloud/DepthCloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,10 @@ ROS3D.DepthCloud = function(options) {
this.pointSize = options.pointSize || 3;
this.width = options.width || 1024;
this.height = options.height || 1024;
this.resolutionFactor = Math.max(this.width, this.height) / 1024;
this.whiteness = options.whiteness || 0;
this.varianceThreshold = options.varianceThreshold || 0.000016667;

var metaLoaded = false;

this.isMjpeg = this.streamType.toLowerCase() === 'mjpeg';

this.video = document.createElement(this.isMjpeg ? 'img' : 'video');
Expand All @@ -60,6 +59,7 @@ ROS3D.DepthCloud = function(options) {
'',
'uniform float focallength;',
'uniform float maxDepthPerTile;',
'uniform float resolutionFactor;',
'',
'varying vec2 vUvP;',
'varying vec2 colorP;',
Expand Down Expand Up @@ -163,8 +163,8 @@ ROS3D.DepthCloud = function(options) {
' float z = -depth;',
' ',
' pos = vec4(',
' ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength) * -1.0,',
' ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * (1000.0/focallength),',
' ( position.x / width - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength) * -1.0,',
' ( position.y / height - 0.5 ) * z * 0.5 * maxDepthPerTile * resolutionFactor * (1000.0/focallength),',
' (- z + zOffset / 1000.0) * maxDepthPerTile,',
' 1.0);',
' ',
Expand Down Expand Up @@ -285,6 +285,10 @@ ROS3D.DepthCloud.prototype.initStreamer = function() {
type : 'f',
value : this.maxDepthPerTile
},
'resolutionFactor': {
type : 'f',
value : this.resolutionFactor
},
},
vertexShader : this.vertex_shader,
fragmentShader : this.fragment_shader
Expand Down

0 comments on commit 27dbf62

Please sign in to comment.