I'm working on face recognition in Qt & openCV using the FisherFaces recognizer which doesn't support updating so i have to save the faces database to retrain the recognizer after any changes.
Here is my code for saving :
save(const std::vector* MatVect){
QFile file("students_dataset.dat");
file.open(QIODevice::WriteOnly);
QDataStream out(&file);
QVector qimgvect;
for (size_t i = 0; i < MatVect->size(); ++i)
{
cv::Mat matt = MatVect->at(i);
QImage img((uchar*)matt.data, matt.cols, matt.rows, matt.step, QImage::Format_Indexed8);
qimgvect.push_back(img);
}
out << qimgvect ;
file.flush();
file.close();
}
and this is for loading :
load(std::vector* MatVect)
{
QFile file("students_dataset.dat");
file.open(QIODevice::ReadOnly);
QDataStream in(&file);
QVector qimgvect;
in >> qimgvect;
for (size_t i = 0; i < qimgvect.size(); ++i)
{
QImage img = qimgvect.at(i);
cv::Mat matt = cv::Mat(70, 70, CV_8U, img.bits(), img.bytesPerLine());
MatVect->push_back(matt);
}
file.close();
return;
}
the problem is that what I read back from the file is not what i saved

so what's exactly wrong in this code (hope not all of it ) ?
is there a better/easier way of saving the vector ?
EDIT :
thanks to Marek_R the conversion part is fixed, but saving and loading with QDataStream is the problem now :
so what's causing those lines ?
EDIT :
I have tried this :
made QimgVect
public and elemenated QDataStream part : MatVect-> QimgVect than QimgVect->MatVect and it did work fine, but after adding QDataStream : MatVect-> QimgVect->QDataStream and QDataStream->QimgVect->MatVect i get get the result shown above( vertical white lines ).
EDIT
converting the image from RGB32 to Indexed8 after reading from qdatastream gives the following result :