Added the images for test.
[pom.git] / pom_solver.h
1
2 //////////////////////////////////////////////////////////////////////////////////
3 // This program is free software: you can redistribute it and/or modify         //
4 // it under the terms of the version 3 of the GNU General Public License        //
5 // as published by the Free Software Foundation.                                //
6 //                                                                              //
7 // This program is distributed in the hope that it will be useful, but          //
8 // WITHOUT ANY WARRANTY; without even the implied warranty of                   //
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU             //
10 // General Public License for more details.                                     //
11 //                                                                              //
12 // You should have received a copy of the GNU General Public License            //
13 // along with this program. If not, see <http://www.gnu.org/licenses/>.         //
14 //                                                                              //
15 // Written by Francois Fleuret                                                  //
16 // (C) Ecole Polytechnique Federale de Lausanne                                 //
17 // Contact <pom@epfl.ch> for comments & bug reports                             //
18 //////////////////////////////////////////////////////////////////////////////////
19
20 #ifndef POM_SOLVER_H
21 #define POM_SOLVER_H
22
23 #include "misc.h"
24 #include "integral_proba_view.h"
25 #include "normal_law.h"
26 #include "room.h"
27
28 class POMSolver {
29
30   // At each pixel the proba for the pixel to be off
31
32   ProbaView neg;
33
34   // At each pixel, 0 if the view is 0, and the proba for the pixel to
35   // be off if the view is 1 (or, more mathematically: neg * view)
36
37   ProbaView neg_view;
38
39   // Integral images to speed-up computation
40
41   IntegralProbaView ii_neg, ii_neg_view;
42
43   // Distribution of surface_difference / surface_synthetic
44
45   NormalLaw global_difference;
46
47   void compute_average_images(int camera,
48                               Room *room,
49                               Vector<scalar_t> *proba_absence);
50
51   // Adds to every sum[i] the value log(P(X_i = 1 | V_camera) / P(X_i
52   // = 0 | V_camera)), given the other P(X_j = 1 | V)
53
54   void add_log_ratio(int camera,
55                      Room *room,
56                      ProbaView *view,
57                      Vector<scalar_t> *proba_absence,
58                      Vector<scalar_t> *sum);
59
60 public:
61
62   POMSolver(Room *room);
63
64   // Uses the computation above for the various cameras and the prior
65   // to refresh proba_absence. Iterates as many times as
66   // specified. The two last parameters are used only to save images
67   // showing the convergence
68
69   void solve(Room *room,
70              Vector<scalar_t> *prior,
71              Vector<ProbaView *> *views,
72              Vector<scalar_t> *result_proba_presence,
73              int nb_frame,
74              char *convergence_file_format);
75 };
76
77 #endif