I'm trying to read sequence of YAML files and reshape them in a single row then trying to concatenate in a single YAML file. Here is my snap of code:
for (int i = 1; i <= 6; i++ )
{
sprintf_s(filename, "VocabularyLBP/Dictionary%d.yml", i);
Mat feature;// , labels);;// = Mat::zeros(1, 100, CV_32FC1);
FileStorage fs(filename, FileStorage::READ);
fs["vocabulary"] >> feature;
feature.convertTo(feature, CV_32FC1);
feature = feature.reshape(1, 1);
trainData.push_back(feature);
FileStorage fs1("trainData.yml", FileStorage::WRITE);
fs1 << "vocabulary" << trainData;
}
I'm not getting error, but getting data like:
---
vocabulary: !!opencv-matrix
rows: 6
cols: 7800
dt: f
data: [ -1.32703932e-03, -1.32703932e-03, -1.32703932e-03,
-1.32703932e-03, -1.32703932e-03, -1.32703932e-03,
-1.32703932e-03, -1.32703932e-03, -1.32703932e-03,
%YAML:1.0
-1.32703932e-03, -1.32703932e-03, -1.32703932e-03,
-1.32703932e-03, -1.32703932e-03, -1.32703932e-03,
-1.32703932e-03, -1.32703932e-03, -1.32703932e-03,........
What am I doing wrong here? Why do each row and column have the same value?
my data was like Data1
%YAML:1.0
Vocabulary: !!opencv-matrix
rows: 100
cols: 78
dt: f
data: [ 5.49666524e-001, 5.66434860e-001, 4.44352776e-001,
3.23528647e-001, 2.49731302e-001, 9.43774283e-002,
8.07617828e-002, 1.17960289e-001, 6.93683475e-002,....
data2:
%YAML:1.0
Vocabulary: !!opencv-matrix
rows: 100
cols: 78
dt: f
data: [ 1.19325793e+000, 1.14433956e+000, 1.22386146e+000,
1.20958960e+000, 1.75026524e+000, 5.27490759e+000,......
data3:
%YAML:1.0
Vocabulary: !!opencv-matrix
rows: 100
cols: 78
dt: f
data: [ 3.21339786e-001, 2.84904152e-001, 2.93418944e-001,
2.12616310e-001, 1.51279286e-001, 1.42454490e-001,
1.66635603e-001,...........
etc.
Why am I not properly getting data in a single file? What is wrong in my code? Why is my code copying -1.32703932e-03 in all 7800 columns and 6 rows?