New repo for repo.or.cz
[The-Artvertiser.git] / garfeild / lightcalib / lightcollector.h
blob65381f6eefecef4d39ac684b02010e1cb39d6b80
1 /*
2 Copyright 2005, 2006 Computer Vision Lab,
3 Ecole Polytechnique Federale de Lausanne (EPFL), Switzerland.
4 Modified by Damian Stewart <damian@frey.co.nz> 2009-2010;
5 modifications Copyright 2009, 2010 Damian Stewart <damian@frey.co.nz>.
7 Distributed under the terms of the GNU General Public License v3.
9 This file is part of The Artvertiser.
11 The Artvertiser is free software: you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation, either version 3 of the License, or
14 (at your option) any later version.
16 The Artvertiser is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
21 You should have received a copy of the GNU Lesser General Public License
22 along with The Artvertiser. If not, see <http://www.gnu.org/licenses/>.
26 #ifndef _LIGHTCOLLECTOR_H
27 #define _LIGHTCOLLECTOR_H
29 #include <cv.h>
31 class LightMap;
33 /*!
34 * \ingroup photocalib
35 * Collects lighting clues. This class apply an homography to a planar mesh and
36 * average colors within triangles. The LightMap class can use these measures
37 * to estimate a radiance map.
39 class LightCollector {
40 public:
41 LightCollector();
42 LightCollector(const LightCollector &lc);
43 ~LightCollector();
44 const LightCollector &operator=(LightCollector &lc);
45 void copy(const LightCollector &lc);
47 //! Generate a regular grid given its 4 corners.
48 bool genGrid(float corners[4][2], int nx, int ny);
50 void averageImage(IplImage *im, CvMat *_homography);
52 int serializeSize();
53 void serialize(char *buffer);
54 void load(const char *buffer, int size);
55 void invalidate();
57 // for debugging
58 void drawGrid(IplImage *im, CvMat *_homography);
59 void drawAvg(IplImage *im);
61 CvMat *worldRT;
63 bool cmpWithRef(const LightCollector &ref, float *val, const float *scale=0, const float *shift=0);
65 //friend LightMap;
66 //private:
67 float *avg;
68 CvMat *vertices, *transformed;
69 int *triangles;
70 int nbTri;
71 int nx, ny;
72 int avgChannels;
73 int nbPix;
76 #endif