Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
ExampleIpl.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 
26 /**
27  @example ExampleIpl.cpp
28  @brief OpenCV/IPL image format acces.
29  @ingroup g_examples
30  @author Thomsen / Woetzel
31 */
32 
33 #include <iostream>
34 
35 #include <Base/Image/Image.hh>
36 #include <Base/Image/ImageIO.hh>
37 #include <Base/Image/ImageConvert.hh>
38 
39 #ifdef BIAS_HAVE_OPENCV
40 # include <highgui.h>
41 #endif
42 
43 using namespace BIAS;
44 using namespace std;
45 
46 int main(int argc, char *argv[])
47 {
48 #ifdef BIAS_HAVE_OPENCV
49  Image<unsigned char> im, im2;
50  IplImage *dst=NULL;
51 
52  if (argc!=2){
53  BIASERR(argv[0]<<" <image-file>");
54  return -1;
55  }
56 
57  if (ImageIO::Load(argv[1], im)!=0){
58  BIASERR("error loading "<<argv[1]<<" (Load)");
59  return -2;
60  }
61 
62  if (ImageConvert::BIAS2ipl(im, dst)!=0){
63  BIASERR("error converting bias -> ipl");
64  return -2;
65  }
66 
67  cvNamedWindow( "window", 1 );
68  cvShowImage( "window", dst );
69  const int delay=3000;
70  //cvWaitKey(0);
71  std::cout<<"will close gui window after "<<delay<<" msecs."<<endl;
72  cvWaitKey(4000); // msec
73  std::cout<<"closed window."<<endl;
74 
75  if (ImageConvert::Ipl2BIAS(dst, im2)!=0){
76  BIASERR("error converting ipl -> bias");
77  return -2;
78  }
79 
80  //if (ImageIO::Save("out_bias-ipl-bias.mip", im2)!=0){
81  if (ImageIO::Save("out_bias-ipl-bias.mip", im2)!=0){
82  BIASERR("error writing bias-ipl-bias.mip");
83  return -1;
84  }
85 #else
86  std::cout<<"you compiled without OpenCV."<<endl;
87 #endif
88  return 0;
89 }
static int Ipl2BIAS(IplImage *source, Image< StorageType > &dest)
Takes the image information and data of an existing IplImage and builds a Image.
static int Save(const std::string &filename, const ImageBase &img, const enum TFileFormat FileFormat=FF_auto, const bool sync=BIAS_DEFAULT_SYNC, const int c_jpeg_quality=BIAS_DEFAULT_IMAGE_QUALITY, const bool forceNewID=BIAS_DEFAULT_FORCENEWID, const bool &writeMetaData=true)
Export image as file using extrnal libs.
Definition: ImageIO.cpp:725
static int Load(const std::string &FileName, ImageBase &img)
first tries a call to Read MIP image and if that fails, tries to Import Image with all other availabl...
Definition: ImageIO.cpp:141
static int BIAS2ipl(const Image< StorageType > &source, IplImage *&dest)
Returns a new, separate IplImage for use with OpenCV created rom the source BIAS Image.