Blender.h
Go to the documentation of this file.
00001 /*
00002  * Blender.h
00003  *
00004  *  Created on: Jun 18, 2010
00005  *      Author: ethan
00006  */
00007 
00008 #ifndef BLENDER_H_
00009 #define BLENDER_H_
00010 
00011 #include <opencv2/core/core.hpp>
00012 
00013 #include <iostream>
00014 #include <vector>
00015 
00016 #include "pano_core/ModelFitter.h"
00017 #include "pano_core/ImageMolecule.h"
00018 #include "pano_core/Projector.h"
00019 #include "pano_core/callbacks.h"
00020 namespace pano
00021 {
00022 
00023 class Blender
00024 { // abstract blending class, to be overridden by various ones.
00025 public:
00026   virtual ~Blender()
00027   {
00028   }
00029 
00032   virtual void BlendMolecule(const ImageMolecule& mol, cv::Mat& outimage) = 0;
00033 
00036   virtual void BlendAtoms(const std::set<cv::Ptr<ImageAtom> >& atoms, cv::Mat& outimage) = 0;
00037 
00038 
00039 
00040   virtual void blendIncremental(const ImageAtom& image_atom, cv::Mat& outimage){ }
00041 
00042   static void fillWeightsGaussian32(cv::Mat& weights, float sigma_squared = 0.05);
00043 
00044   static void fillWeightsGaussian64(cv::Mat& weights, double sigma_squared = 0.02 );
00045 
00046   void set_image_path(const std::string&  path ) { image_path = path; }
00047 
00048 protected:
00049   std::string image_path;
00050 
00051 };
00052 
00053 
00054 class BlenderNoBlend : public Blender
00055 {
00056 public:
00057 
00058   virtual ~BlenderNoBlend();
00059 
00062   void BlendMolecule(const ImageMolecule& mol, cv::Mat& outimage);
00063 
00066   void BlendAtoms(const std::set<cv::Ptr<ImageAtom> >& atoms, cv::Mat& outimage)
00067   {
00068   }
00069 
00070 private:
00071 
00072 };
00073 
00074 class BlenderSimple : public Blender
00075 {
00076 public:
00077   BlenderSimple() ;
00078   virtual ~BlenderSimple();
00079 
00082   void BlendMolecule(const ImageMolecule& mol, cv::Mat& outimage);
00083 
00086   void BlendAtoms(const std::set<cv::Ptr<ImageAtom> >& atoms, cv::Mat& outimage)
00087   {
00088   }
00089 
00090 
00091   virtual void blendIncremental(const ImageAtom& image_atom, cv::Mat& outimage);
00092 
00093   CallbackEngine* cbe;
00094 
00095 private:
00096   SparseProjector projector;
00097 
00098   cv::Mat in_img;
00099   cv::Mat in_weight;
00100 
00101   std::string output_prefix;
00102 
00103   HugeImage huge_image_;
00104   void setInputSize(cv::Size size);
00105   void setOutputSize(cv::Size size);
00106 };
00107 
00108 void initAlphaMat(const cv::Size& sz, cv::Mat& alpha, int feather_width);
00109 
00110 class BlenderAlpha : public Blender
00111 {
00112 
00113 public:
00114   BlenderAlpha(int feather_edge = 30);
00115   BlenderAlpha(int feather_edge, cv::Size outputsize, cv::Size inputsize);
00116   virtual ~BlenderAlpha();
00117 
00120   void BlendMolecule(const ImageMolecule& mol, cv::Mat& outimage);
00121 
00122   void blendMolecule(const ImageMolecule& mol, cv::Size outputsize, const std::string& name_prefix);
00123 
00126   void BlendAtoms(const std::set<cv::Ptr<ImageAtom> >& atoms, cv::Mat& outimage)
00127   {
00128   }
00129 
00130   virtual void blendIncremental(const ImageAtom& image_atom, cv::Mat& outimage);
00131   CallbackEngine* cbe;
00132 
00133 private:
00134 
00135   int feather_edge;
00136   //generate the alpha mask
00137   cv::Mat alpha;
00138   cv::Size outputsize;
00139   cv::Size inputSize;
00140   SparseProjector projector;
00141 
00142   cv::Mat in_img;
00143   cv::Mat in_alpha;
00144   cv::Mat in_one_minus_alpha;
00145   cv::Mat one_minus_alpha;
00146 
00147   std::string output_prefix;
00148 
00149   HugeImage huge_image_;
00150   void setInputSize(cv::Size size);
00151   void setOutputSize(cv::Size size);
00152 };
00153 
00154 
00155 
00156 class BlenderMultiband : public Blender
00157 {
00158 public:
00159   BlenderMultiband() ;
00160   virtual ~BlenderMultiband();
00161 
00164   void BlendMolecule(const ImageMolecule& mol, cv::Mat& outimage);
00165 
00168   void BlendAtoms(const std::set<cv::Ptr<ImageAtom> >& atoms, cv::Mat& outimage)
00169   {
00170   }
00171 
00172   virtual void blendIncremental(const ImageAtom& image_atom, cv::Mat& outimage);
00173 
00174   CallbackEngine* cbe;
00175 
00176 private:
00177   SparseProjector projector;
00178 
00179   cv::Mat in_img;
00180   cv::Mat in_weight;
00181 
00182   std::string output_prefix;
00183 
00184   HugeImage huge_image_;
00185   void setInputSize(cv::Size size);
00186   void setOutputSize(cv::Size size);
00187 };
00188 
00189 
00190 
00191 
00192 }
00193 
00194 #endif /* BLENDER_H_ */


pano_core
Author(s): Ethan Rublee
autogenerated on Mon Mar 14 2016 10:56:54