mls_matlab2opencv.py
Go to the documentation of this file.
1 #!/usr/bin/env python
2 # -*- coding: utf-8 -*-
3 
4 # Python version of https://gist.github.com/dangkhoasdc/991b6913a43a2a726743
5 
6 import os
7 import scipy.io
8 
9 
10 def main():
11  home_dir = os.environ['HOME']
12  mls = scipy.io.loadmat(os.path.join(home_dir, '.ros/XY_MLS_Grid_example2.mat'))
13  yml_path = os.path.join(home_dir, '.ros/fisheye_stitcher_grid_xd_yd_3840x1920.yml')
14  with open(yml_path, 'w') as f:
15  f.write('%YAML:1.0\n')
16  for label in ['Xd', 'Yd']:
17  rows = mls[label].shape[0]
18  cols = mls[label].shape[1]
19  f.write(' {}: !!opencv-matrix\n'.format(label))
20  f.write(' rows: {}\n'.format(rows))
21  f.write(' cols: {}\n'.format(cols))
22  f.write(' dt: f\n')
23  f.write(' data: [ ')
24  for i in range(mls[label].size):
25  f.write(str(mls[label][i / cols][i % cols]))
26  if i < mls[label].size - 1:
27  f.write(', ')
28  if (i % 4) == 3:
29  f.write('\n ')
30  else:
31  f.write(' ]\n')
32  print('{} is exported.'.format(yml_path))
33 
34 
35 if __name__ == '__main__':
36  main()


jsk_perception
Author(s): Manabu Saito, Ryohei Ueda
autogenerated on Mon May 3 2021 03:03:27