1
1
/* **********************************************************************
2
2
CalibrateProjector - Utility to calculate the calibration transformation
3
3
of a projector into a Kinect-captured 3D space.
4
- Copyright (c) 2012-2013 Oliver Kreylos
4
+ Copyright (c) 2012-2015 Oliver Kreylos
5
5
6
6
This file is part of the Augmented Reality Sandbox (SARndbox).
7
7
@@ -44,6 +44,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
44
44
#include < Vrui/ToolManager.h>
45
45
#include < Vrui/OpenFile.h>
46
46
47
+ #include " Config.h"
48
+
47
49
/* *******************************************************
48
50
Static elements of class CalibrateProjector::CaptureTool:
49
51
********************************************************/
@@ -150,7 +152,7 @@ void CalibrateProjector::depthStreamingCallback(const Kinect::FrameBuffer& frame
150
152
Vrui::requestUpdate ();
151
153
}
152
154
153
- void CalibrateProjector::backgroundCaptureCompleteCallback (Kinect::Camera &)
155
+ void CalibrateProjector::backgroundCaptureCompleteCallback (Kinect::DirectFrameSource &)
154
156
{
155
157
/* Reset the background capture flag: */
156
158
std::cout<<" done" <<std::endl;
@@ -182,9 +184,12 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
182
184
183
185
/* Process command line parameters: */
184
186
bool printHelp=false ;
185
- std::string sandboxLayoutFileName=CONFIGDIR ;
187
+ std::string sandboxLayoutFileName=CONFIG_CONFIGDIR ;
186
188
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);
188
193
int cameraIndex=0 ;
189
194
imageSize[0 ]=1024 ;
190
195
imageSize[1 ]=768 ;
@@ -233,6 +238,11 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
233
238
++i;
234
239
tiePointFileName=argv[i];
235
240
}
241
+ else if (strcasecmp (argv[i]+1 ," pmf" )==0 )
242
+ {
243
+ ++i;
244
+ projectionMatrixFileName=argv[i];
245
+ }
236
246
}
237
247
}
238
248
@@ -244,7 +254,7 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
244
254
std::cout<<" Prints this help message" <<std::endl;
245
255
std::cout<<" -slf <sandbox layout file name>" <<std::endl;
246
256
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;
248
258
std::cout<<" -c <camera index>" <<std::endl;
249
259
std::cout<<" Selects the local Kinect camera of the given index (0: first camera" <<std::endl;
250
260
std::cout<<" on USB bus)" <<std::endl;
@@ -262,6 +272,9 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
262
272
std::cout<<" Default: 1" <<std::endl;
263
273
std::cout<<" -tpf <tie point file name>" <<std::endl;
264
274
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;
265
278
}
266
279
267
280
/* Read the sandbox layout file: */
@@ -295,18 +308,15 @@ CalibrateProjector::CalibrateProjector(int& argc,char**& argv)
295
308
tiePoints.push_back (tp);
296
309
}
297
310
298
- if (tiePoints.size ()>=numTiePoints[0 ]*numTiePoints[1 ])
311
+ if (tiePoints.size ()>=size_t ( numTiePoints[0 ]*numTiePoints[1 ]) )
299
312
{
300
313
/* Calculate an initial calibration: */
301
314
calcCalibration ();
302
315
}
303
316
}
304
317
305
- /* Enable background USB event handling: */
306
- usbContext.startEventHandling ();
307
-
308
318
/* Open the Kinect camera device: */
309
- camera=new Kinect::Camera (usbContext, cameraIndex);
319
+ camera=new Kinect::Camera (cameraIndex);
310
320
camera->setCompressDepthFrames (true );
311
321
camera->setSmoothDepthFrames (false );
312
322
camera->setBackgroundRemovalFuzz (1 );
@@ -360,7 +370,7 @@ void CalibrateProjector::frame(void)
360
370
if (rawFrames.lockNewValue ())
361
371
{
362
372
/* 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>( );
364
374
BlobForegroundSelector bfs;
365
375
BlobMergeChecker bmc (blobMergeDepth);
366
376
DepthCentroidBlob::Creator blobCreator;
@@ -481,7 +491,7 @@ void CalibrateProjector::frame(void)
481
491
capturingTiePoint=false ;
482
492
483
493
/* Check if the calibration is complete: */
484
- if (tiePoints.size ()>=numTiePoints[0 ]*numTiePoints[1 ])
494
+ if (tiePoints.size ()>=size_t ( numTiePoints[0 ]*numTiePoints[1 ]) )
485
495
{
486
496
/* Calculate the calibration transformation: */
487
497
calcCalibration ();
@@ -829,10 +839,7 @@ void CalibrateProjector::calcCalibration(void)
829
839
projection=invViewport*projection;
830
840
831
841
/* 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);
836
843
projFile->setEndianness (Misc::LittleEndian);
837
844
for (int i=0 ;i<4 ;++i)
838
845
for (int j=0 ;j<4 ;++j)
0 commit comments