Alida-C++ 0.5

dataio/provider/cmdline/openCVImageProvider.cc

Go to the documentation of this file.
00001 /*
00002  * This file is part of Alida-C++ library for
00003  *
00004  * Automatic Logging of Process Information in Data Analysis.
00005  *
00006  * Copyright (C) 2012 - @YEAR@
00007  *
00008  * This program is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, either version 3 of the License, or
00011  * (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
00020  *
00021  * Fore more information on Alida, visit
00022  *
00023  *    http://www.informatik.uni-halle.de/alida/
00024  *
00025  */
00026 
00027 /*
00028  * Most recent change(s):
00029  *
00030  * $Rev: 58 $
00031  * $Date: 2012-03-06 11:49:07 +0100 (Di, 06 Mrz 2012) $
00032  * $Author: moeller $
00033  *
00034  */
00035 
00036 #include <math.h>
00037 #include <stdio.h>
00038 #include <fstream>
00039 #include <string>
00040 #include <iostream>
00041 
00042 #include <opencv/cv.h>
00043 #include <opencv/highgui.h>
00044 
00045 #include "dataio/ioManagerCmdline.h"
00046 #include "dataio/provider/cmdline/openCVImageProvider.h"
00047 
00048 using namespace std;
00049 
00050 using namespace Alida;
00051 
00056 REGISTER_PROVIDER(OpenCVImageProvider,IplImage,Cmdline);
00057 
00066 void* OpenCVImageProvider::parseInput(string input, string type) const
00067 {
00068     IplImage *img = cvLoadImage(input.c_str());
00069     return img;
00070 }
00071 
00083 string
00084 OpenCVImageProvider::writeOutput(
00085                                         std::string format, std::string type, void *data) const
00086 {
00087     string outString;
00088     if (data == NULL) {
00089         cerr << "Image is NULL, nothing to write..." << endl;
00090         return outString;
00091     }
00092     IplImage *img = (IplImage*)(data);
00093 
00094     if (format == "-") {
00095         // display the image on screen
00096         cvNamedWindow("Result Window",1);
00097         cvShowImage("Result Window",img);
00098         while(1) {
00099             if (cvWaitKey( 100) == 27)
00100                 break;
00101         }
00102         cvDestroyWindow("Result Window");
00103     }
00104     else {
00105         // save to file
00106         cvSaveImage(format.c_str(),img);
00107     }
00108     return outString;
00109 }
00110 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines