Beispiel #1
0
void BenchMarkLatex::saveData2Csv(CMat &_value1d, CStr csvFile, vecS &rowStart)
{
	Mat value1d = _value1d.reshape(1);
	FILE *f = fopen(_S(csvFile), "w");
	CV_Assert(f != NULL && value1d.type() == CV_64FC1);
	for (int r = 0; r < value1d.rows; r++)	{
		const double *v = value1d.ptr<double>(r);
		fprintf(f, "\n%s", _S(rowStart[r]));
		for (int c = 0; c < value1d.cols; c++)	
			fprintf(f, ", %5.3f", v[c]);
	}
	fclose(f);
}
Beispiel #2
0
void BenchMarkLatex::printMat(CMat &_mat1d, CStr texFile, bool descendOrder)
{
	FILE* f = fopen(_S(texFile), "w");
	if (f == NULL){
		printf("Can't open file %s\n", _S(texFile));
		return;
	}
	CV_Assert(_mat1d.rows == _numMethod);

	Mat mat1d = _mat1d.reshape(1);
	int dataWidth = mat1d.cols;
	string strAlign = "|l||";
	for (int i = 0; i < _mat1d.cols; i++){
		for (int c = 0; c < _mat1d.channels(); c++)
			strAlign += "c";
		strAlign += "|";
	}
	fprintf(f, "\\begin{tabular}{%s} \\hline\n\t\\tabTitle \\\\", _S(strAlign));
	const char* rankCommand[3] = {"\\first", "\\second", "\\third"};
	Mat rnk1i = getRankIdx(mat1d, descendOrder);
	for (int i = 0; i < _numMethod; i++){
		if (find(_subNumbers.begin(), _subNumbers.end(), i) != _subNumbers.end())
			fprintf(f, "\t\\hline \\hline\n");
		fprintf(f, "\t\\textbf{%-5s ", _S(_methodNames[i] + "}"));
		for (int j = 0; j < dataWidth; j++){
			int idx = rnk1i.at<int>(i, j);
			if (idx < 3)
				fprintf(f, "& %s{%5.3f} ", rankCommand[idx], mat1d.at<double>(i, j));
			else
				fprintf(f, "& %5.3f ", mat1d.at<double>(i, j));
		}
		fprintf(f, "\\\\\n");
	}
	fprintf(f, "\\hline\n\\end{tabular}\n");

	fclose(f);
}