From 33d23ef27aeda069aa9cb1adce19cab1f7e4688b Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Sat, 4 Dec 2010 18:37:07 +0000 Subject: [PATCH] fixed several typos in docs; make MLData capable of reading csv files with much more columns than before --- doc/core_basic_structures.tex | 4 ++-- doc/core_drawing_functions.tex | 16 ++++++++-------- doc/core_introduction.tex | 2 +- doc/core_utilities_system_functions.tex | 14 +++++++------- doc/video_motion_tracking.tex | 10 +++++----- modules/ml/src/data.cpp | 9 ++++----- 6 files changed, 27 insertions(+), 28 deletions(-) diff --git a/doc/core_basic_structures.tex b/doc/core_basic_structures.tex index dc8bcd99e6..23c8e7ab4e 100644 --- a/doc/core_basic_structures.tex +++ b/doc/core_basic_structures.tex @@ -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. -\cvCppFunc{reshape} +\cvCppFunc{Mat::reshape} Changes the 2D matrix's shape and/or the number of channels without copying the data. \cvdefCpp{ @@ -1758,7 +1758,7 @@ Mat pointMat = Mat(vec). // convert vector to Mat, O(1) operation \end{lstlisting} -\cvCppFunc{Mat::t()} +\cvCppFunc{Mat::t} Transposes the matrix \cvdefCpp{ diff --git a/doc/core_drawing_functions.tex b/doc/core_drawing_functions.tex index 37dfe72114..cce9b596b6 100644 --- a/doc/core_drawing_functions.tex +++ b/doc/core_drawing_functions.tex @@ -725,18 +725,18 @@ public: // from the left-most point to the right most, // not to depend on the ordering of pt1 and pt2 parameters 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 - uchar* operator *();newline + uchar* operator *(); // move the iterator to the next pixel - LineIterator& operator ++();newline - LineIterator operator ++(int);newline + LineIterator& operator ++(); + LineIterator operator ++(int); // internal state of the iterator - uchar* ptr;newline - int err, count;newline - int minusDelta, plusDelta;newline - int minusStep, plusStep;newline + uchar* ptr; + int err, count; + int minusDelta, plusDelta; + int minusStep, plusStep; }; \end{lstlisting} diff --git a/doc/core_introduction.tex b/doc/core_introduction.tex index a003c5ec67..7bb4d15387 100644 --- a/doc/core_introduction.tex +++ b/doc/core_introduction.tex @@ -183,7 +183,7 @@ void drawCircle(Mat &image, int R, Point center) } \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: \begin{lstlisting} diff --git a/doc/core_utilities_system_functions.tex b/doc/core_utilities_system_functions.tex index 5c87023c57..b113bf78d1 100644 --- a/doc/core_utilities_system_functions.tex +++ b/doc/core_utilities_system_functions.tex @@ -646,18 +646,18 @@ public: // various constructors and the copy operation Exception() { code = 0; line = 0; } Exception(int _code, const string& _err, - const string& _func, const string& _file, int _line);newline - Exception(const Exception& exc);newline - Exception& operator = (const Exception& exc);newline + const string& _func, const string& _file, int _line); + Exception(const Exception& exc); + Exception& operator = (const Exception& exc); // the error code - int code;newline + int code; // the error text message - string err;newline + string err; // function name where the error happened - string func;newline + string func; // the source file name where the error happened - string file;newline + string file; // the source file line where the error happened int line; }; diff --git a/doc/video_motion_tracking.tex b/doc/video_motion_tracking.tex index 5862fe8c6a..84d1d0088a 100644 --- a/doc/video_motion_tracking.tex +++ b/doc/video_motion_tracking.tex @@ -905,14 +905,14 @@ Kalman filter class class KalmanFilter { public: - KalmanFilter();newline - KalmanFilter(int dynamParams, int measureParams, int controlParams=0);newline - void init(int dynamParams, int measureParams, int controlParams=0);newline + KalmanFilter(); + KalmanFilter(int dynamParams, int measureParams, int controlParams=0); + void init(int dynamParams, int measureParams, int controlParams=0); // 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 // 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)): // x(k)=A*x(k-1)+B*u(k) diff --git a/modules/ml/src/data.cpp b/modules/ml/src/data.cpp index 86493a0662..8e52d71b3e 100644 --- a/modules/ml/src/data.cpp +++ b/modules/ml/src/data.cpp @@ -139,14 +139,13 @@ 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' }; FILE* file = 0; CvMemStorage* storage; CvSeq* seq; - char *buf; char *ptr; float* el_ptr; CvSeqReader reader; @@ -161,7 +160,8 @@ int CvMLData :: read_csv(const char* filename) return -1; // read the first line and determine the number of variables - buf = new char[M]; + std::vector _buf(M); + char* buf = &_buf[0]; if( !fgets_chomp( buf, M, file )) { fclose(file); @@ -242,7 +242,6 @@ int CvMLData :: read_csv(const char* filename) cvReleaseMemStorage( &storage ); delete []el_ptr; - delete []buf; return 0; } -- GitLab