int maxlen=1024*1024;
std::vector<byte> buf;
FILE* f= fopen( "c:/f.jpg", "rb" );
string signature(maxlen, ' ');
maxlen = fread( &signature[0], 1, maxlen, f );
fclose(f);
buf.resize(maxlen);
signature = signature.substr(0, maxlen);
memcpy(&buf[0],&signature[0],maxlen);
cv::Mat ma = cv::imdecode(cv::Mat(buf),1);
imshow("",ma);
cvWaitKey(1000);