Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleDynamicCastImage.cpp
1 /* This file is part of the BIAS library (Basic ImageAlgorithmS).
2 
3  Copyright (C) 2003-2009 (see file CONTACT for details)
4  Multimediale Systeme der Informationsverarbeitung
5  Institut fuer Informatik
6  Christian-Albrechts-Universitaet Kiel
7 
8 
9  BIAS is free software; you can redistribute it and/or modify
10  it under the terms of the GNU Lesser General Public License as published by
11  the Free Software Foundation; either version 2.1 of the License, or
12  (at your option) any later version.
13 
14  BIAS is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Lesser General Public License for more details.
18 
19  You should have received a copy of the GNU Lesser General Public License
20  along with BIAS; if not, write to the Free Software
21  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA*/
22 
23 
24 /**
25  * @example ExampleDynamicCastImage.cpp
26  @brief Example for dynamically casting images
27  @ingroup g_examples
28  @author woelk 10/2007 (c) www.vision-n.de
29 */
30 
31 #include <Image/Camera.hh>
32 
33 using namespace BIAS;
34 using namespace std;
35 
36 int main(int argc, char *argv[])
37 {
38  PMatrix P;
39  for (int i=0; i<12; i++)
40  P.GetData()[i] = (double)i;
42  cam.Init(640, 480, 1);
43  cam.SetP(P);
44  cam.UpdateMetaData();
45 
46  ImageBase *ib = &cam;
47 
48  Camera<unsigned char> *cam2 = dynamic_cast<Camera<unsigned char> *>(ib);
49  if (!cam2){
50  BIASERR("error in dynamic cast");
51  return -1;
52  }
53 
54  cam2->ParseMetaData();
55  cout << "cam2->P: "<<cam2->GetP()<<endl;
56 
57  return 0;
58 }
int SetP(const PMatrix &matP)
Definition: Camera.hh:102
T * GetData()
get the pointer to the data array of the matrix (for faster direct memeory access) ...
Definition: Matrix.hh:185
const BIAS::PMatrix & GetP() const
Definition: Camera.hh:104
void Init(unsigned int Width, unsigned int Height, unsigned int channels=1, enum EStorageType storageType=ST_unsignedchar, const bool interleaved=true)
calls Init from ImageBase storageType is ignored, just dummy argument
Definition: Image.cpp:421
int UpdateMetaData()
copy P_ and co.
Definition: Camera.cpp:446
describes a projective 3D -&gt; 2D mapping in homogenous coordinates
Definition: PMatrix.hh:88
This is the base class for images in BIAS.
Definition: ImageBase.hh:102
int ParseMetaData(bool bUse2x64bitTS=true)
After ImageIO::Load() operated on AppData_, this method fills P_, Timestamp, DC_*, ...
Definition: Camera.cpp:154