How to read the text file and create Mat object in C++

后端 未结 4 1491
长发绾君心
长发绾君心 2021-01-13 13:45

Hi i have being able to write a Mat object in to a text file. As follows,

std::fstream outputFile;
    outputFile.open( \"myFile.txt\", std::ios::out ) ;

          


        
4条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-13 14:26

    it's probably far easier, to use the opencv FileStorage:

    // write:
    Mat m;
    FileStorage fs("myfile.txt",FileStorage::WRITE);
    fs << "mat1" << m;
    
    // read:
    FileStorage fs("myfile.txt",FileStorage::READ);
    fs["mat1"] >> m;
    

提交回复
热议问题