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

Example for creating a calibrated pyramid object with automatic adaption of BIAS::Projection to pyramid layers

Author
MIP
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003, 2004 (see file CONTACTS 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 ExampleCalibratedPyramid.cpp
@relates CalibratedPyramid
@brief Example for creating a calibrated pyramid object with
automatic adaption of BIAS::Projection to pyramid layers
@ingroup g_examples
@author MIP
*/
#include <Base/Image/ImageIO.hh>
#include <Base/Image/ImageConvert.hh>
#include <Image/CalibratedPyramid.hh>
#include <Image/Camera.hh>
using namespace BIAS;
using namespace std;
int main(int argc, char *argv[])
{
if (argc<2){
cerr << argv[0] << " <image>"<<endl;
return -1;
}
if (ImageIO::Load(argv[1], cam)!=0){
cerr << "error loading image \""<<argv[1]<<"\"\n";
return -2;
}
// extract projections
BIASASSERT(cam.IsProjValid());
BIASASSERT(ci.projection);
if (cam.GetChannelCount()!=1){
if (ImageConvert::ToGrey(cam, tmp)!=0){
return -3;
}
cam = tmp;
}
// this does not Work!!! SharedPtr is destructing object and it ends in a double free
// ci.image = SharedPtr<Image<unsigned char> >(&cam);
double rescale = 4.0;
unsigned size = 2;
cp.Init(ci, size, rescale);
cout<<"Size:"<<cp.Size()<<endl;
cout<<"RefCount image:"<<RefCount(ci.image)<<endl;
cout<<"RefCount projection:"<<RefCount(ci.projection)<<endl;
return 0;
}