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

OpenCV/IPL image draw

Author
Woetzel
/*
This file is part of the BIAS library (Basic ImageAlgorithmS).
Copyright (C) 2003-2009 (see file CONTACT 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 ExampleIplImageDraw.cpp
@relates ImageDraw
@brief OpenCV/IPL image draw
@ingroup g_examples
@author Woetzel
*/
#include <iostream>
#include <string>
// BIAS
#include <Base/Image/Image.hh>
#include <Base/Image/ImageIO.hh>
#include <Base/ImageUtils/ImageDraw.hh>
#include <Base/Image/ColourRGB.hh>
using namespace std;
using namespace BIAS;
int main( int argc, char** argv ){
int result=0;
bool darttest=false;
if (argc>=2) if (strcmp(argv[1],"-darttest")==0) {
darttest=true;
std::cout<<"started dart test: "<<argv[0]<<std::endl;
}
//
// load a BIAS image to work with:
//
string filename( BIAS_TESTS_DATA "r4.jpg" );
if (!darttest && (argc>1)) filename=argv[1];
if (BIAS::ImageIO::Load(filename, img) !=0){
cout<<"error loading image "<<filename<<endl;
return -1;
};
cout<<"loaded image "<<filename<<" with dim: "<<img.GetWidth()<<"x"<<img.GetHeight()<<endl;
//
// OK, work:
//
{
ImageDraw<unsigned char>::Circle(img, 100,150, 40,COLOR_RED,
5, CV_AA, 0 );
ImageDraw<unsigned char>::Line(img, 10,10, 100,100,
25, // thickness
CV_AA
);
,200,300 // center
,150, 50 // axes
,45 // orientation
,0, 270 // paint angle from..to
,COLOR_WHITE
,20
);
100,100,
150,200,
COLOR_BLACK,
8
);
ImageDraw<unsigned char>::Text(img, "Hello BIAS!!", 10,50 );
ImageDraw<unsigned char>::Text(img, "ExampleIplImageDraw.cpp RED", 10, 100, COLOR_RED );
ImageDraw<unsigned char>::Text(img, "ExampleIplImageDraw.cpp GREEN",10, 150, COLOR_GREEN );
ImageDraw<unsigned char>::Text(img, "ExampleIplImageDraw.cpp BLUE", 10, 200, COLOR_BLUE );
ImageDraw<unsigned char>::Text(img, "Renault 4TL rocks ;-)", 10, 250, COLOR_BLUE,
CV_FONT_HERSHEY_SIMPLEX, 1.5, 1.5, 0, 2, CV_AA);
ImageDraw<unsigned char>::Text(img, argv[0] , 0, 300, COLOR_WHITE,
CV_FONT_HERSHEY_PLAIN, 0.8, 1.2, 0, 1, CV_AA);
}
//
// output result:
//
string outFn("out_ExampleIplImageDraw.jpg");
//string outFn("out_ExampleIplImageDraw.png");
//result=BIAS::ImageIO::Save(outFn, img, BIAS::ImageIO::FF_png);
if (result==0) cout<<"wrote "<<outFn<<endl;
// ---- Example for Dart attachment adta submission (Jan Woetzel) ----
//
// attach Dart client xml data for submission to dart server (JW):
// jpeg is much smaller.
cout<<endl
//<<"<DartMeasurementFile name=\"outputImage1\" type=\"image/png\">"<<outFn<<"</DartMeasurementFile>"
<<"<DartMeasurementFile name=\"outputImage1\" type=\"image/jpeg\">"<<outFn<<"</DartMeasurementFile>"
<<endl;
return result;
}