'opencv 3.1.0 imread stunked, but imdecode is ok
I'm using opencv 3.1.0, tried to read an image by imread, just like
Mat image = cv::imread("1.jpg");
but it stunked without any error message (performs like in an endless loop)
I changed imread to imdecode, like this
cv::Mat readimage(const char* filename)
{
Mat image;
FILE *file = fopen(filename, "rb");
if (file == 0)
{
return image;
}
int len = 5000*5000*4;
char *imgData1 = new char[len];
int imgLen1 = fread(imgData1, 1, len, file);
vector<unsigned char> vecImgData(imgLen1);
memcpy(&(vecImgData[0]), imgData1, imgLen1);
image = cv::imdecode(vecImgData,1);
delete[] imgData1;
fclose(file);
return image;
}
Mat image = readimage("1.jpg");
and this try works well.
I just wonder what wrong with my picture? It's there something wrong when i use imread?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|