-
Notifications
You must be signed in to change notification settings - Fork 2
/
showdistortionmap.py
executable file
·57 lines (42 loc) · 1.36 KB
/
showdistortionmap.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
#!/usr/bin/env python
"""
Display how the undistorter converts coordinates visibly.
(C) 2016-2018 1024jp
"""
import os
import sys
from modules import argsparser
from modules.datafile import Data
from modules.undistortion import Undistorter
class ArgsParser(argsparser.Parser):
description = 'Display how the undistorter converts coordinates visibly.'
datafile_name = 'location'
def main(data, camera_path=None, size):
"""Display potential map for given location file.
Arguments:
data (Data) -- Data source instance.
camera_path (str) -- Path to a camera model or None.
size (int, int) -- Width and height of source image.
"""
if camerafile:
undistorter = Undistorter.load(camera_path)
else:
undistorter = Undistorter.init(data.image_points, data.dest_points,
size)
undistorter.show_map()
def test():
"""Show potential map with test data.
"""
from modules.datafile import LOC_FILENAME
path = os.path.join(os.path.dirname(__file__), 'test', LOC_FILENAME)
location_file = open(path, 'r')
data = Data(open(path, 'r'))
main(data, (3840, 2160))
if __name__ == "__main__":
parser = ArgsParser()
args = parser.parse_args()
if args.test:
test()
sys.exit()
data = Data(args.file, in_cols=args.in_cols)
main(data, args.size)