Skip to content

Commit

Permalink
Release version 2.2 revision 2
Browse files Browse the repository at this point in the history
Using tarball (with SHA1):
2278ccc3d45180162e44a8fbe6a2e02de7826b33 *SARndbox-2.2.tar.gz
  • Loading branch information
Doc-Ok authored and melanopsis committed Jun 17, 2019
1 parent bffc539 commit 1e9ae8f
Show file tree
Hide file tree
Showing 66 changed files with 5,932 additions and 1,978 deletions.
629 changes: 629 additions & 0 deletions BathymetrySaverTool.cpp

Large diffs are not rendered by default.

111 changes: 111 additions & 0 deletions BathymetrySaverTool.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
/***********************************************************************
BathymetrySaverTool - Tool to save the current bathymetry grid of an
augmented reality sandbox to a file or network socket.
Copyright (c) 2016 Oliver Kreylos
This file is part of the Augmented Reality Sandbox (SARndbox).
The Augmented Reality Sandbox is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Augmented Reality Sandbox is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with the Augmented Reality Sandbox; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***********************************************************************/

#ifndef BATHYMETRYSAVERTOOL_INCLUDED
#define BATHYMETRYSAVERTOOL_INCLUDED

#include <string>
#include <GL/gl.h>
#include <Vrui/Tool.h>
#include <Vrui/Application.h>

#include "Types.h"

/* Forward declarations: */
class WaterTable2;
class Sandbox;
class BathymetrySaverTool;

class BathymetrySaverToolFactory:public Vrui::ToolFactory
{
friend class BathymetrySaverTool;

/* Embedded classes: */
private:
struct Configuration // Structure containing tool settings
{
/* Elements: */
public:
std::string saveFileName; // Name of file to which to save the bathymetry grid
bool postUpdate; // Flag whether to post an update message to a web server after saving the bathymetry grid
std::string postUpdateHostName; // Name of web server to which to send update messages
int postUpdatePort; // TCP port number of web server to which to send update messages
std::string postUpdatePage; // Name of page on web server to which update messages are posted
std::string postUpdateMessage; // The message to send to the web server

/* Constructors and destructors: */
Configuration(void); // Creates default configuration

/* Methods: */
void read(const Misc::ConfigurationFileSection& cfs); // Overrides configuration from configuration file section
void write(Misc::ConfigurationFileSection& cfs) const; // Writes configuration to configuration file section
};

/* Elements: */
private:
Configuration configuration; // Default configuration for all tools
WaterTable2* waterTable; // Pointer to water table object from which to request bathymetry grids
GLsizei gridSize[2]; // Width and height of the water table's bathymetry grid
GLfloat cellSize[2]; // Width and height of each water table cell

/* Constructors and destructors: */
public:
BathymetrySaverToolFactory(WaterTable2* sWaterTable,Vrui::ToolManager& toolManager);
virtual ~BathymetrySaverToolFactory(void);

/* Methods from Vrui::ToolFactory: */
virtual const char* getName(void) const;
virtual const char* getButtonFunction(int buttonSlotIndex) const;
virtual Vrui::Tool* createTool(const Vrui::ToolInputAssignment& inputAssignment) const;
virtual void destroyTool(Vrui::Tool* tool) const;
};

class BathymetrySaverTool:public Vrui::Tool,public Vrui::Application::Tool<Sandbox>
{
friend class BathymetrySaverToolFactory;

/* Elements: */
private:
static BathymetrySaverToolFactory* factory; // Pointer to the factory object for this class
BathymetrySaverToolFactory::Configuration configuration; // Configuration of this tool
GLfloat* bathymetryBuffer; // Bathymetry grid buffer
bool requestPending; // Flag if this tool has a pending request to retrieve a bathymetry grid

/* Private methods: */
void writeDEMFile(void) const; // Writes the bathymetry grid to a file in USGS DEM format
void postUpdate(void) const; // Sends an update message to a web server

/* Constructors and destructors: */
public:
static BathymetrySaverToolFactory* initClass(WaterTable2* sWaterTable,Vrui::ToolManager& toolManager);
BathymetrySaverTool(const Vrui::ToolFactory* factory,const Vrui::ToolInputAssignment& inputAssignment);
virtual ~BathymetrySaverTool(void);

/* Methods from class Vrui::Tool: */
virtual void configure(const Misc::ConfigurationFileSection& configFileSection);
virtual void storeState(Misc::ConfigurationFileSection& configFileSection) const;
virtual const Vrui::ToolFactory* getFactory(void) const;
virtual void buttonCallback(int buttonSlotIndex,Vrui::InputDevice::ButtonCallbackData* cbData);
virtual void frame(void);
};

#endif
39 changes: 23 additions & 16 deletions CalibrateProjector.cpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/***********************************************************************
CalibrateProjector - Utility to calculate the calibration transformation
of a projector into a Kinect-captured 3D space.
Copyright (c) 2012-2013 Oliver Kreylos
Copyright (c) 2012-2015 Oliver Kreylos
This file is part of the Augmented Reality Sandbox (SARndbox).
Expand Down Expand Up @@ -44,6 +44,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <Vrui/ToolManager.h>
#include <Vrui/OpenFile.h>

#include "Config.h"

/********************************************************
Static elements of class CalibrateProjector::CaptureTool:
********************************************************/
Expand Down Expand Up @@ -150,7 +152,7 @@ void CalibrateProjector::depthStreamingCallback(const Kinect::FrameBuffer& frame
Vrui::requestUpdate();
}

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

/* Process command line parameters: */
bool printHelp=false;
std::string sandboxLayoutFileName=CONFIGDIR;
std::string sandboxLayoutFileName=CONFIG_CONFIGDIR;
sandboxLayoutFileName.push_back('/');
sandboxLayoutFileName.append("BoxLayout.txt");
sandboxLayoutFileName.append(CONFIG_DEFAULTBOXLAYOUTFILENAME);
projectionMatrixFileName=CONFIG_CONFIGDIR;
projectionMatrixFileName.push_back('/');
projectionMatrixFileName.append(CONFIG_DEFAULTPROJECTIONMATRIXFILENAME);
int cameraIndex=0;
imageSize[0]=1024;
imageSize[1]=768;
Expand Down Expand Up @@ -233,6 +238,11 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
++i;
tiePointFileName=argv[i];
}
else if(strcasecmp(argv[i]+1,"pmf")==0)
{
++i;
projectionMatrixFileName=argv[i];
}
}
}

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

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

if(tiePoints.size()>=numTiePoints[0]*numTiePoints[1])
if(tiePoints.size()>=size_t(numTiePoints[0]*numTiePoints[1]))
{
/* Calculate an initial calibration: */
calcCalibration();
}
}

/* Enable background USB event handling: */
usbContext.startEventHandling();

/* Open the Kinect camera device: */
camera=new Kinect::Camera(usbContext,cameraIndex);
camera=new Kinect::Camera(cameraIndex);
camera->setCompressDepthFrames(true);
camera->setSmoothDepthFrames(false);
camera->setBackgroundRemovalFuzz(1);
Expand Down Expand Up @@ -360,7 +370,7 @@ void CalibrateProjector::frame(void)
if(rawFrames.lockNewValue())
{
/* Extract all foreground blobs from the raw depth frame: */
const DepthPixel* framePixels=static_cast<const DepthPixel*>(rawFrames.getLockedValue().getBuffer());
const DepthPixel* framePixels=rawFrames.getLockedValue().getData<DepthPixel>();
BlobForegroundSelector bfs;
BlobMergeChecker bmc(blobMergeDepth);
DepthCentroidBlob::Creator blobCreator;
Expand Down Expand Up @@ -481,7 +491,7 @@ void CalibrateProjector::frame(void)
capturingTiePoint=false;

/* Check if the calibration is complete: */
if(tiePoints.size()>=numTiePoints[0]*numTiePoints[1])
if(tiePoints.size()>=size_t(numTiePoints[0]*numTiePoints[1]))
{
/* Calculate the calibration transformation: */
calcCalibration();
Expand Down Expand Up @@ -829,10 +839,7 @@ void CalibrateProjector::calcCalibration(void)
projection=invViewport*projection;

/* Write the projection matrix to a file: */
std::string projFileName=CONFIGDIR;
projFileName.push_back('/');
projFileName.append("ProjectorMatrix.dat");
IO::FilePtr projFile=Vrui::openFile(projFileName.c_str(),IO::File::WriteOnly);
IO::FilePtr projFile=Vrui::openFile(projectionMatrixFileName.c_str(),IO::File::WriteOnly);
projFile->setEndianness(Misc::LittleEndian);
for(int i=0;i<4;++i)
for(int j=0;j<4;++j)
Expand Down
8 changes: 4 additions & 4 deletions CalibrateProjector.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/***********************************************************************
CalibrateProjector - Utility to calculate the calibration transformation
of a projector into a Kinect-captured 3D space.
Copyright (c) 2012-2013 Oliver Kreylos
Copyright (c) 2012-2015 Oliver Kreylos
This file is part of the Augmented Reality Sandbox (SARndbox).
Expand All @@ -27,7 +27,6 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include <Threads/Mutex.h>
#include <Threads/Cond.h>
#include <Threads/TripleBuffer.h>
#include <USB/Context.h>
#include <Math/Matrix.h>
#include <Geometry/Point.h>
#include <Geometry/AffineCombiner.h>
Expand Down Expand Up @@ -176,7 +175,6 @@ class CalibrateProjector:public Vrui::Application,public GLObject
unsigned int numTiePointFrames; // Number of frames to capture per tie point
unsigned int numBackgroundFrames; // Number of frames to capture for background removal
int blobMergeDepth; // Maximum depth difference between neighboring pixels in the same blob
USB::Context usbContext; // USB device context
Kinect::Camera* camera; // Pointer to Kinect camera defining the object space
unsigned int frameSize[2]; // Size of the Kinect camera's depth frames in pixels
PixelDepthCorrection* pixelDepthCorrection; // Buffer of per-pixel depth correction coefficients
Expand All @@ -199,9 +197,11 @@ class CalibrateProjector:public Vrui::Application,public GLObject
bool haveProjection; // Flag if a projection matrix has been computed
Math::Matrix projection; // The current projection matrix

std::string projectionMatrixFileName; // Name of the file to which the projection matrix is saved

/* Private methods: */
void depthStreamingCallback(const Kinect::FrameBuffer& frameBuffer); // Callback receiving depth frames from the Kinect camera
void backgroundCaptureCompleteCallback(Kinect::Camera& camera); // Callback when the Kinect camera is done capturing a background image
void backgroundCaptureCompleteCallback(Kinect::DirectFrameSource& camera); // Callback when the Kinect camera is done capturing a background image

/* Constructors and destructors: */
public:
Expand Down
33 changes: 33 additions & 0 deletions Config.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/***********************************************************************
Config - Configuration header file for the Augmented Reality Sandbox.
Copyright (c) 2014-2016 Oliver Kreylos
This file is part of the Augmented Reality Sandbox (SARndbox).
The Augmented Reality Sandbox is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License as
published by the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
The Augmented Reality Sandbox is distributed in the hope that it will be
useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along
with the Augmented Reality Sandbox; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
***********************************************************************/

#ifndef CONFIG_INCLUDED
#define CONFIG_INCLUDED

#define CONFIG_CONFIGDIR "/usr/local/etc/SARndbox-3.0"
#define CONFIG_SHADERDIR "/usr/local/share/SARndbox-3.0/Shaders"

#define CONFIG_DEFAULTCONFIGFILENAME "SARndbox.cfg"
#define CONFIG_DEFAULTBOXLAYOUTFILENAME "BoxLayout.txt"
#define CONFIG_DEFAULTPROJECTIONMATRIXFILENAME "ProjectorMatrix.dat"
#define CONFIG_DEFAULTHEIGHTCOLORMAPFILENAME "HeightColorMap.cpt"

#endif
Loading

0 comments on commit 1e9ae8f

Please sign in to comment.