CvMLData broken in openCV 2.4 (Bug #1962)
in my project I was using CvMLData.read_csv from version 2.31 to parse a .csv file. When I switched to 2.4 precompiled static libraries for Windows x86 included in the last package the CvMLData.get_values methods always return 0. Please note that I tried the same code on the same .csv and while 2.3.1 returns some thousands of rows, with 2.4 just return 0!
The code I used is the following
CvMLData csvReader = CvMLData();
Mat data = csvReader.get_values();
cout << "Rows " << data.rows << "\n";
in attach the sp500.csv to parse which works on 2.3.1 and fails with 2.4
Marco, thank you for the report. The problem is that the table stored in your file has a header. We don't support a files with a header in 2.4. Yes, it is wrong that we did not mentioned about this in the documentation, sorry. Even though you got nonzero number of samples (data.rows) with 2.3.1 it also was incorrect beacuse the first line (header) was considered as a sample too. As the header elements are not a numbers, you had to get all the variables are categorical (if you used MLData::get_var_types()), which is also incorrect.
The changes of 2.4, due to which you have a different behavior, are not a problem for the table without a header. So we left them, but added a support of a table header in r8391 for you :) You should update opencv to this revision and set the number of header lines using MLData::set_header_lines_number().
CvMLData csvReader; csvReader.set_header_lines_number(1); csvReader.read_csv("c:/sp500.csv"); cv::Mat data = csvReader.get_values();
The other way to solve your problem with 2.4 is just to remove the header lines from your file manually. And you need not update your opencv in the last case.
- Status changed from Open to Done
- Assignee changed from Vadim Pisarevsky to Maria Dimashova