Esempio n. 1
0
// Write matrix to binary file
bool CmFile::matWrite(CStr& filename, CMat& _M){
	Mat M;
	_M.copyTo(M);
	FILE* file = fopen(_S(filename), "wb");
	if (file == NULL || M.empty())
		return false;
	fwrite("CmMat", sizeof(char), 5, file);
	int headData[3] = {M.cols, M.rows, M.type()};
	fwrite(headData, sizeof(int), 3, file);
	fwrite(M.data, sizeof(char), M.step * M.rows, file);
	fclose(file);
	return true;
}
Esempio n. 2
0
// Write matrix to binary file
bool Objectness::matWrite(CStr& filename, CMat& _M) {
    Mat M;
    _M.copyTo(M);
    FILE* file = fopen(_S(filename), "wb");
    if (file == NULL || M.empty())
        return false;
    fwrite("CmMat", sizeof(char), 5, file);
    int headData[3] = {M.cols, M.rows, M.type()};
    fwrite(headData, sizeof(int), 3, file);
    fwrite(M.data, sizeof(char), M.step * M.rows, file);
    fclose(file);

    FileStorage fs(filename + ".yml.gz", FileStorage::WRITE);
    fs << removeExtension(basename(filename)) << M;
    fs.release();

    return true;
}