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:
but I get this image:
rotate() function is used to rotate an image by an angle in Python.
We can rotate a given image using OpenCV in two ways. One is using the cv. rotate() function and other is using cv2. getRotationMatrix2D() function.
The length of the longest side determines the orientation. For example, if the height of the image is longer than the width, it is a “portrait” format. Images where the width is longer are called “landscape.”
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With