/**
* 读取文件数据到vector中
* 正常的RGB文件
* @param file_name 文件名
*/
std::vector<uint8_t> read_file(const std::string &file_name)
{
int begin, end;
std::ifstream file(file_name, std::ios::in | std::ios::binary);
if (!file)
{
LOG(FATAL) << "input file " << file_name << " not found";
exit(-1);
}
begin = file.tellg();
file.seekg(0, std::ios::end);
end = file.tellg();
size_t len = end - begin;
LOG(INFO) << "len: " << len;
std::vector<uint8_t> img_bytes(len);
file.seekg(0, std::ios::beg);
file.read(reinterpret_cast<char *>(img_bytes.data()), len);
return img_bytes;
}
|