ReconKhCam.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #ifndef __RECON_KH_CAM_H_
00027 #define __RECON_KH_CAM_H_
00028
00029
00030
00031
00032
00033
00034 #define Max_khepera 5 // max number of khepera in view
00035 #define focal 380.95 // must be in pixel !!
00036
00037
00038
00039
00040
00041
00042
00043 #include "opencv2/imgproc/imgproc.hpp"
00044 #include <opencv2/imgproc/imgproc_c.h>
00045
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
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
00075
00076
00077
00078
00079 int hdims;
00080 int vmin, vmax, smin;
00081 int init_hist;
00082
00083
00084 int prime[Max_khepera];
00085 CvRect past_rects[Max_khepera];
00086 int pauses_spa[Max_khepera];
00087 int pauses_dim[Max_khepera];
00088 CvFont fonti;
00089 CvSeq* contours;
00090
00091
00092
00093 struct timeval start, stop;
00094 Decimal temp;
00095
00096
00097
00098
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
00107
00108
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);
00116
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
00155 ReconKhCam(){
00156 _var = new ReconKhCamVar;
00157 _par = new ReconKhCamPar();
00158 }
00159
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
00172
00173 bool step(IplImage *frame,vector<Decimal> &ris);
00174 };
00175
00176 #endif