Ask Your Question

Revision history [back]

How do I load CSV files now?

With OpenCV 3.0, the ml module has been rewritten, I used to do

CvMLData data;
if(data.read_csv(path.c_str())==-1){
    printf("File %s cannot be opened\n", path.c_str());
    return false;
}
const CvMat *tmp = data.get_values();
m = cv::Mat(tmp,true);
m.convertTo(m,type);
cv::resize(m,m,cv::Size(ncol,nrow));
tmp->CvMat::~CvMat();

What do I do now to load CSV files into a Mat?