本文整理汇总了C++中FileUtils::ReadMatFile方法的典型用法代码示例。如果您正苦于以下问题:C++ FileUtils::ReadMatFile方法的具体用法?C++ FileUtils::ReadMatFile怎么用?C++ FileUtils::ReadMatFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileUtils
的用法示例。
在下文中一共展示了FileUtils::ReadMatFile方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadResponsesForTraining_new
void AnnHelper::LoadResponsesForTraining_new(std::vector<std::string> _files, cv::Mat& _response)
{
FileUtils futils;
MathUtils mathUtils;
MatUtils matutils;
Mat responses;
for (string filename : _files)
{
//获取图片信息文件路径
string fileinfo = filename.substr(0, filename.find_last_of('\\'));//目录
fileinfo += "\\training_data_new.txt";
//读取结果矩阵
vector<string> matNames;
vector<string> matStrs;
futils.ReadMatFile(matStrs, matNames, fileinfo);
assert(matStrs.size() > 0);
int bcodeIndex = 0;//数值矩阵
int bitIndex = 0;//位数矩阵
for (int i = 0; i < matNames.size(); i++)
{
if (matNames[i] == "code")
{
bcodeIndex = i;
}
if (matNames[i] == "bit")
{
bitIndex = i;
}
}
string bcode = "";
Mat decCodeMat = matutils.ToMat(matStrs[bcodeIndex]);
Mat bitMat = matutils.ToMat(matStrs[bitIndex]);
assert(decCodeMat.cols == bitMat.cols);
int bitNum=0;
int bit = 0;
for (int i = 0; i < decCodeMat.cols; i++)
{
bitNum = decCodeMat.at<float>(0, i);
bit = bitMat.at<float>(0, i);
bcode += mathUtils.ConvertToBinary(bitNum, bit);
}
stringstream ss;
Mat resMat(1, bcode.length(), CV_32F);
for (int i = 0; i < resMat.cols; i++)
{
ss << bcode[i];
float ib = 0.;
ss >> ib;
resMat.at<float>(0, i) = ib;
ss.clear();
}
matutils.AddMatRow(responses, resMat, responses);
}
_response = responses;
}
示例2: LoadResponsesForTraining
void AnnHelper::LoadResponsesForTraining(std::vector<string> _files, cv::Mat& _response)
{
FileUtils futils;
MatUtils matutils;
Mat responses;
for (string filename : _files)
{
//获取图片信息文件路径
string fileinfo = filename.substr(0, filename.find_last_of('\\'));//目录
fileinfo += "\\training_data.txt";
//读取结果矩阵
vector<string> matNames;
vector<string> matStrs;
futils.ReadMatFile(matStrs, matNames, fileinfo);
assert(matStrs.size()>0);
Mat response = matutils.ToMat(matStrs[0]);
matutils.AddMatRow(responses, response, responses);
}
_response = responses;
}