将图片为二进制并解析为Mat格式

void getimages(char* pData, int size, )
{
	char *buffer;
	buffer = new char[size];
	void *achar = const_cast<void *>(pData);
	const char *tempData = static_cast<const char *>(achar );
	memcpy(buffer, tempData, size);
	vector<char> vdata(&buffer[0], &buffer[0] + size);
	Mat tmpImage = imdecode(vdata, cv::IMREAD_COLOR);
}

main()
{
string listpath[0] = "a.jpg";
 ifstream file(listpath[i].c_str(), ios::in | ios::binary);
 streampos length;
 cout << listpath[i].c_str() << endl;
 cout << s << endl;
 file.seekg(0, ios::end);
 length = file.tellg();
 file.seekg(0, ios::beg);
 char *buffer;
 buffer = new char[length];
 file.read(buffer, length);
 file.close();
 getimages(buffer, length);
}
读取二进制文件的代码
```cpp
std::ifstream file(engine_name, std::ios::binary);
		if (file.good()) {
			file.seekg(0, file.end);
			size = file.tellg();
			file.seekg(0, file.beg);
			trtModelStream = new char[size];
			assert(trtModelStream);
			file.read(trtModelStream, size);
			file.close();
		}