Image Orientation (python+openCV)

yuanyesjtu picture yuanyesjtu · Jun 14, 2017 · Viewed 8.2k times · Source

Using Python and OpenCV, I try to read an image which size is (3264*2448), but the resulting size is always (2448*3264). That means the direction of the image is changed by 90 degrees. The code is following:

img1 = cv2.imread("C:\\Users\\test.jpg", 0) 
cv2.namedWindow("test", 0) 
cv2.imshow("test", img1)

the orignal image is this:

enter image description here

but I get this image:

enter image description here

Answer

Akshay Mhapankar picture Akshay Mhapankar · Aug 11, 2017

I faced a similar issue in one program. In my case, the problem was due to the camera orientation data stored in the image.

The problem was resolved after I used CV_LOAD_IMAGE_COLOR instead of CV_LOAD_IMAGE_UNCHANGED in OpenCV Java.