ReconKhCam.h

Go to the documentation of this file.
00001 // ----------------------------------------------------------------------------
00002 //
00003 // $Id$
00004 //
00005 // Copyright 2008, 2009, 2010, 2011, 2012  Antonio Franchi and Paolo Stegagno
00006 //
00007 // This file is part of MIP.
00008 //
00009 // MIP is free software: you can redistribute it and/or modify
00010 // it under the terms of the GNU General Public License as published by
00011 // the Free Software Foundation, either version 3 of the License, or
00012 // (at your option) any later version.
00013 //
00014 // MIP is distributed in the hope that it will be useful,
00015 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017 // GNU General Public License for more details.
00018 //
00019 // You should have received a copy of the GNU General Public License
00020 // along with MIP. If not, see <http://www.gnu.org/licenses/>.
00021 //
00022 // Contact info: antonio.franchi@tuebingen.mpg.de stegagno@diag.uniroma1.it
00023 //
00024 // ----------------------------------------------------------------------------
00025 
00026 #ifndef __RECON_KH_CAM_H_
00027 #define __RECON_KH_CAM_H_
00028 
00029 //#ifdef _CH_
00030 //#pragma package <opencv>
00031 //#endif
00032 
00033 //#define CV_NO_BACKWARD_COMPATIBILITY
00034 #define Max_khepera 5                                                           // max number of khepera in view
00035 #define focal 380.95                                                                 // must be in pixel !!
00036 //#define focal 347.83                                                                 // must be in pixel !!
00037 
00038 //#ifndef _EiC
00039 
00040 // #include <cv.h>
00041 // #include <highgui.h>
00042 
00043 #include "opencv2/imgproc/imgproc.hpp"
00044 #include <opencv2/imgproc/imgproc_c.h>
00045 // #include "opencv2/opencv.hpp"
00046 
00047 #include <stdio.h>
00048 #include <stdlib.h>
00049 #include <ctype.h>
00050 #include <vector>
00051 #include <iostream>
00052 #include <sys/time.h>
00053 #include "MIPMatrix.h"
00054 #include <Camera.h>
00055 //#endif
00056 
00057 using namespace std;
00058 
00059 class ReconKhCamVar{
00060  public:     IplImage *image, *hsv, *hue, *sat,*mask, *backproject,
00061               *histimg, *mask_sat, *backproject2,*total,*total2;
00062           
00063           CvHistogram *hist_hue,*hist_sat;
00064           
00065           int select_object;
00066           int track_object;
00067           CvPoint origin;
00068           CvRect selection;
00069           CvRect track_window;
00070           CvBox2D track_box;
00071           CvConnectedComp track_comp;
00072           CvMemStorage* contorni;
00073           
00074           // histogram vars
00075           //float hranges_arr[2];
00076           //float* hranges;
00077           //Decimal range_sat_val[2];
00078           //Decimal *range_sat;
00079           int hdims;
00080           int vmin, vmax, smin;
00081           int init_hist;
00082           
00083           // print rectangles vars
00084           int prime[Max_khepera];
00085           CvRect past_rects[Max_khepera];
00086           int pauses_spa[Max_khepera];                                                    // pause due changing rectangle position
00087           int pauses_dim[Max_khepera];                                                    // pause due changing rectangle dimension
00088           CvFont fonti;
00089           CvSeq* contours;
00090           
00091           //CvCapture* capture;
00092           // time variables
00093           struct timeval start, stop;
00094           Decimal temp;
00095           
00096           
00097           
00098           // output of bearing
00099           vector <Decimal> vect_out;
00100           
00101           ReconKhCamVar(){ image = 0, hsv = 0, hue = 0, sat = 0,mask = 0, backproject = 0,
00102                   histimg = 0, mask_sat = 0, backproject2 = 0,total = 0,total2 = 0;
00103                   hist_hue = 0,hist_sat = 0;
00104                   select_object = 0;
00105                   track_object = 0;
00106                   // range_sat_val[0] = 0;
00107                   // range_sat_val[1] = 256;
00108                   // range_sat = range_sat_val;
00109                   hdims = 16;
00110                   vmin = 51;
00111                   vmax = 200;
00112                   smin = 30;
00113                   for(int con=0; con<Max_khepera;con++)
00114                   {prime[con] = 1;}
00115                   cvInitFont(&fonti,CV_FONT_HERSHEY_SIMPLEX,1.0f,1.0f,0.0f,1,8);              // font to print rectangle numbers
00116                   //capture = 0;
00117                   temp = 0;
00118                   contorni = cvCreateMemStorage(0);
00119                   init_hist = -1;
00120                   contours = 0;
00121                  }
00122 
00123 };
00124 
00125 class ReconKhCamPar {
00126   private:
00127     Decimal _focal;
00128   
00129   public:
00131     ReconKhCamPar();
00132     
00134     ReconKhCamPar(Decimal fc);
00135     
00137     ReconKhCamPar(const ReconKhCamPar &A);
00138     
00140     ReconKhCamPar operator=(ReconKhCamPar A);
00141     
00143     
00144     Decimal getFocal() {
00145       return _focal;
00146     }
00147   };
00148 
00149 class ReconKhCam{
00150  private:
00151       ReconKhCamVar* _var;
00152       ReconKhCamPar  *_par;
00153     public:
00154       /*Default constructor*/
00155       ReconKhCam(){
00156     _var = new ReconKhCamVar;
00157                 _par = new ReconKhCamPar();
00158            }
00159       /*Default deconstructor*/
00160       ~ReconKhCam(){
00161              delete _var;
00162              delete _par;
00163             }
00164     
00165     void object_print(CvSeq *sequence,int ind,IplImage *imag, CvFont* font);
00166     
00167     void setDisplay();
00168     
00169     void closeDisplay();
00170     
00171     //bool step(IplImage *frame);
00172     //vector<Decimal> step(IplImage *frame);
00173     bool step(IplImage *frame,vector<Decimal> &ris);
00174 };
00175 
00176 #endif

Generated on Mon Feb 20 07:01:06 2017 for MIP by  doxygen 1.5.6