ccd.h
Go to the documentation of this file.
00001 // Software License Agreement (BSD License)
00002 // 
00003 //   Copyright (c) 2011, Shulei Zhu <schuleichu@gmail.com>
00004 //   All rights reserved.
00005 // 
00006 //   Redistribution and use in source and binary forms, with or without
00007 //   modification, are permitted provided that the following conditions
00008 //   are met:
00009 // 
00010 //    * Redistributions of source code must retain the above copyright
00011 //      notice, this list of conditions and the following disclaimer.
00012 //    * Redistributions in binary form must reproduce the above
00013 //      copyright notice, this list of conditions and the following
00014 //      disclaimer in the documentation and/or other materials provided
00015 //      with the distribution.
00016 //    * Neither the name of Shulei Zhu nor the names of its
00017 //      contributors may be used to endorse or promote products derived
00018 //      from this software without specific prior written permission.
00019 // 
00020 //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00021 //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00022 //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
00023 //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
00024 //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
00025 //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
00026 //   BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
00027 //   LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
00028 //   CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00029 //   LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
00030 //   ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00031 //   POSSIBILITY OF SUCH DAMAGE.
00032 // 
00033 // 
00034 // ccd.h --- 
00035 // File            : ccd.h
00036 // Created: Sa Jun 18 14:06:36 2011 (+0200)
00037 // Author: Shulei Zhu
00038 // 
00039 // Code:
00040 
00041 
00042 
00043 /* 
00044  * #pragma warning (disable:981)        
00045  * #pragma warning (disable:383)
00046  * #pragma warning (disable:15)
00047  */
00048 struct CCDParams
00049 {
00050  CCDParams(): gamma_1(0.5), gamma_2(4), gamma_3(4), gamma_4(3),alpha(1.3), beta(0.06), kappa(0.5),c(0.25), h(40), delta_h(1),resolution(100), degree(4), phi_dim(8)
00051   {
00052   }
00053   CCDParams(double p1,
00054             double p2,
00055             double p3,
00056             double p4,
00057             double p5,
00058             double p6,
00059             double p7,
00060             double p8,
00061             int p9,
00062             int p10,
00063             int p11,
00064             int p12,
00065             int p13
00066             )
00067   {
00068     gamma_1 = p1;
00069     gamma_2 = p2;
00070     gamma_3 = p3;
00071     gamma_4 = p4;
00072     alpha = p5;
00073     beta = p6;
00074     kappa = p7;
00075     c = p8;
00076     h = p9;
00077     delta_h = p10;
00078     resolution = p11;
00079     degree = p12;
00080     phi_dim = p13;
00081   }
00082 
00083   ~CCDParams()
00084   {
00085   }
00086   double gamma_1;
00087   double gamma_2;
00088   double gamma_3;
00089   double gamma_4;
00090   double alpha;
00091   double beta;
00092   double kappa;
00093   double c;
00094   int h;
00095   int delta_h;
00096   int resolution;
00097   int degree;
00098   int phi_dim;
00099 };
00100 
00101 class CCD
00102 {
00103 public:
00104   cv::Mat image, canvas, tpl;
00105   std::vector<cv::Point3d> pts;
00106   /* 
00107    * CCD()
00108    * {
00109    *   Phi = cv::Mat::zeros(params_.phi_dim,1, CV_64F);
00110    *   Sigma_Phi = cv::Mat::zeros(params_.phi_dim,params_.phi_dim, CV_64F);
00111    *   delta_Phi = cv::Mat::zeros(params_.phi_dim,1, CV_64F);
00112    * }
00113    */
00114   void read_params( const std::string& filename);
00115   void init_mat();
00116   void run_ccd();
00117   double resolution(){return params_.resolution;}
00118   double degree(){return params_.degree;}
00119   /* inline void init_pts(int init_method); */
00120   void init_cov(BSpline &bs, int degree);
00121   ~CCD(){clear();}
00122 private:
00123   void clear();
00124   /* 
00125    * void contour_sift();
00126    * void contour_manually();
00127    */
00128   void local_statistics(BSpline &bs);
00129   void refine_parameters(BSpline &bs);
00130   /* void on_mouse( int event, int x, int y, int flags, void* param ); */
00131   CCDParams params_;
00132   cv::Mat vic;
00133   cv::Mat mean_vic;
00134   cv::Mat cov_vic;
00135   cv::Mat nv;
00136   cv::Mat Phi;
00137   cv::Mat Sigma_Phi;
00138   cv::Mat delta_Phi;
00139   cv::Mat bs_old;
00140   cv::Mat nabla_E;
00141   cv::Mat hessian_E;
00142 };
00143 
00144 /* 
00145  * inline void CCD::init_pts(int init_method)
00146  * {
00147  *   if(init_method == 1)
00148  *     contour_manually();
00149  *   else if(init_method == 2)
00150  *     contour_sift();
00151  *   if((int)pts.size() > params_.degree)
00152  *   {
00153  *     for (int i = 0; i < params_.degree; ++i)
00154  *       pts.push_back(pts[i]);
00155  *   }
00156  * }
00157  */
00158 
00159 /* void on_mouse(int event, int x, int y, int flags, void* param ); */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Friends Defines


contracting_curve_density_algorithm
Author(s): Shulei Zhu, Dejan Pangercic
autogenerated on Thu May 23 2013 14:41:45