fixed several typos in docs; make MLData capable of reading csv files with much more columns than before

This commit is contained in:
Vadim Pisarevsky 2010-12-04 18:37:07 +00:00
parent 3e7fbd21e0
commit 33d23ef27a
6 changed files with 27 additions and 28 deletions

View File

@ -1725,7 +1725,7 @@ Mat\& Mat::setTo(const Scalar\& s, const Mat\& mask=Mat());
This is the advanced variant of \texttt{Mat::operator=(const Scalar\& s)} operator. This is the advanced variant of \texttt{Mat::operator=(const Scalar\& s)} operator.
\cvCppFunc{reshape} \cvCppFunc{Mat::reshape}
Changes the 2D matrix's shape and/or the number of channels without copying the data. Changes the 2D matrix's shape and/or the number of channels without copying the data.
\cvdefCpp{ \cvdefCpp{
@ -1758,7 +1758,7 @@ Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation
\end{lstlisting} \end{lstlisting}
\cvCppFunc{Mat::t()} \cvCppFunc{Mat::t}
Transposes the matrix Transposes the matrix
\cvdefCpp{ \cvdefCpp{

View File

@ -725,18 +725,18 @@ public:
// from the left-most point to the right most, // from the left-most point to the right most,
// not to depend on the ordering of pt1 and pt2 parameters // not to depend on the ordering of pt1 and pt2 parameters
LineIterator(const Mat& img, Point pt1, Point pt2, LineIterator(const Mat& img, Point pt1, Point pt2,
int connectivity=8, bool leftToRight=false);newline int connectivity=8, bool leftToRight=false);
// returns pointer to the current line pixel // returns pointer to the current line pixel
uchar* operator *();newline uchar* operator *();
// move the iterator to the next pixel // move the iterator to the next pixel
LineIterator& operator ++();newline LineIterator& operator ++();
LineIterator operator ++(int);newline LineIterator operator ++(int);
// internal state of the iterator // internal state of the iterator
uchar* ptr;newline uchar* ptr;
int err, count;newline int err, count;
int minusDelta, plusDelta;newline int minusDelta, plusDelta;
int minusStep, plusStep;newline int minusStep, plusStep;
}; };
\end{lstlisting} \end{lstlisting}

View File

@ -183,7 +183,7 @@ void drawCircle(Mat &image, int R, Point center)
} }
\end{lstlisting} \end{lstlisting}
\section{Namespace \texttt{cv} and Function Naming} \section{Namespace cv and Function Naming}
All the newly introduced classes and functions are placed into \texttt{cv} namespace. Therefore, to access this functionality from your code, use \texttt{cv::} specifier or \texttt{"using namespace cv;"} directive: All the newly introduced classes and functions are placed into \texttt{cv} namespace. Therefore, to access this functionality from your code, use \texttt{cv::} specifier or \texttt{"using namespace cv;"} directive:
\begin{lstlisting} \begin{lstlisting}

View File

@ -646,18 +646,18 @@ public:
// various constructors and the copy operation // various constructors and the copy operation
Exception() { code = 0; line = 0; } Exception() { code = 0; line = 0; }
Exception(int _code, const string& _err, Exception(int _code, const string& _err,
const string& _func, const string& _file, int _line);newline const string& _func, const string& _file, int _line);
Exception(const Exception& exc);newline Exception(const Exception& exc);
Exception& operator = (const Exception& exc);newline Exception& operator = (const Exception& exc);
// the error code // the error code
int code;newline int code;
// the error text message // the error text message
string err;newline string err;
// function name where the error happened // function name where the error happened
string func;newline string func;
// the source file name where the error happened // the source file name where the error happened
string file;newline string file;
// the source file line where the error happened // the source file line where the error happened
int line; int line;
}; };

View File

@ -905,14 +905,14 @@ Kalman filter class
class KalmanFilter class KalmanFilter
{ {
public: public:
KalmanFilter();newline KalmanFilter();
KalmanFilter(int dynamParams, int measureParams, int controlParams=0);newline KalmanFilter(int dynamParams, int measureParams, int controlParams=0);
void init(int dynamParams, int measureParams, int controlParams=0);newline void init(int dynamParams, int measureParams, int controlParams=0);
// predicts statePre from statePost // predicts statePre from statePost
const Mat& predict(const Mat& control=Mat());newline const Mat& predict(const Mat& control=Mat());
// corrects statePre based on the input measurement vector // corrects statePre based on the input measurement vector
// and stores the result to statePost. // and stores the result to statePost.
const Mat& correct(const Mat& measurement);newline const Mat& correct(const Mat& measurement);
Mat statePre; // predicted state (x'(k)): Mat statePre; // predicted state (x'(k)):
// x(k)=A*x(k-1)+B*u(k) // x(k)=A*x(k-1)+B*u(k)

View File

@ -141,12 +141,11 @@ static char *fgets_chomp(char *str, int n, FILE *stream)
int CvMLData::read_csv(const char* filename) int CvMLData::read_csv(const char* filename)
{ {
const int M = 50000; const int M = 1000000;
const char str_delimiter[3] = { ' ', delimiter, '\0' }; const char str_delimiter[3] = { ' ', delimiter, '\0' };
FILE* file = 0; FILE* file = 0;
CvMemStorage* storage; CvMemStorage* storage;
CvSeq* seq; CvSeq* seq;
char *buf;
char *ptr; char *ptr;
float* el_ptr; float* el_ptr;
CvSeqReader reader; CvSeqReader reader;
@ -161,7 +160,8 @@ int CvMLData :: read_csv(const char* filename)
return -1; return -1;
// read the first line and determine the number of variables // read the first line and determine the number of variables
buf = new char[M]; std::vector<char> _buf(M);
char* buf = &_buf[0];
if( !fgets_chomp( buf, M, file )) if( !fgets_chomp( buf, M, file ))
{ {
fclose(file); fclose(file);
@ -242,7 +242,6 @@ int CvMLData :: read_csv(const char* filename)
cvReleaseMemStorage( &storage ); cvReleaseMemStorage( &storage );
delete []el_ptr; delete []el_ptr;
delete []buf;
return 0; return 0;
} }