zakjma
zakjma

Reputation: 2110

opencv - imread returns false size

I have a 720x1280 image. I try to load ans show it. But I see 90 degree rotated image(1280x720).

My simple code is :

cout << "Size = " << imread(fileName).size() << endl;

The result is :

Size = [1280x720]

enter image description here

How can I load and show big size image using opencv? I use opencv 2.4.10.

Upvotes: 1

Views: 516

Answers (1)

morotspaj
morotspaj

Reputation: 1420

The image is probably encoded that way. Smartphones typically encode images the same direction every time regardless of how it is held but will add meta data to the image so that the viewing program can show it the intended way. OpenCV does not take this meta data into account. You can rotate the image yourself though. (Use 1 instead of 0 if the image becomes upside down).

cv::transpose(image, image);
cv::flip(image, image, 0);

If you prefer to modify the image on disk instead you can use gimp. Simply open the image and save/export it. Gimp will use the meta data when opening the image but re-encode the image without it.

Upvotes: 2

Related Questions