-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathImageRotation.py
28 lines (24 loc) · 1019 Bytes
/
ImageRotation.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import cv2
class Info(object):
def __init__(self, dct):
self.dct = dct
def __getattr__(self, name):
return self.dct[name]
pic = 10
image = cv2.imread('../road6/'+str(pic)+'.jpg')
height = int(image.shape[0]) # row y
width = int(image.shape[1]) # col x
cameraInfo = Info({
"focalLengthX": 4600, # 1200.6831, # focal length x
"focalLengthY": 3400, # 1200.6831, # focal length y
"opticalCenterX": int(width / 2), # 638.1608, # optical center x
"opticalCenterY": int(height / 2), # 738.8648, # optical center y
"cameraHeight": 1500, # 1879.8, # camera height in `mm`
"pitch": 7, # rotation degree around x
"yaw": 0, # rotation degree around y
"roll": 1.5 # rotation degree around z
})
M = cv2.getRotationMatrix2D(
(cameraInfo.opticalCenterX, cameraInfo.opticalCenterY), cameraInfo.roll, 1)
image = cv2.warpAffine(image, M, (width, height))
cv2.imwrite('../road6/'+str(pic)+'_rotate.jpg',image)