Draw.h
Go to the documentation of this file.
00001 /*
00002  * This file is part of ALVAR, A Library for Virtual and Augmented Reality.
00003  *
00004  * Copyright 2007-2012 VTT Technical Research Centre of Finland
00005  *
00006  * Contact: VTT Augmented Reality Team <alvar.info@vtt.fi>
00007  *          <http://www.vtt.fi/multimedia/alvar.html>
00008  *
00009  * ALVAR is free software; you can redistribute it and/or modify it under the
00010  * terms of the GNU Lesser General Public License as published by the Free
00011  * Software Foundation; either version 2.1 of the License, or (at your option)
00012  * any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful, but WITHOUT
00015  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00016  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
00017  * for more details.
00018  *
00019  * You should have received a copy of the GNU Lesser General Public License
00020  * along with ALVAR; if not, see
00021  * <http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>.
00022  */
00023 
00024 #ifndef DRAW_H
00025 #define DRAW_H
00026 
00034 #include "Alvar.h"
00035 #include "Util.h"
00036 #include "Camera.h"
00037 #include "Line.h"
00038 #include <sstream>
00039 
00040 namespace alvar {
00041 
00048 template<class PointType>
00049 void inline DrawBB(IplImage *image, const std::vector<PointType>& points, CvScalar color, std::string label="")
00050 {
00051     if (points.size() < 2) {
00052         return;
00053     }
00054     PointType minimum = PointType(image->width, image->height);
00055     PointType maximum = PointType(0, 0);
00056     for (int i = 0; i < (int)points.size(); ++i) {
00057         PointType current = points.at(i);
00058         if (current.x < minimum.x) minimum.x = current.x;
00059         if (current.x > maximum.x) maximum.x = current.x;
00060         if (current.y < minimum.y) minimum.y = current.y;
00061         if (current.y > maximum.y) maximum.y = current.y;
00062     }
00063     cvLine(image, cvPoint((int)minimum.x,(int)minimum.y), cvPoint((int)maximum.x,(int)minimum.y), color);
00064         cvLine(image, cvPoint((int)maximum.x,(int)minimum.y), cvPoint((int)maximum.x,(int)maximum.y), color);
00065         cvLine(image, cvPoint((int)maximum.x,(int)maximum.y), cvPoint((int)minimum.x,(int)maximum.y), color);
00066         cvLine(image, cvPoint((int)minimum.x,(int)maximum.y), cvPoint((int)minimum.x,(int)minimum.y), color);
00067     if (!label.empty()) {
00068         CvFont font;
00069                 cvInitFont(&font, 0, 0.5, 0.5, 0);
00070                 cvPutText(image, label.c_str(), cvPoint((int)minimum.x+1,(int)minimum.y+2), &font, CV_RGB(255,255,0));
00071     }
00072 }
00073 
00079 void ALVAR_EXPORT DrawPoints(IplImage *image, const std::vector<CvPoint>& points, CvScalar color);
00080 
00087 template<class PointType>
00088 void inline DrawLines(IplImage *image, const std::vector<PointType>& points, CvScalar color, bool loop=true)
00089 {
00090         for(unsigned i = 1; i < points.size(); ++i)
00091                 cvLine(image, cvPoint((int)points[i-1].x,(int)points[i-1].y), cvPoint((int)points[i].x,(int)points[i].y), color);
00092         if (loop) {
00093                 cvLine(image, cvPoint((int)points[points.size()-1].x,(int)points[points.size()-1].y), cvPoint((int)points[0].x,(int)points[0].y), color);
00094         }
00095 }
00096 
00102 void ALVAR_EXPORT DrawLine(IplImage* image, const Line line, CvScalar color = CV_RGB(0,255,0));
00103 
00109 void ALVAR_EXPORT DrawPoints(IplImage* image, const CvSeq* contour, CvScalar color = CV_RGB(255,0,0));
00110 
00111 
00118 void ALVAR_EXPORT DrawCircles(IplImage* image, const CvSeq* contour, int radius, CvScalar color = CV_RGB(255,0,0));
00119 
00125 void ALVAR_EXPORT DrawLines(IplImage* image, const CvSeq* contour, CvScalar color = CV_RGB(255,0,0));
00126 
00133 template<class PointType>
00134 void inline DrawPoints(IplImage *image, const std::vector<PointType>& points, CvScalar color, int radius=1)
00135 {
00136         for(unsigned i = 0; i < points.size(); ++i)
00137                 cvCircle(image, cvPoint((int)points[i].x,(int)points[i].y), radius, color);
00138 }
00139 
00147 void ALVAR_EXPORT DrawCVEllipse(IplImage* image, CvBox2D& ellipse, CvScalar color, bool fill=false, double par=0);
00148 
00157 void ALVAR_EXPORT BuildHideTexture(IplImage *image, IplImage *hide_texture, 
00158         Camera *cam, double gl_modelview[16], 
00159         PointDouble topleft, PointDouble botright);
00160 
00169 void ALVAR_EXPORT DrawTexture(IplImage *image, IplImage *texture, 
00170         Camera *cam, double gl_modelview[16], 
00171         PointDouble topleft, PointDouble botright);
00172 
00173 } // namespace alvar
00174 
00175 #endif


ar_track_alvar
Author(s): Scott Niekum
autogenerated on Sat Dec 28 2013 16:46:15