utils.hpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00015 #ifndef UTILS_HPP
00016 #define UTILS_HPP
00017
00018 using namespace cv;
00019 using namespace std;
00020
00021
00022
00028 template <typename T>
00029 bool inp_minbnd(Mat &mtx, T minval) {
00030 Size sz = mtx.size();
00031 bool retval = false;
00032 for (int i=0; i<sz.height; i++) {
00033 T* ptr = mtx.ptr<T>(i);
00034 for (int j=0; j<sz.width; j++) {
00035 if (ptr[j] < minval) {
00036 ptr[j] = minval;
00037 retval = true;
00038 }
00039 }
00040 }
00041 return retval;
00042 };
00043
00045 void dumpMatSize(const Mat &m);
00046
00050 void scaleRows(Mat &m, const Mat &w);
00051
00055 void scaleCols(Mat &m, const Mat &w);
00056
00058 ostream& operator <<(ostream &output, const Range &r);
00059
00063 void timer_start();
00064
00068 double timer_stop();
00069
00073 void timer_print();
00074
00080 void timerOn();
00081
00085 int timerOff();
00086
00090 void timerPrint();
00091
00092
00093
00097 void strtok2(string str, string del,string& key, string& valuestr);
00098
00101 int checkOptionInStr(string str,string opt);
00102
00103
00104
00105 OPT_F_TYPE computeVariance3dDouble(Mat input);
00106
00107 template<class T>
00108 double meanOfStdVector(std::vector<T> input)
00109 {
00110 T sum=(T)0;
00111 for(int i=0;i<input.size();i++)
00112 sum=sum+input[i];
00113
00114 double mean=sum/input.size();
00115 return mean;
00116 }
00117
00118 template<class T>
00119 T minOfStdVector(std::vector<T> input)
00120 {
00121 T min=input[0];
00122 for(int i=1;i<input.size();i++)
00123 {
00124 if(input[i]<min)
00125 min=input[i];
00126 }
00127 return min;
00128 }
00129
00130 void matlabSVD(Mat X,Mat &U, Mat &S, Mat &V);
00131
00132 char* readMatrix(char *mptr,Mat &mtx);
00133 char* writeMatrix(char *mptr,Mat &mtx);
00134
00135 Mat eigc(Mat &X);
00136 Mat eigc_abs(Mat &W);
00137
00138 void exitWithError(const std::string &error);
00139 #endif