Opencv – Python Görüntü döndürme

import cv2
import cv2 numpy as np
image=cv2.imread( ‘C:\\Users\\USER\\Desktop\\images\\elephant.jpg’)   #döndürmek istediğim görüntünün bilgisayarımda ki konumunu belirtiyorum.
height, width = image.shape[:2]   #Görüntüyü merkezin etrafında döndürmek için ikiye bölün.
rotation_matrix = cv2.getRotationMatrix2D((width/2, height/2), 90, .5)
rotated_image = cv2.warpAffine(image, rotation_matrix, (width, height))
cv2.imshow( ‘Rotated Image’, rotated_image)
cv2.waitKey()
cv2.destroyAllWindows()

 

  • Eğer görüntünün direk ekranda açılmasını istiyorsanız cv2.waitKey(0) komutunu kullanabiliriz.

 

 

import cv2
import cv2 numpy as np
image = cv2.imread( ‘C:\\Users\\USER\\Desktop\\images\\elephant.jpg’ #Tercihen ‘image’ yerine istediğiniz herhangi bir değer verebilirsiniz.
rotated_image = cv2.transpose(image)
cv2.imshow(‘Rotated Image – Method 2’, rotated_image)
cv2.waitKey(0)
cv2.destroyAllWindows()

 

 

 

 

Bir cevap yazın

E-posta hesabınız yayımlanmayacak. Gerekli alanlar * ile işaretlenmişlerdir