Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleThreeDOutVRML.cpp

Example for ThreeDOut object, writes a wrl with an image

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT for details)
Multimediale Systeme der Informationsverarbeitung
Institut fuer Informatik
Christian-Albrechts-Universitaet Kiel
BIAS is free software; you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 2.1 of the License, or
(at your option) any later version.
BIAS 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 Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with BIAS; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/** @example ExampleThreeDOutVRML.cpp
* @relates ThreeDOut
@ingroup g_examples
@brief Example for ThreeDOut object, writes a wrl with an image
@author MIP */
#include "Utils/ThreeDOut.hh"
#include <Base/Common/BIASpragma.hh>
using namespace std;
using namespace BIAS;
int main()
{
param.PointStyle = Box;
param.PointSize = 0.1;
param.LineStyle = Solid;
ThreeDOut T(param);
HomgPoint3D P1(1,1,1), P2(0,0,0);
RGBAuc Color(0,0,255,0);
//T.AddLine(P1, P2, Color);
P1[0] = 5;
P1[1] = -1;
//T.AddPoint(P1, Color);
P2[0] = 3;
P2[1] = 2;
// T.AddPoint(P2);
Color[0]=255;
Color[1]=0;
Color[2]=128;
//T.AddPMatrix(P, 640, 480, Color);
Cov.SetIdentity();
Cov[0][0] = 0.5;
Cov[1][1] = 0.8;
P2[2] = 0.8;
Color[1] = 255;
//T.AddEllipsoid(Cov, P2, Color);
#define IMSIZE 5
Image<unsigned char> im(IMSIZE,IMSIZE,1);
for (unsigned int i=0; i<IMSIZE*IMSIZE; i++)
im.GetImageDataArray()[i/IMSIZE][i%IMSIZE]
= (255 / (IMSIZE*IMSIZE)) * i;
// 3 of the 4 corners
Vector3<double> UL(0,0,0), UR(1,0,0), LL(0,0,1),
offset1(5,-5,12), offset2(17,-5, 2);
T.AddImage(UL+offset2, UR+offset2, LL+offset2, IMSIZE, IMSIZE, im.GetImageData(),
1, "testbillboard1", false);
T.AddImage(UL+offset1, UR+offset1, LL+offset1, IMSIZE, IMSIZE,
1, "testbillboard2", true);
K[0][2] = 256;
K[1][2] = 256;
cout<<"K is "<<K<<endl;
K[0][0] = K[1][1] = 256;
Vector3<double> axis(0.1, 0.9, 0.1);
axis.Normalize();
PMatrix PM1(K, RMatrix(axis, 0.4), offset1),
PM2(K, RMatrix(MatrixIdentity), offset2),
PM3(K, RMatrix(axis, -0.3), Vector3<double>(6.5,0,0));
T.AddPMatrix(PM1, 512, 512);
T.AddPMatrix(PM2, 512, 512);
//T.AddPMatrix(PM3, 512, 512);
T.VRMLOut("test.wrl");
T.Dump();
return 0;
}