1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-31 00:03:03 +04:00

dnn(test): replace file content reading

This commit is contained in:
Alexander Alekhin
2019-05-29 15:29:31 +03:00
parent 0d477d7364
commit 52548bde05
5 changed files with 31 additions and 33 deletions
+7 -9
View File
@@ -158,23 +158,21 @@ void normAssertDetections(
testBoxes, comment, confThreshold, scores_diff, boxes_iou_diff);
}
bool readFileInMemory(const std::string& filename, std::string& content)
void readFileContent(const std::string& filename, CV_OUT std::vector<char>& content)
{
std::ios::openmode mode = std::ios::in | std::ios::binary;
const std::ios::openmode mode = std::ios::in | std::ios::binary;
std::ifstream ifs(filename.c_str(), mode);
if (!ifs.is_open())
return false;
ASSERT_TRUE(ifs.is_open());
content.clear();
ifs.seekg(0, std::ios::end);
content.reserve(ifs.tellg());
const size_t sz = ifs.tellg();
content.resize(sz);
ifs.seekg(0, std::ios::beg);
content.assign((std::istreambuf_iterator<char>(ifs)),
std::istreambuf_iterator<char>());
return true;
ifs.read((char*)content.data(), sz);
ASSERT_FALSE(ifs.fail());
}