Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleThreeDOutVRML.cpp
1 /*
2 This file is part of the BIAS library (Basic ImageAlgorithmS).
3 
4 Copyright (C) 2003-2009 (see file CONTACT for details)
5  Multimediale Systeme der Informationsverarbeitung
6  Institut fuer Informatik
7  Christian-Albrechts-Universitaet Kiel
8 
9 
10 BIAS is free software; you can redistribute it and/or modify
11 it under the terms of the GNU Lesser General Public License as published by
12 the Free Software Foundation; either version 2.1 of the License, or
13 (at your option) any later version.
14 
15 BIAS is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU Lesser General Public License for more details.
19 
20 You should have received a copy of the GNU Lesser General Public License
21 along with BIAS; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 */
24 
25 /** @example ExampleThreeDOutVRML.cpp
26  * @relates ThreeDOut
27  @ingroup g_examples
28  @brief Example for ThreeDOut object, writes a wrl with an image
29  @author MIP */
30 
31 #include "Utils/ThreeDOut.hh"
32 
33 #include <Base/Common/BIASpragma.hh>
34 
35 using namespace std;
36 using namespace BIAS;
37 
38 int main()
39 {
40  ThreeDOutParameters param;
41  param.CameraStyle = PyramidSolid;
42  param.PointStyle = Box;
43  param.PointSize = 0.1;
44  param.LineStyle = Solid;
45  param.DrawUncertaintyEllipsoids = false;
46  ThreeDOut T(param);
47  HomgPoint3D P1(1,1,1), P2(0,0,0);
48  RGBAuc Color(0,0,255,0);
49 
50  //T.AddLine(P1, P2, Color);
51  P1[0] = 5;
52  P1[1] = -1;
53  //T.AddPoint(P1, Color);
54  P2[0] = 3;
55  P2[1] = 2;
56  // T.AddPoint(P2);
57 
58 
59  PMatrix P;
60  P.SetIdentity();
61  Color[0]=255;
62  Color[1]=0;
63  Color[2]=128;
64  //T.AddPMatrix(P, 640, 480, Color);
65 
66  CovMatrix3x3 Cov;
67  Cov.SetIdentity();
68  Cov[0][0] = 0.5;
69  Cov[1][1] = 0.8;
70  P2[2] = 0.8;
71  Color[1] = 255;
72  //T.AddEllipsoid(Cov, P2, Color);
73 
74 
75 
76 
77 
78 #define IMSIZE 5
79  Image<unsigned char> im(IMSIZE,IMSIZE,1);
80  for (unsigned int i=0; i<IMSIZE*IMSIZE; i++)
81  im.GetImageDataArray()[i/IMSIZE][i%IMSIZE]
82  = (255 / (IMSIZE*IMSIZE)) * i;
83  // 3 of the 4 corners
84  Vector3<double> UL(0,0,0), UR(1,0,0), LL(0,0,1),
85  offset1(5,-5,12), offset2(17,-5, 2);
86  T.AddImage(UL+offset2, UR+offset2, LL+offset2, IMSIZE, IMSIZE, im.GetImageData(),
87  1, "testbillboard1", false);
88 
89  T.AddImage(UL+offset1, UR+offset1, LL+offset1, IMSIZE, IMSIZE,
90  im.GetImageData(),
91  1, "testbillboard2", true);
92 
93 
94  KMatrix K(MatrixIdentity);
95  K[0][2] = 256;
96  K[1][2] = 256;
97  cout<<"K is "<<K<<endl;
98  K[0][0] = K[1][1] = 256;
99  Vector3<double> axis(0.1, 0.9, 0.1);
100  axis.Normalize();
101  PMatrix PM1(K, RMatrix(axis, 0.4), offset1),
102  PM2(K, RMatrix(MatrixIdentity), offset2),
103  PM3(K, RMatrix(axis, -0.3), Vector3<double>(6.5,0,0));
104  T.AddPMatrix(PM1, 512, 512);
105  T.AddPMatrix(PM2, 512, 512);
106  //T.AddPMatrix(PM3, 512, 512);
107 
108  T.VRMLOut("test.wrl");
109  T.Dump();
110  return 0;
111 }
class RGBAuc is asynonym for a Vector4 of corerct type
Unified output of 3D entities via OpenGL or VRML.
Definition: ThreeDOut.hh:349
configuration struct for drawing styles of various 3d objects
Definition: ThreeDOut.hh:309
CameraDrawingStyle CameraStyle
Definition: ThreeDOut.hh:313
3D rotation matrix
Definition: RMatrix.hh:49
void SetIdentity()
set the elements of this matrix to the matrix 1 0 0 0 0 1 0 0 0 0 1 0 which is no strict identity (!)...
Definition: Matrix3x4.hh:240
class for 3x3 covariance matrices
Definition: CovMatrix3x3.hh:50
LineDrawingStyle LineStyle
Definition: ThreeDOut.hh:314
class HomgPoint3D describes a point with 3 degrees of freedom in projective coordinates.
Definition: HomgPoint3D.hh:61
K describes the mapping from world coordinates (wcs) to pixel coordinates (pcs).
Definition: KMatrix.hh:48
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
PointDrawingStyle PointStyle
Definition: ThreeDOut.hh:312
void SetIdentity()
set the elements of this matrix to the identity matrix (possibly overriding the inherited method) ...
Definition: Matrix3x3.hh:429