-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathupdates.py
112 lines (91 loc) · 4.35 KB
/
updates.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
100
101
102
103
104
105
106
107
108
109
110
111
112
############################################################################
# This file is part of the 4D Light Field Benchmark. #
# #
# This work is licensed under the Creative Commons #
# Attribution-NonCommercial-ShareAlike 4.0 International License. #
# To view a copy of this license, #
# visit http://creativecommons.org/licenses/by-nc-sa/4.0/. #
# #
# Authors: Katrin Honauer & Ole Johannsen #
# Contact: [email protected] #
# Website: www.lightfield-analysis.net #
# #
# This add-on is based upon work of Maximilian Diebold #
# #
# The 4D Light Field Benchmark was jointly created by the University of #
# Konstanz and the HCI at Heidelberg University. If you use any part of #
# the benchmark, please cite our paper "A dataset and evaluation #
# methodology for depth estimation on 4D light fields". Thanks! #
# #
# @inproceedings{honauer2016benchmark, #
# title={A dataset and evaluation methodology for depth estimation on #
# 4D light fields}, #
# author={Honauer, Katrin and Johannsen, Ole and Kondermann, Daniel #
# and Goldluecke, Bastian}, #
# booktitle={Asian Conference on Computer Vision}, #
# year={2016}, #
# organization={Springer} #
# } #
# #
############################################################################
import bpy
from bpy.props import *
import os
def update_lightfield(self, context):
"""
update function for light field
"""
bpy.ops.scene.update_lightfield('EXEC_DEFAULT')
def update_baseline(self, context):
"""
update function for baseline property
"""
LF = bpy.context.scene.LF
LF.baseline_x_m = LF.baseline_mm / 1000.0
LF.baseline_y_m = LF.baseline_mm / 1000.0
update_lightfield(self, context)
def update_number_of_cameras(self, context):
"""
update function for number of cameras
"""
# enforce odd number of cameras
LF = bpy.context.scene.LF
if LF.num_cams_x % 2 == 0:
if LF.num_cams_x_hidden and LF.num_cams_x_hidden < LF.num_cams_x:
LF.num_cams_x += 1
else:
LF.num_cams_x -= 1
if LF.num_cams_y % 2 == 0:
if LF.num_cams_y_hidden and LF.num_cams_y_hidden < LF.num_cams_y:
LF.num_cams_y += 1
else:
LF.num_cams_y -= 1
LF.num_cams_x_hidden = LF.num_cams_x
LF.num_cams_y_hidden = LF.num_cams_y
update_lightfield(self, context)
def update_target_directory(self, context):
"""
update function for target directory
"""
LF = bpy.context.scene.LF
if not LF.is_valid_directory(LF.tgt_dir):
LF.tgt_dir = get_default_target_directory()
def update_path_config_file(self, context):
"""
update function for path to config file
"""
LF = bpy.context.scene.LF
try:
path, file_name = os.path.split(LF.path_config_file)
if not LF.is_valid_directory(path):
LF.path_config_file = get_default_path_config_file()
except:
print("Could not split file path into directory and file name: '%s'" % LF.path_config_file)
LF.path_config_file = get_default_path_config_file()
def get_default_target_directory():
path = os.path.join(bpy.context.user_preferences.filepaths.temporary_directory, 'lightfield')
if not os.path.isdir(path):
os.makedirs(path)
return path
def get_default_path_config_file():
return os.path.join(get_default_target_directory(), 'parameters.cfg')