Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
biaswarpkinect2.cpp
1 #include <Base/Image/ImageIO.hh>
2 #include <OpenGLFramework/RenderingContext/glfPBuffer.hh>
3 #include <OpenGLFramework/RenderingContext/glfRenderingContext.hh>
4 #include <iostream>
5 
6 #include <VideoSource/VideoSource_Kinect2.hh>
7 #include <OpenGLFramework/SpecializedBatches/MultipleDepthWarp.hh>
8 
9 using namespace std;
10 using namespace BIAS;
11 
12 int main(int argc, char *argv[]) {
13 
14 
15  glfPBuffer context;
17  config.width = 5;
18  config.height = 5;
19  config.redSize = 8;
20  config.greenSize = 8;
21  config.blueSize = 8;
22  config.alphaSize = 8;
23  context.Init(config);
24 
25  context.MakeCurrent();
26 
27  std::string cdir="/home/fkellner/20150415_calibration_kinects_only/";
28  std::string idir="/home/fkellner/20150415_test_kinect/";
29 
30  Image<float> depthmapmain,depthmapsieg;
31  ImageIO::Load(idir+"kinect-main-00000-depth.mip", depthmapmain);
32  ImageIO::Load(idir+"kinect-sieg-00000-depth.mip", depthmapsieg);
33 
34  Projection projmain, projsieg;
35  projmain.Load(cdir+"igor-kinect-calibration-main.xml");
36  projsieg.Load(cdir+"igor-kinect-calibration-sieg.xml");
37  std::vector<Projection> sourceCams;
38  sourceCams.push_back( projmain );
39  sourceCams.push_back( projsieg );
40  Projection target = projmain;
41  Vector3<double> C = projsieg.GetC() + projmain.GetC();
42  C.MultIP(0.5);
43  target.SetC( C );
44  Quaternion<double> Q = projsieg.GetQ().Interpolate(projmain.GetQ(), 0.5);
45  target.SetQ( Q );
46 
48 
49  MultipleDepthWarp warp;
50  warp.SetWarpType(MultipleDepthWarp::DEPTH);
51  warp.FlipTextureCoordinates(true);
52  warp.Init( *targetCam, sourceCams, true);
53  warp.UploadDepthMap( depthmapmain,0 );
54  warp.UploadDepthMap( depthmapsieg,1 );
55  warp.Warp();
56  Image<float> result;
57  warp.GetWarpedDisparity(result);
58  ImageIO::Save("warp.mip", result);
59  return 0;
60 }
virtual int Load(const std::string &filename)
convenience wrapper which tries to read different formats
Definition: Projection.cpp:62
camera parameters which define the mapping between rays in the camera coordinate system and pixels in...
int Warp()
warps the depths maps for all sourceCameras to the target camera view as disparity / depth map ...
virtual void MakeCurrent()
Makes this context the current target for OpenGL calls.
int GetWarpedDisparity(Image< float > &dispMap)
gives the warped disparity / depth map as a bias image
virtual void SetC(const Vector3< double > &C, unsigned int cam=0)
Set center of camera with index cam.
Definition: Projection.hh:331
BIAS::Quaternion< double > GetQ(unsigned int cam=0) const
return rotation quaternion of camera with index cam if cam&gt;0 this is a relative pose in the coordinat...
Definition: Projection.cpp:524
int UploadDepthMap(Image< float > &depthMap, unsigned int index)
uploads the given depthMap to the gpu as texture depthMap is a depth map from source camera i ...
const ProjectionParametersBase * GetParameters(unsigned int cam=0) const
const parameter access function
Definition: Projection.hh:194
This class hides the underlying projection model, like projection matrix, spherical camera...
Definition: Projection.hh:70
Quaternion< QUAT_TYPE > Interpolate(const Quaternion< QUAT_TYPE > &to, const QUAT_TYPE &t) const
Spherical interpolation between this and given quaternion.
GLX pbuffer rendering context.
void FlipTextureCoordinates(bool flip)
void SetWarpType(WARPING_TYPE type)
virtual void Init(const glfRenderingContextConfig &config)
Initializes the rendering context with the given configuration.
void MultIP(const T &scalar)
Definition: Vector3.hh:327
int Init(const ProjectionParametersPerspective &targetCam, std::vector< Projection > &sourceCameras, bool createDepthMaps=true)
virtual void SetQ(const Quaternion< double > &Q, unsigned int cam=0)
Set rotation quaternion of camera with index cam.
Definition: Projection.hh:338
Vector3< double > GetC(unsigned int cam=0) const
return Center of camera with index cam.
Definition: Projection.hh:236
Configuration for a rendering context.