-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathundistortVideoStream.py
36 lines (28 loc) · 1000 Bytes
/
undistortVideoStream.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
29
30
31
32
33
34
35
36
"""
This code uses the output parameters of the camera calibration
to get a clear image(undistorted) by remapping it
"""
import cv2
from Camera.Undistortion import UndistortFisheye
# frontStream = cv2.VideoCapture(0)
# backStream = cv2.VideoCapture(0)
frontCamera = UndistortFisheye("Front_Camera", tune=True)
backCamera = UndistortFisheye("Back_Camera")
while True:
# _, frontFrame = frontStream.read()
# _, backFrame = backStream.read()
frontFrame = cv2.imread("dataset/Front_View.jpg")
backFrame = cv2.imread("dataset/Rear_View.jpg")
frontView = frontCamera.undistort(frontFrame)
backView = backCamera.undistort(backFrame)
cv2.imshow("Undistorted Front", frontView)
cv2.imshow("Undistorted Back", backView)
key = cv2.waitKey(1) & 0xFF
if key == ord("q"):
break
if key == ord("s"):
cv2.imwrite("Capture.jpg", frontView)
if key == ord("r"):
frontCamera.reset()
backCamera.reset()
cv2.destroyAllWindows()