Skip to content

Commit 1e9ae8f

Browse files
Doc-Okmelanopsis
authored andcommitted
Release version 2.2 revision 2
Using tarball (with SHA1): 2278ccc3d45180162e44a8fbe6a2e02de7826b33 *SARndbox-2.2.tar.gz
1 parent bffc539 commit 1e9ae8f

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+5932
-1978
lines changed

BathymetrySaverTool.cpp

+629
Large diffs are not rendered by default.

BathymetrySaverTool.h

+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
/***********************************************************************
2+
BathymetrySaverTool - Tool to save the current bathymetry grid of an
3+
augmented reality sandbox to a file or network socket.
4+
Copyright (c) 2016 Oliver Kreylos
5+
6+
This file is part of the Augmented Reality Sandbox (SARndbox).
7+
8+
The Augmented Reality Sandbox is free software; you can redistribute it
9+
and/or modify it under the terms of the GNU General Public License as
10+
published by the Free Software Foundation; either version 2 of the
11+
License, or (at your option) any later version.
12+
13+
The Augmented Reality Sandbox is distributed in the hope that it will be
14+
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
15+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16+
General Public License for more details.
17+
18+
You should have received a copy of the GNU General Public License along
19+
with the Augmented Reality Sandbox; if not, write to the Free Software
20+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21+
***********************************************************************/
22+
23+
#ifndef BATHYMETRYSAVERTOOL_INCLUDED
24+
#define BATHYMETRYSAVERTOOL_INCLUDED
25+
26+
#include <string>
27+
#include <GL/gl.h>
28+
#include <Vrui/Tool.h>
29+
#include <Vrui/Application.h>
30+
31+
#include "Types.h"
32+
33+
/* Forward declarations: */
34+
class WaterTable2;
35+
class Sandbox;
36+
class BathymetrySaverTool;
37+
38+
class BathymetrySaverToolFactory:public Vrui::ToolFactory
39+
{
40+
friend class BathymetrySaverTool;
41+
42+
/* Embedded classes: */
43+
private:
44+
struct Configuration // Structure containing tool settings
45+
{
46+
/* Elements: */
47+
public:
48+
std::string saveFileName; // Name of file to which to save the bathymetry grid
49+
bool postUpdate; // Flag whether to post an update message to a web server after saving the bathymetry grid
50+
std::string postUpdateHostName; // Name of web server to which to send update messages
51+
int postUpdatePort; // TCP port number of web server to which to send update messages
52+
std::string postUpdatePage; // Name of page on web server to which update messages are posted
53+
std::string postUpdateMessage; // The message to send to the web server
54+
55+
/* Constructors and destructors: */
56+
Configuration(void); // Creates default configuration
57+
58+
/* Methods: */
59+
void read(const Misc::ConfigurationFileSection& cfs); // Overrides configuration from configuration file section
60+
void write(Misc::ConfigurationFileSection& cfs) const; // Writes configuration to configuration file section
61+
};
62+
63+
/* Elements: */
64+
private:
65+
Configuration configuration; // Default configuration for all tools
66+
WaterTable2* waterTable; // Pointer to water table object from which to request bathymetry grids
67+
GLsizei gridSize[2]; // Width and height of the water table's bathymetry grid
68+
GLfloat cellSize[2]; // Width and height of each water table cell
69+
70+
/* Constructors and destructors: */
71+
public:
72+
BathymetrySaverToolFactory(WaterTable2* sWaterTable,Vrui::ToolManager& toolManager);
73+
virtual ~BathymetrySaverToolFactory(void);
74+
75+
/* Methods from Vrui::ToolFactory: */
76+
virtual const char* getName(void) const;
77+
virtual const char* getButtonFunction(int buttonSlotIndex) const;
78+
virtual Vrui::Tool* createTool(const Vrui::ToolInputAssignment& inputAssignment) const;
79+
virtual void destroyTool(Vrui::Tool* tool) const;
80+
};
81+
82+
class BathymetrySaverTool:public Vrui::Tool,public Vrui::Application::Tool<Sandbox>
83+
{
84+
friend class BathymetrySaverToolFactory;
85+
86+
/* Elements: */
87+
private:
88+
static BathymetrySaverToolFactory* factory; // Pointer to the factory object for this class
89+
BathymetrySaverToolFactory::Configuration configuration; // Configuration of this tool
90+
GLfloat* bathymetryBuffer; // Bathymetry grid buffer
91+
bool requestPending; // Flag if this tool has a pending request to retrieve a bathymetry grid
92+
93+
/* Private methods: */
94+
void writeDEMFile(void) const; // Writes the bathymetry grid to a file in USGS DEM format
95+
void postUpdate(void) const; // Sends an update message to a web server
96+
97+
/* Constructors and destructors: */
98+
public:
99+
static BathymetrySaverToolFactory* initClass(WaterTable2* sWaterTable,Vrui::ToolManager& toolManager);
100+
BathymetrySaverTool(const Vrui::ToolFactory* factory,const Vrui::ToolInputAssignment& inputAssignment);
101+
virtual ~BathymetrySaverTool(void);
102+
103+
/* Methods from class Vrui::Tool: */
104+
virtual void configure(const Misc::ConfigurationFileSection& configFileSection);
105+
virtual void storeState(Misc::ConfigurationFileSection& configFileSection) const;
106+
virtual const Vrui::ToolFactory* getFactory(void) const;
107+
virtual void buttonCallback(int buttonSlotIndex,Vrui::InputDevice::ButtonCallbackData* cbData);
108+
virtual void frame(void);
109+
};
110+
111+
#endif

CalibrateProjector.cpp

+23-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/***********************************************************************
22
CalibrateProjector - Utility to calculate the calibration transformation
33
of a projector into a Kinect-captured 3D space.
4-
Copyright (c) 2012-2013 Oliver Kreylos
4+
Copyright (c) 2012-2015 Oliver Kreylos
55
66
This file is part of the Augmented Reality Sandbox (SARndbox).
77
@@ -44,6 +44,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4444
#include <Vrui/ToolManager.h>
4545
#include <Vrui/OpenFile.h>
4646

47+
#include "Config.h"
48+
4749
/********************************************************
4850
Static elements of class CalibrateProjector::CaptureTool:
4951
********************************************************/
@@ -150,7 +152,7 @@ void CalibrateProjector::depthStreamingCallback(const Kinect::FrameBuffer& frame
150152
Vrui::requestUpdate();
151153
}
152154

153-
void CalibrateProjector::backgroundCaptureCompleteCallback(Kinect::Camera&)
155+
void CalibrateProjector::backgroundCaptureCompleteCallback(Kinect::DirectFrameSource&)
154156
{
155157
/* Reset the background capture flag: */
156158
std::cout<<" done"<<std::endl;
@@ -182,9 +184,12 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
182184

183185
/* Process command line parameters: */
184186
bool printHelp=false;
185-
std::string sandboxLayoutFileName=CONFIGDIR;
187+
std::string sandboxLayoutFileName=CONFIG_CONFIGDIR;
186188
sandboxLayoutFileName.push_back('/');
187-
sandboxLayoutFileName.append("BoxLayout.txt");
189+
sandboxLayoutFileName.append(CONFIG_DEFAULTBOXLAYOUTFILENAME);
190+
projectionMatrixFileName=CONFIG_CONFIGDIR;
191+
projectionMatrixFileName.push_back('/');
192+
projectionMatrixFileName.append(CONFIG_DEFAULTPROJECTIONMATRIXFILENAME);
188193
int cameraIndex=0;
189194
imageSize[0]=1024;
190195
imageSize[1]=768;
@@ -233,6 +238,11 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
233238
++i;
234239
tiePointFileName=argv[i];
235240
}
241+
else if(strcasecmp(argv[i]+1,"pmf")==0)
242+
{
243+
++i;
244+
projectionMatrixFileName=argv[i];
245+
}
236246
}
237247
}
238248

@@ -244,7 +254,7 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
244254
std::cout<<" Prints this help message"<<std::endl;
245255
std::cout<<" -slf <sandbox layout file name>"<<std::endl;
246256
std::cout<<" Loads the sandbox layout file of the given name"<<std::endl;
247-
std::cout<<" Default: "<<CONFIGDIR<<"/BoxLayout.txt"<<std::endl;
257+
std::cout<<" Default: "<<CONFIG_CONFIGDIR<<'/'<<CONFIG_DEFAULTBOXLAYOUTFILENAME<<std::endl;
248258
std::cout<<" -c <camera index>"<<std::endl;
249259
std::cout<<" Selects the local Kinect camera of the given index (0: first camera"<<std::endl;
250260
std::cout<<" on USB bus)"<<std::endl;
@@ -262,6 +272,9 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
262272
std::cout<<" Default: 1"<<std::endl;
263273
std::cout<<" -tpf <tie point file name>"<<std::endl;
264274
std::cout<<" Reads initial calibration tie points from a CSV file"<<std::endl;
275+
std::cout<<" -pmf <projection matrix file name>"<<std::endl;
276+
std::cout<<" Saves the calibration matrix to the file of the given name"<<std::endl;
277+
std::cout<<" Default: "<<CONFIG_CONFIGDIR<<'/'<<CONFIG_DEFAULTPROJECTIONMATRIXFILENAME<<std::endl;
265278
}
266279

267280
/* Read the sandbox layout file: */
@@ -295,18 +308,15 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
295308
tiePoints.push_back(tp);
296309
}
297310

298-
if(tiePoints.size()>=numTiePoints[0]*numTiePoints[1])
311+
if(tiePoints.size()>=size_t(numTiePoints[0]*numTiePoints[1]))
299312
{
300313
/* Calculate an initial calibration: */
301314
calcCalibration();
302315
}
303316
}
304317

305-
/* Enable background USB event handling: */
306-
usbContext.startEventHandling();
307-
308318
/* Open the Kinect camera device: */
309-
camera=new Kinect::Camera(usbContext,cameraIndex);
319+
camera=new Kinect::Camera(cameraIndex);
310320
camera->setCompressDepthFrames(true);
311321
camera->setSmoothDepthFrames(false);
312322
camera->setBackgroundRemovalFuzz(1);
@@ -360,7 +370,7 @@ void CalibrateProjector::frame(void)
360370
if(rawFrames.lockNewValue())
361371
{
362372
/* Extract all foreground blobs from the raw depth frame: */
363-
const DepthPixel* framePixels=static_cast<const DepthPixel*>(rawFrames.getLockedValue().getBuffer());
373+
const DepthPixel* framePixels=rawFrames.getLockedValue().getData<DepthPixel>();
364374
BlobForegroundSelector bfs;
365375
BlobMergeChecker bmc(blobMergeDepth);
366376
DepthCentroidBlob::Creator blobCreator;
@@ -481,7 +491,7 @@ void CalibrateProjector::frame(void)
481491
capturingTiePoint=false;
482492

483493
/* Check if the calibration is complete: */
484-
if(tiePoints.size()>=numTiePoints[0]*numTiePoints[1])
494+
if(tiePoints.size()>=size_t(numTiePoints[0]*numTiePoints[1]))
485495
{
486496
/* Calculate the calibration transformation: */
487497
calcCalibration();
@@ -829,10 +839,7 @@ void CalibrateProjector::calcCalibration(void)
829839
projection=invViewport*projection;
830840

831841
/* Write the projection matrix to a file: */
832-
std::string projFileName=CONFIGDIR;
833-
projFileName.push_back('/');
834-
projFileName.append("ProjectorMatrix.dat");
835-
IO::FilePtr projFile=Vrui::openFile(projFileName.c_str(),IO::File::WriteOnly);
842+
IO::FilePtr projFile=Vrui::openFile(projectionMatrixFileName.c_str(),IO::File::WriteOnly);
836843
projFile->setEndianness(Misc::LittleEndian);
837844
for(int i=0;i<4;++i)
838845
for(int j=0;j<4;++j)

CalibrateProjector.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/***********************************************************************
22
CalibrateProjector - Utility to calculate the calibration transformation
33
of a projector into a Kinect-captured 3D space.
4-
Copyright (c) 2012-2013 Oliver Kreylos
4+
Copyright (c) 2012-2015 Oliver Kreylos
55
66
This file is part of the Augmented Reality Sandbox (SARndbox).
77
@@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
2727
#include <Threads/Mutex.h>
2828
#include <Threads/Cond.h>
2929
#include <Threads/TripleBuffer.h>
30-
#include <USB/Context.h>
3130
#include <Math/Matrix.h>
3231
#include <Geometry/Point.h>
3332
#include <Geometry/AffineCombiner.h>
@@ -176,7 +175,6 @@ class CalibrateProjector:public Vrui::Application,public GLObject
176175
unsigned int numTiePointFrames; // Number of frames to capture per tie point
177176
unsigned int numBackgroundFrames; // Number of frames to capture for background removal
178177
int blobMergeDepth; // Maximum depth difference between neighboring pixels in the same blob
179-
USB::Context usbContext; // USB device context
180178
Kinect::Camera* camera; // Pointer to Kinect camera defining the object space
181179
unsigned int frameSize[2]; // Size of the Kinect camera's depth frames in pixels
182180
PixelDepthCorrection* pixelDepthCorrection; // Buffer of per-pixel depth correction coefficients
@@ -199,9 +197,11 @@ class CalibrateProjector:public Vrui::Application,public GLObject
199197
bool haveProjection; // Flag if a projection matrix has been computed
200198
Math::Matrix projection; // The current projection matrix
201199

200+
std::string projectionMatrixFileName; // Name of the file to which the projection matrix is saved
201+
202202
/* Private methods: */
203203
void depthStreamingCallback(const Kinect::FrameBuffer& frameBuffer); // Callback receiving depth frames from the Kinect camera
204-
void backgroundCaptureCompleteCallback(Kinect::Camera& camera); // Callback when the Kinect camera is done capturing a background image
204+
void backgroundCaptureCompleteCallback(Kinect::DirectFrameSource& camera); // Callback when the Kinect camera is done capturing a background image
205205

206206
/* Constructors and destructors: */
207207
public:

Config.h

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/***********************************************************************
2+
Config - Configuration header file for the Augmented Reality Sandbox.
3+
Copyright (c) 2014-2016 Oliver Kreylos
4+
5+
This file is part of the Augmented Reality Sandbox (SARndbox).
6+
7+
The Augmented Reality Sandbox is free software; you can redistribute it
8+
and/or modify it under the terms of the GNU General Public License as
9+
published by the Free Software Foundation; either version 2 of the
10+
License, or (at your option) any later version.
11+
12+
The Augmented Reality Sandbox is distributed in the hope that it will be
13+
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15+
General Public License for more details.
16+
17+
You should have received a copy of the GNU General Public License along
18+
with the Augmented Reality Sandbox; if not, write to the Free Software
19+
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20+
***********************************************************************/
21+
22+
#ifndef CONFIG_INCLUDED
23+
#define CONFIG_INCLUDED
24+
25+
#define CONFIG_CONFIGDIR "/usr/local/etc/SARndbox-3.0"
26+
#define CONFIG_SHADERDIR "/usr/local/share/SARndbox-3.0/Shaders"
27+
28+
#define CONFIG_DEFAULTCONFIGFILENAME "SARndbox.cfg"
29+
#define CONFIG_DEFAULTBOXLAYOUTFILENAME "BoxLayout.txt"
30+
#define CONFIG_DEFAULTPROJECTIONMATRIXFILENAME "ProjectorMatrix.dat"
31+
#define CONFIG_DEFAULTHEIGHTCOLORMAPFILENAME "HeightColorMap.cpt"
32+
33+
#endif

0 commit comments

Comments
 (0)