Commit ddcfbe04 authored by Vincent POLLET's avatar Vincent POLLET
Browse files

Merge branch 'improvements' into 'master'

Improvements

Closes #3 and #1

See merge request !4
parents f2e30c38 6f280047
Pipeline #41832 passed with stages
in 6 minutes and 57 seconds
include README.rst buildout.cfg COPYING version.txt requirements.txt
recursive-include doc *.rst *.png *.ico *.txt
\ No newline at end of file
recursive-include doc *.py *.rst *.png *.ico *.txt
recursive-include bob/io/stream *.h5 *.png *.json
......@@ -20,12 +20,6 @@
This package is part of the signal-processing and machine learning toolbox Bob_.
.. todo::
**Complete the sentence above to include one phrase about your
package! Once this is done, delete this to-do!**
Installation
------------
......@@ -45,4 +39,4 @@ development `mailing list`_.
.. Place your references here:
.. _bob: https://www.idiap.ch/software/bob
.. _installation: https://www.idiap.ch/software/bob/install
.. _mailing list: https://www.idiap.ch/software/bob/discuss
\ No newline at end of file
.. _mailing list: https://www.idiap.ch/software/bob/discuss
from .stream import Stream, StreamFile
def get_config():
"""Returns a string containing the configuration information.
"""
......@@ -10,4 +9,5 @@ def get_config():
# gets sphinx autodoc done right - don't remove it
__all__ = [_ for _ in dir() if not _.startswith('_')]
\ No newline at end of file
__all__ = [_ for _ in dir() if not _.startswith('_')]
......@@ -11,39 +11,9 @@ CALIBRATION_PARAMETERS = ['markers',
def load_data_config(path, update_submodalities=True):
with open(path, 'r') as data_config_file:
data_config = json.load(data_config_file)
for mod_config in data_config.values():
config_from = mod_config.get('use_config_from')
if config_from is not None and update_submodalities:
mod_config['array_format'] = data_config[config_from]['array_format']
mod_config['calibration'] = data_config[config_from]['calibration']
mod_config['path_dark'] = data_config[config_from]['path_dark']
if data_config[config_from].get('limits'):
mod_config['limits'] = data_config[config_from]['limits']
if data_config[config_from].get('rotation'):
mod_config['rotation'] = data_config[config_from]['rotation']
if data_config[config_from].get('stereovision'):
mod_config['stereovision'] = data_config[config_from]['stereovision']
for field in CALIBRATION_PARAMETERS:
fld = mod_config['stereovision'].get(field)
if fld is not None:
mod_config['stereovision'][field] = np.array(fld)
calibration = mod_config.get('calibration')
if calibration is not None:
for field in CALIBRATION_PARAMETERS:
fld = calibration.get(field)
if fld is not None:
calibration[field] = np.array(fld)
return data_config
return data_config
def dump_data_config(data_config, path):
data_config = data_config.copy()
with open(path, 'w') as data_config_file:
for mod_config in data_config.values():
calibration = mod_config.get('calibration')
if calibration is not None:
for field in CALIBRATION_PARAMETERS:
fld = calibration.get(field)
if fld is not None:
calibration[field] = fld.tolist()
json.dump(data_config, data_config_file, indent=4, sort_keys=True)
\ No newline at end of file
{
"color": {
"array_format": {
"depth": 1,
"flip": [
"depth"
],
"frame": 0,
"height": 2,
"width": 3
},
"calibration": {
"camera_matrix": [
[
2709.1608316941306,
0.0,
665.6722958269642
],
[
0.0,
2709.1608316941306,
991.2546837678124
],
[
0.0,
0.0,
1.0
]
],
"distortion_coefs": [
[
-0.2300762557375275,
1.3385654630186887,
0.006436850068432612,
0.002152318492553552,
-18.00828586576378
]
],
"markers": [
[
896.0001220703125,
756.5
],
[
907.6502685546875,
1378.1544189453125
],
[
376.49371337890625,
763.4385375976562
],
[
389.854736328125,
1396.3524169921875
]
],
"reference": "nir_left",
"relative_rotation": [
[
0.9999611731884056,
-4.2716520736830266e-05,
-0.008811940249812737
],
[
0.00013545735589643023,
0.9999446107106842,
0.010524122859553463
],
[
0.008811002608792438,
-0.010524907883544557,
0.9999057918359463
]
],
"relative_translation": [
[
-3.4622708861028713
],
[
3.251856340362261
],
[
-3.3090761715952763
]
]
},
"exposure_time": 10000,
"limits": [
0,
255
],
"path": "/BASLER_BGR",
"rotation": 0
},
"depth": {
"array_format": {
"depth": 1,
"flip": [
"depth"
],
"frame": 0,
"height": 2,
"width": 3
},
"calibration": {
"camera_matrix": [
[
938.4110896899313,
0.0,
670.7533296270018
],
[
0.0,
938.4110896899313,
353.5949750660378
],
[
0.0,
0.0,
1.0
]
],
"distortion_coefs": [
[
-0.32878513196223,
4.710993641188489,
0.0012059040097683869,
0.004235057538393047,
-20.185643978195685
]
],
"markers": [
[
780.0,
184.5
],
[
786.693359375,
405.5968017578125
],
[
596.5,
185.5
],
[
602.3780517578125,
411.5423278808594
]
],
"reference": "nir_left",
"relative_rotation": [
[
0.9998353226924195,
0.00931521416438263,
-0.015574154282562952
],
[
-0.008797189920079612,
0.9994164439486106,
0.033005772443977906
],
[
0.015872521729562647,
-0.03286332834916888,
0.9993338104476197
]
],
"relative_translation": [
[
-0.9969100259599053
],
[
-4.1089629090554745
],
[
-5.478408272133706
]
]
},
"exposure_time": 10000,
"limits": [
0,
255
],
"path": "/REALSENSE_D415_DEPTH",
"rotation": 0
},
"infrared": {
"path": "/BASLER_LEFT_NIR_850nm",
"use_config_from": "nir_left"
},
"nir_left": {
"array_format": {
"depth": 1,
"flip": [
"depth"
],
"frame": 0,
"height": 2,
"width": 3
},
"calibration": {
"camera_matrix": [
[
2722.614014815716,
0.0,
637.0863885092994
],
[
0.0,
2722.614014815716,
1004.3124451966052
],
[
0.0,
0.0,
1.0
]
],
"distortion_coefs": [
[
-0.4587300219790108,
5.855915847620604,
0.0054332550377982815,
0.00034621966410940266,
-33.10729465702896
]
],
"markers": [
[
1010.6461181640625,
600.6754760742188
],
[
1026.8948974609375,
1214.5269775390625
],
[
499.5,
602.5
],
[
515.9231567382812,
1234.172607421875
]
],
"reference": "nir_left",
"relative_rotation": [
[
1.0,
0.0,
0.0
],
[
0.0,
1.0,
0.0
],
[
0.0,
0.0,
1.0
]
],
"relative_translation": [
[
0.0
],
[
0.0
],
[
0.0
]
]
},
"exposure_time": 9000,
"limits": [
0,
255
],
"path": "/BASLER_LEFT_NIR_Dark",
"path_dark": "/BASLER_LEFT_NIR_Dark",
"rotation": 0
},
"nir_left_1050nm": {
"path": "/BASLER_LEFT_NIR_1050nm",
"use_config_from": "nir_left"
},
"nir_left_735nm": {
"path": "/BASLER_LEFT_NIR_735nm",
"use_config_from": "nir_left"
},
"nir_left_850nm": {
"path": "/BASLER_LEFT_NIR_850nm",
"use_config_from": "nir_left"
},
"nir_left_940nm": {
"path": "/BASLER_LEFT_NIR_940nm",
"use_config_from": "nir_left"
},
"nir_left_stereo": {
"path": "/BASLER_LEFT_NIR_stereo",
"use_config_from": "nir_left"
},
"nir_right": {
"array_format": {
"depth": 1,
"flip": [
"depth"
],
"frame": 0,
"height": 2,
"width": 3
},
"calibration": {
"camera_matrix": [
[
2713.6917664466746,
0.0,
723.3752564651963
],
[
0.0,
2713.6917664466746,
977.4202504202484
],
[
0.0,
0.0,
1.0
]
],
"distortion_coefs": [
[
-0.22604276527403855,
0.2627983942595181,
0.005057453387572285,
0.004729228169466112,
0.3555445805850847
]
],
"markers": [
[
816.0,
547.5
],
[
830.5,
1173.5
],
[
291.0,
554.0
],
[
305.5,
1190.5
]
],
"reference": "nir_left",
"relative_rotation": [
[
0.9995730307722179,
0.0035040431216878543,
-0.02900823735844914
],
[
-0.0034198776357118894,
0.9999897993273502,
0.0029505386292432447
],
[
0.029018280269504777,
-0.0028500742178495958,
0.9995748178536479
]
],
"relative_translation": [
[
-7.578980266142972
],
[
0.015287974138590213
],
[
-0.6072390457505107
]
]
},
"exposure_time": 9000,
"limits": [
0,
255
],
"path": "/BASLER_RIGHT_NIR_Dark",
"path_dark": "/BASLER_RIGHT_NIR_Dark",
"rotation": 0,
"stereovision": {
"relative_rotation": [
[
0.9995730307722179,
0.0035040431216878543,
-0.02900823735844914
],
[
-0.0034198776357118894,
0.9999897993273502,
0.0029505386292432447
],
[
0.029018280269504777,
-0.0028500742178495958,
0.9995748178536479
]
],
"relative_translation": [
[
-7.578980266142972
],
[
0.015287974138590213
],
[
-0.6072390457505107
]
]
}
},
"nir_right_1050nm": {
"path": "/BASLER_RIGHT_NIR_1050nm",
"use_config_from": "nir_right"
},
"nir_right_735nm": {
"path": "/BASLER_RIGHT_NIR_735nm",
"use_config_from": "nir_right"
},
"nir_right_850nm": {
"path": "/BASLER_RIGHT_NIR_850nm",
"use_config_from": "nir_right"
},
"nir_right_940nm": {
"path": "/BASLER_RIGHT_NIR_940nm",
"use_config_from": "nir_right"
},
"nir_right_stereo": {
"path": "/BASLER_RIGHT_NIR_stereo",
"use_config_from": "nir_right"
},
"swir": {
"array_format": {
"depth": 1,
"flip": [
"depth"
],
"frame": 0,
"height": 2,
"width": 3
},
"calibration": {
"camera_matrix": [
[
852.2523364228687,
0.0,
259.2747690018226
],
[
0.0,
852.2523364228687,
347.7324598499826
],
[
0.0,
0.0,
1.0
]
],
"distortion_coefs": [
[
-0.4465895920413288,
5.016209557144835,
0.007170975813169811,
-0.0006575956372264583,
-33.04161368229198
]
],
"markers": [
[
401.470947265625,
254.2352294921875
],
[
402.63323974609375,
449.9360046386719
],
[
238.87954711914062,
256.83465576171875
],
[
242.61898803710938,
458.85186767578125
]
],
"reference": "nir_left",
"relative_rotation": [
[
0.9998076313398208,
0.003776106961104712,
0.01924685249268862
],
[
-0.002153740960903502,
0.9964948523893977,
-0.08362637479471233
],
[
-0.01949517156965653,
0.08356883496645545,
0.996311290766003
]
],
"relative_translation": [
[
-0.008628450018923383
],
[
8.3851084744432
],