-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcalibration_tools.py
101 lines (72 loc) · 2.45 KB
/
calibration_tools.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
''' Python scripts to calibrate a single camera
All Rights Resrved (c) Uditha Jayarathne 2014
'''
import os
import sys
#from termcolor import colored
## Use this function to invove Capture_Video.exe
# @param framerate
# @param port1 left camera port
# @param port2 right camera port
def capture_video(input1, input2, input3):
print("Executing Capture_Video.exe")
cmd = 'Capture_Video.exe' + ' ' + input1 + ' ' + input2 + ' ' + input3
os.system(cmd)
return
## Use this function to invoke ReadVid.exe
# @param input video_to_be_playedback
# @param output director to write the images
def read_and_split_video(input, output):
# ceate directory to save captured images
cmd = 'mkdir' + ' ' + output
os.system(cmd)
print("Executing ReavVid.exe")
cmd = 'ReadVid.exe' + ' ' + input
os.system(cmd)
return
## Use this function to invoke CV_Calib_V1.exe
# @param input name of the settings file
# @param output name of the output file
def calibrate_camera(input, output, prefix):
print("Executing CV_Calib_V1.exe for calibration")
cmd = 'CV_Calib_V1.exe' + ' ' + input + ' ' + output + ' ' + prefix
os.system(cmd)
return
## Use this function to invoke CV_Stereo_Calib.exe
# @param input name of the settings file
# @param output file
def stereo_calibrate_cameras(input, output):
print("Executing CV_Stereo_Calib.exe for stereo calibration")
cmd = 'CV_Stereo_Calib.exe' + ' ' + input + ' ' + output
os.system(cmd)
return
# Script
os.system('cls')
while True:
print("\n")
print("Camera Calibration Tools")
print("Key strokes:")
print("\t1 - capture video from camera(s)")
print("\t2 - read and split frames")
print("\t3 - calibrate camera")
print("\t4 - stereo calibrate")
print("\t0 - quit")
# Get user input
key = int(input("-->"))
if key == 1:
capture_video('30', '1', '0')
if key == 2:
read_and_split_video('videos/CAP_2014923T184648.avi', 'captures')
if key == 3:
print("Select which camera to calibrate (L - 0/R - 1)")
s = int(input("-->"))
# Select which camera to calibrate
if s == 0:
calibrate_camera('settings.xml', 'left_calibration.xml', 'L')
if s == 1:
calibrate_camera('settings.xml', 'right_calibration.xml', 'R')
if key == 4:
stereo_calibrate_cameras('stereo_settings.xml', 'stereo_calibration.xml')
if key == 0:
print("Exiting the calibration tool.")
break;