코드 4-15 파일로부터 데이터 불러오기 [ch04/storage]
01 void readData() 02 { 03 String name; 04 int age; 05 Point pt1; 06 vector<int> scores; 07 Mat mat1; 08 09 FileStorage fs(filename, FileStorage::READ); 10 11 if (!fs.isOpened()) { 12 cerr << "File open failed!" << endl; 13 return; 14 } 15 16 fs["name"] >> name; 17 fs["age"] >> age; 18 fs["point"] >> pt1; 19 fs["scores"] >> scores; 20 fs["data"] >> mat1; 21 22 fs.release(); 23 24 cout << "name: " << name << endl; 25 cout << "age: " << age << endl; 26 cout << "point: " << pt1 << endl; 27 cout << "scores: " << Mat(scores).t() << endl; 28 cout << "data:\n" << mat1 << endl; 29 }