1 | initial version |
even if you're using some outdated opencv2.4 version, try to avoid c-based datastructures, like CvMat
, IplImage
, CvMlData
, and such.
then, while CvMlData can be used for numerical data, it won't work with strings at all.
try with vector<string>
, and something manual:
vector<string> names;
vector<int> ids;
int id;
char sep;
string name;
ifstream csv("asd.csv")
while(csv.good() && (csv >> id >> sep >> name)) {
ids.push_back(id);
names.push_back(name);
}
2 | No.2 Revision |
even if you're using some outdated opencv2.4 version, try to avoid c-based datastructures, like CvMat
, IplImage
, CvMlData
, and such.
then, while CvMlData can be used for numerical data, it won't work with strings at all.
try with vector<string>
, and something manual:
vector<string> names;
vector<int> ids;
int id;
char sep;
string name;
ifstream csv("asd.csv")
csv("asd.csv");
getline(csv, name); // skip header line
while(csv.good() && (csv >> id >> sep >> name)) {
ids.push_back(id);
names.push_back(name);
}