1 | initial version |
This is actually the answer of @berak, but their post disappeared...
One should only convert the .wS1 (etc) model files into .wS1.yml.gz. It is possible with the following code:
bool matRead(const string& filename, Mat& _M){
FILE* f = fopen(filename, "rb");
if (f == NULL)
return false;
char buf[8];
int pre = fread(buf,sizeof(char), 5, f);
if (strncmp(buf, "CmMat", 5) != 0) {
printf("Invalidate CvMat data file %s\n", filename);
return false;
}
int headData[3]; // Width, height, type
fread(headData, sizeof(int), 3, f);
Mat M(headData[1], headData[0], headData[2]);
fread(M.data, sizeof(char), M.step * M.rows, f);
fclose(f);
M.copyTo(_M);
return true;
}
int main(int argc, char**argv) {
cv::String node = argv[1];
cv::String ext = argv[2];
Mat m;
if (matRead(node + ext, m)) {
FileStorage fs(node + ext + ".yml.gz", 1);
fs << node << m;
fs.release();
return 0;
}
return 1; // fail
}