Commit 42f9b71dfdf89a60aa1a3885a06117450f618fb8

Authored by André Araújo
1 parent 2b000538
Exists in master

Adiciona movimento retilíneo

1 -#JSON = $(JSON_CIRCULAR)  
2 -JSON = $(JSON_PONTUAL) 1 +JSON = $(JSON_RETILINEO)
  2 +
  3 +# ----------------------------
  4 +# JSON = $(JSON_CIRCULAR)
  5 +# JSON = $(JSON_CONTATO_ALISAR)
  6 +# JSON = $(JSON_CONTATO_COCAR)
  7 +# JSON = $(JSON_CONTATO_TOCAR)
  8 +# JSON = $(JSON_CONTATO_RISCAR)
  9 +# JSON = $(JSON_FACIAL)
  10 +# JSON = $(JSON_HELICOIDAL)
  11 +# JSON = $(JSON_PONTUAL)
  12 +# JSON = $(JSON_RETILINEO)
  13 +# JSON = $(JSON_SEMI_CIRCULAR)
  14 +# JSON = $(JSON_SENOIDAL)
  15 +# ----------------------------
3 16
4 JSON_CIRCULAR = \ 17 JSON_CIRCULAR = \
5 '{ \ 18 '{ \
@@ -8,11 +21,7 @@ JSON_CIRCULAR = \ @@ -8,11 +21,7 @@ JSON_CIRCULAR = \
8 "interpolacao": "normal", \ 21 "interpolacao": "normal", \
9 "movimentos": [ \ 22 "movimentos": [ \
10 { \ 23 { \
11 - "facial": { \  
12 - "expressao": 10, \  
13 - "transicao": "normal", \  
14 - "duracao": "normal" \  
15 - }, \ 24 + "facial": {}, \
16 "mao_esquerda": { \ 25 "mao_esquerda": { \
17 "circular": { \ 26 "circular": { \
18 "plano": "esquerda-cima", \ 27 "plano": "esquerda-cima", \
@@ -25,27 +34,104 @@ JSON_CIRCULAR = \ @@ -25,27 +34,104 @@ JSON_CIRCULAR = \
25 "orientacao": 20 \ 34 "orientacao": 20 \
26 } \ 35 } \
27 }, \ 36 }, \
  37 + "mao_direita": {} \
  38 + } \
  39 + ] \
  40 +}'
  41 +
  42 +JSON_CONTATO_ALISAR = \
  43 +'{ \
  44 + "userId": "lavid", \
  45 + "sinal": "modelo_contato_alisar", \
  46 + "interpolacao": "normal", \
  47 + "movimentos": [ \
  48 + { \
  49 + "facial": {}, \
28 "mao_direita": { \ 50 "mao_direita": { \
29 - } \  
30 - }, \ 51 + "contato": { \
  52 + "movimento_orientacao": "paralelo", \
  53 + "alisar": { \
  54 + "articulacao": 71, \
  55 + "configuracao": 19, \
  56 + "orientacao": 11 \
  57 + } \
  58 + } \
  59 + }, \
  60 + "mao_esquerda": {} \
  61 + } \
  62 + ] \
  63 +}'
  64 +
  65 +JSON_CONTATO_COCAR = \
  66 +'{ \
  67 + "userId": "lavid", \
  68 + "sinal": "modelo_contato_cocar", \
  69 + "interpolacao": "normal", \
  70 + "movimentos": [ \
31 { \ 71 { \
32 - "facial": { \  
33 - "expressao": 11, \  
34 - "transicao": "normal", \  
35 - "duracao": "normal" \ 72 + "facial": {}, \
  73 + "mao_direita": { \
  74 + "contato": { \
  75 + "cocar": { \
  76 + "articulacao": 71, \
  77 + "configuracao": 19, \
  78 + "orientacao": 11 \
  79 + } \
  80 + } \
36 }, \ 81 }, \
37 - "mao_esquerda": { \ 82 + "mao_esquerda": {} \
  83 + } \
  84 + ] \
  85 +}'
  86 +
  87 +JSON_CONTATO_TOCAR = \
  88 +'{ \
  89 + "userId": "lavid", \
  90 + "sinal": "modelo_contato_tocar", \
  91 + "interpolacao": "normal", \
  92 + "movimentos": [ \
  93 + { \
  94 + "facial": {}, \
  95 + "mao_direita": { \
  96 + "contato": { \
  97 + "tocar": { \
  98 + "articulacao": 71, \
  99 + "configuracao": 19, \
  100 + "orientacao": 11 \
  101 + } \
  102 + } \
38 }, \ 103 }, \
  104 + "mao_esquerda": {} \
  105 + } \
  106 + ] \
  107 +}'
  108 +
  109 +JSON_CONTATO_RISCAR = \
  110 +'{ \
  111 + "userId": "lavid", \
  112 + "sinal": "modelo_contato_riscar", \
  113 + "interpolacao": "normal", \
  114 + "movimentos": [ \
  115 + { \
  116 + "facial": {}, \
39 "mao_direita": { \ 117 "mao_direita": { \
40 - } \ 118 + "contato": { \
  119 + "riscar": { \
  120 + "articulacao": 71, \
  121 + "configuracao": 19, \
  122 + "orientacao": 11 \
  123 + } \
  124 + } \
  125 + }, \
  126 + "mao_esquerda": {} \
41 } \ 127 } \
42 ] \ 128 ] \
43 }' 129 }'
44 130
45 -JSON_PONTUAL = \ 131 +JSON_FACIAL = \
46 '{ \ 132 '{ \
47 "userId": "lavid", \ 133 "userId": "lavid", \
48 - "sinal": "modelo_pontual", \ 134 + "sinal": "modelo_facial", \
49 "interpolacao": "normal", \ 135 "interpolacao": "normal", \
50 "movimentos": [ \ 136 "movimentos": [ \
51 { \ 137 { \
@@ -54,6 +140,53 @@ JSON_PONTUAL = \ @@ -54,6 +140,53 @@ JSON_PONTUAL = \
54 "transicao": "normal", \ 140 "transicao": "normal", \
55 "duracao": "normal" \ 141 "duracao": "normal" \
56 }, \ 142 }, \
  143 + "mao_direita": {}, \
  144 + "mao_esquerda": {} \
  145 + }, \
  146 + { \
  147 + "facial": { \
  148 + "expressao": 11, \
  149 + "transicao": "normal", \
  150 + "duracao": "normal" \
  151 + } \
  152 + "mao_direita": {}, \
  153 + "mao_esquerda": {} \
  154 + } \
  155 + ] \
  156 +}'
  157 +
  158 +JSON_HELICOIDAL = \
  159 +'{ \
  160 + "userId": "lavid", \
  161 + "sinal": "modelo_helicoidal", \
  162 + "interpolacao": "normal", \
  163 + "movimentos": [ \
  164 + { \
  165 + "facial": {}, \
  166 + "mao_esquerda": { \
  167 + "helicoidal": { \
  168 + "plano": "esquerda-cima", \
  169 + "raio": "pequeno", \
  170 + "velocidade": "normal", \
  171 + "lado_oposto": false, \
  172 + "sentido_inverso": false, \
  173 + "articulacao": 80, \
  174 + "configuracao": 10, \
  175 + "orientacao": 20 \
  176 + } \
  177 + }, \
  178 + "mao_direita": {} \
  179 + } \
  180 +}'
  181 +
  182 +JSON_PONTUAL = \
  183 +'{ \
  184 + "userId": "lavid", \
  185 + "sinal": "modelo_pontual", \
  186 + "interpolacao": "normal", \
  187 + "movimentos": [ \
  188 + { \
  189 + "facial": {}, \
57 "mao_direita": { \ 190 "mao_direita": { \
58 "pontual": { \ 191 "pontual": { \
59 "articulacao": 71, \ 192 "articulacao": 71, \
@@ -67,6 +200,82 @@ JSON_PONTUAL = \ @@ -67,6 +200,82 @@ JSON_PONTUAL = \
67 ] \ 200 ] \
68 }' 201 }'
69 202
  203 +JSON_RETILINEO = \
  204 +'{ \
  205 + "userId": "lavid", \
  206 + "sinal": "modelo_retilineo", \
  207 + "interpolacao": "normal", \
  208 + "movimentos": [ \
  209 + { \
  210 + "facial": {}, \
  211 + "mao_direita": { \
  212 + "retilineo": { \
  213 + "articulacao_inicial": 71, \
  214 + "articulacao_final": 75, \
  215 + "configuracao": 19, \
  216 + "orientacao": 11 \
  217 + } \
  218 + }, \
  219 + "mao_esquerda": { \
  220 + } \
  221 + } \
  222 + ] \
  223 +}'
  224 +
  225 +JSON_SEMI_CIRCULAR = \
  226 +'{ \
  227 + "userId": "lavid", \
  228 + "sinal": "modelo_semi_circular", \
  229 + "interpolacao": "normal", \
  230 + "movimentos": [ \
  231 + { \
  232 + "facial": {}, \
  233 + "mao_esquerda": { \
  234 + "circular": { \
  235 + "plano": "esquerda-cima", \
  236 + "raio": "pequeno", \
  237 + "velocidade": "normal", \
  238 + "lado_oposto": false, \
  239 + "sentido_inverso": false, \
  240 + "articulacao": 80, \
  241 + "configuracao": 10, \
  242 + "orientacao": 20 \
  243 + } \
  244 + }, \
  245 + "mao_direita": {} \
  246 + } \
  247 + ] \
  248 +}'
  249 +
  250 +JSON_SENOIDAL = \
  251 +'{ \
  252 + "userId": "lavid", \
  253 + "sinal": "modelo_senoidal", \
  254 + "interpolacao": "normal", \
  255 + "movimentos": [ \
  256 + { \
  257 + "facial": { \
  258 + "expressao": 10, \
  259 + "transicao": "normal", \
  260 + "duracao": "normal" \
  261 + }, \
  262 + "mao_esquerda": { \
  263 + "circular": { \
  264 + "plano": "esquerda-cima", \
  265 + "raio": "pequeno", \
  266 + "velocidade": "normal", \
  267 + "lado_oposto": false, \
  268 + "sentido_inverso": false, \
  269 + "articulacao": 80, \
  270 + "configuracao": 10, \
  271 + "orientacao": 20 \
  272 + } \
  273 + }, \
  274 + "mao_direita": { \
  275 + } \
  276 + } \
  277 +}'
  278 +
70 BLEND = avatar_cartoon_v2.74.blend 279 BLEND = avatar_cartoon_v2.74.blend
71 CONTROLLER = controller.py 280 CONTROLLER = controller.py
72 MAIN = libras.py 281 MAIN = libras.py
@@ -3,9 +3,16 @@ import moves @@ -3,9 +3,16 @@ import moves
3 import util 3 import util
4 4
5 def circular_semicircular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircular): 5 def circular_semicircular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircular):
6 - # const  
7 - dict_ray = {'pequeno': 0.5, 'normal': 1.0, 'grande': 1.5}  
8 - dict_period = {'lento': 55, 'normal': 45, 'rapido': 35} 6 + dict_ray = {
  7 + 'pequeno': 0.5,
  8 + 'normal': 1.0,
  9 + 'grande': 1.5
  10 + }
  11 + dict_period = {
  12 + 'lento': 55,
  13 + 'normal': 45,
  14 + 'rapido': 35
  15 + }
9 # decodificar valores 16 # decodificar valores
10 ray = dict_ray[js_movement['raio']] 17 ray = dict_ray[js_movement['raio']]
11 period = dict_period[js_movement['velocidade']] 18 period = dict_period[js_movement['velocidade']]
@@ -39,21 +46,24 @@ def contato(js_movement, current_frame, frame_jump, is_right_hand): @@ -39,21 +46,24 @@ def contato(js_movement, current_frame, frame_jump, is_right_hand):
39 current_frame = current_frame + 2*frame_jump 46 current_frame = current_frame + 2*frame_jump
40 return moves.contato(action, sub_type, mov_param, bones, is_right_hand, current_frame, frame_jump) 47 return moves.contato(action, sub_type, mov_param, bones, is_right_hand, current_frame, frame_jump)
41 48
42 -def espiral(js_movement, current_frame, frame_jump, is_right_hand):  
43 - pass  
44 -  
45 -def redemoinho(js_movement, current_frame, frame_jump, is_right_hand):  
46 - pass 49 +def helicoidal(js_movement, current_frame, frame_jump, is_right_hand):
  50 + return moves.helicoidal(js_movement, current_frame, frame_jump, is_right_hand)
47 51
48 def pontual(js_movement, current_frame, frame_jump, is_right_hand): 52 def pontual(js_movement, current_frame, frame_jump, is_right_hand):
49 return moves.pontual(js_movement, current_frame, frame_jump, is_right_hand) 53 return moves.pontual(js_movement, current_frame, frame_jump, is_right_hand)
50 54
  55 +def retilineo(js_movement, current_frame, frame_jump, is_right_hand):
  56 + return moves.retilineo(js_movement, current_frame, frame_jump, is_right_hand)
  57 +
  58 +def semicircular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircular):
  59 + return moves.semi_circular(js_movement, current_frame, frame_jump, is_right_hand)
  60 +
51 def senoidal(js_movement, current_frame, frame_jump, is_right_hand): 61 def senoidal(js_movement, current_frame, frame_jump, is_right_hand):
52 - pass 62 + return moves.senoidal(js_movement, current_frame, frame_jump, is_right_hand)
53 63
54 def hand_mov(current_frame, frame_jump, js_mao, is_right_hand): 64 def hand_mov(current_frame, frame_jump, js_mao, is_right_hand):
55 if (js_mao == {}): 65 if (js_mao == {}):
56 - return 66 + return current_frame
57 movement_name = next(iter(js_mao.keys())) 67 movement_name = next(iter(js_mao.keys()))
58 if (movement_name == 'circular'): 68 if (movement_name == 'circular'):
59 current_frame = circular_semicircular(js_mao[movement_name], current_frame, frame_jump, is_right_hand, False) 69 current_frame = circular_semicircular(js_mao[movement_name], current_frame, frame_jump, is_right_hand, False)
@@ -61,12 +71,12 @@ def hand_mov(current_frame, frame_jump, js_mao, is_right_hand): @@ -61,12 +71,12 @@ def hand_mov(current_frame, frame_jump, js_mao, is_right_hand):
61 current_frame = circular_semicircular(js_mao[movement_name], current_frame, frame_jump, is_right_hand, True) 71 current_frame = circular_semicircular(js_mao[movement_name], current_frame, frame_jump, is_right_hand, True)
62 elif (movement_name == 'contato'): 72 elif (movement_name == 'contato'):
63 current_frame = contato(js_mao[movement_name], current_frame, frame_jump, is_right_hand) 73 current_frame = contato(js_mao[movement_name], current_frame, frame_jump, is_right_hand)
64 - elif (movement_name == 'espiral'): 74 + elif (movement_name == 'helicoidal'):
65 current_frame = espiral(js_mao[movement_name], current_frame, frame_jump, is_right_hand) 75 current_frame = espiral(js_mao[movement_name], current_frame, frame_jump, is_right_hand)
66 - elif (movement_name == 'redemoinho'):  
67 - current_frame = redemoinho(js_mao[movement_name], current_frame, frame_jump, is_right_hand)  
68 elif (movement_name == 'pontual'): 76 elif (movement_name == 'pontual'):
69 current_frame = pontual(js_mao[movement_name], current_frame, frame_jump, is_right_hand) 77 current_frame = pontual(js_mao[movement_name], current_frame, frame_jump, is_right_hand)
  78 + elif (movement_name == 'retilineo'):
  79 + current_frame = retilineo(js_mao[movement_name], current_frame, frame_jump, is_right_hand)
70 elif (movement_name == 'senoidal'): 80 elif (movement_name == 'senoidal'):
71 current_frame = senoidal(js_mao[movement_name], current_frame, frame_jump, is_right_hand) 81 current_frame = senoidal(js_mao[movement_name], current_frame, frame_jump, is_right_hand)
72 return current_frame + frame_jump 82 return current_frame + frame_jump
@@ -64,10 +64,11 @@ def main(): @@ -64,10 +64,11 @@ def main():
64 64
65 # setar pose padrao inicial em todos os bones ('location' e 'rotation_quaternion') 65 # setar pose padrao inicial em todos os bones ('location' e 'rotation_quaternion')
66 endFrame += pose_default(dict_interpolation['inicial']) 66 endFrame += pose_default(dict_interpolation['inicial'])
67 - timeline_mao_esquerda = endFrame  
68 - timeline_mao_direita = endFrame  
69 67
70 for i in range(0, len(js_movimentos)): 68 for i in range(0, len(js_movimentos)):
  69 + timeline_mao_esquerda = endFrame
  70 + timeline_mao_direita = endFrame
  71 +
71 # tenta decodificar objetos JSON 72 # tenta decodificar objetos JSON
72 try: 73 try:
73 js_facial = js_movimentos[i]['facial'] 74 js_facial = js_movimentos[i]['facial']
@@ -84,21 +85,24 @@ def main(): @@ -84,21 +85,24 @@ def main():
84 85
85 # faz tratamento dos objetos 86 # faz tratamento dos objetos
86 if (js_facial == {}): 87 if (js_facial == {}):
87 - pyutil.log("<Vazio> js_movimentos[%d] >> Exp facial" % (i)) 88 + print("movimento [%d] Exp facial = <Vazio>" % (i))
88 timeline_facial = facial.set_expression(timeline_facial, 0) 89 timeline_facial = facial.set_expression(timeline_facial, 0)
89 else: 90 else:
  91 + print("movimento [%d] Exp facial = [%d]" % (i, js_facial["expressao"]))
90 timeline_facial = facial.decode_expression(timeline_facial, js_facial) 92 timeline_facial = facial.decode_expression(timeline_facial, js_facial)
91 93
92 if (js_mao_esquerda == {}): 94 if (js_mao_esquerda == {}):
93 - pyutil.log("<Vazio> js_movimentos[%d] >> Mao esquerda" % (i)) 95 + print("movimento [%d] Mao Esquerda = <Vazio>" % (i))
94 # TODO posicionar mao esquerda na lateral do corpo 96 # TODO posicionar mao esquerda na lateral do corpo
95 else: 97 else:
  98 + print("movimento [%d] Mao Esquerda = [%s]" % (i, next(iter(js_mao_esquerda.keys()))))
96 timeline_mao_esquerda = decode.hand_mov(timeline_mao_esquerda, frame_jump, js_mao_esquerda, False) 99 timeline_mao_esquerda = decode.hand_mov(timeline_mao_esquerda, frame_jump, js_mao_esquerda, False)
97 100
98 if (js_mao_direita == {}): 101 if (js_mao_direita == {}):
99 - pyutil.log("<Vazio> js_movimentos[%d] >> Mao direita" % (i)) 102 + print("movimento [%d] Mao Direita = <Vazio>" % (i))
100 # TODO posicionar mao direita na lateral do corpo 103 # TODO posicionar mao direita na lateral do corpo
101 else: 104 else:
  105 + print("movimento [%d] Mao Direita = [%s]" % (i, next(iter(js_mao_direita.keys()))))
102 timeline_mao_direita = decode.hand_mov(timeline_mao_direita, frame_jump, js_mao_direita, True) 106 timeline_mao_direita = decode.hand_mov(timeline_mao_direita, frame_jump, js_mao_direita, True)
103 107
104 endFrame = max(timeline_facial, timeline_mao_esquerda, timeline_mao_direita) 108 endFrame = max(timeline_facial, timeline_mao_esquerda, timeline_mao_direita)
@@ -186,10 +186,22 @@ def pontual(js_movement, current_frame, frame_jump, is_right_hand): @@ -186,10 +186,22 @@ def pontual(js_movement, current_frame, frame_jump, is_right_hand):
186 hand_param = read_hand_param(js_movement) 186 hand_param = read_hand_param(js_movement)
187 bones = util.right_bones_conf if is_right_hand else util.left_bones_conf 187 bones = util.right_bones_conf if is_right_hand else util.left_bones_conf
188 hand_actions = util.right_hand_actions if is_right_hand else util.left_hand_actions 188 hand_actions = util.right_hand_actions if is_right_hand else util.left_hand_actions
189 -  
190 util.keyframe_insert(bones, 'location', current_frame) 189 util.keyframe_insert(bones, 'location', current_frame)
191 current_frame += frame_jump 190 current_frame += frame_jump
192 util.setPose(hand_actions, hand_param, [current_frame], bones) 191 util.setPose(hand_actions, hand_param, [current_frame], bones)
193 current_frame += frame_jump 192 current_frame += frame_jump
194 util.keyframe_insert(bones, 'location', current_frame) 193 util.keyframe_insert(bones, 'location', current_frame)
195 return current_frame 194 return current_frame
  195 +
  196 +def retilineo(js_movement, current_frame, frame_jump, is_right_hand):
  197 + hand_param = [js_movement['configuracao'], js_movement['articulacao_inicial'], js_movement['orientacao']]
  198 + bones = util.right_bones_conf if is_right_hand else util.left_bones_conf
  199 + hand_actions = util.right_hand_actions if is_right_hand else util.left_hand_actions
  200 + util.keyframe_insert(bones, 'location', current_frame)
  201 + current_frame += frame_jump
  202 + util.setPose(hand_actions, hand_param, [current_frame], bones)
  203 + current_frame += 2* frame_jump
  204 + hand_param = [js_movement['configuracao'], js_movement['articulacao_final'], js_movement['orientacao']]
  205 + util.setPose(hand_actions, hand_param, [current_frame], bones)
  206 + util.keyframe_insert(bones, 'location', current_frame)
  207 + return current_frame
196 \ No newline at end of file 208 \ No newline at end of file
@@ -225,6 +225,7 @@ def configure_output(): @@ -225,6 +225,7 @@ def configure_output():
225 def render_sign(user_id, nome_sinal = "sinal", frame_final = bpy.context.scene.frame_end): 225 def render_sign(user_id, nome_sinal = "sinal", frame_final = bpy.context.scene.frame_end):
226 getcwd = os.path.dirname(os.path.abspath(__file__)) 226 getcwd = os.path.dirname(os.path.abspath(__file__))
227 bpy.context.scene.render.filepath = getcwd + "/users/" + str(user_id) + "/"+ nome_sinal + "_" 227 bpy.context.scene.render.filepath = getcwd + "/users/" + str(user_id) + "/"+ nome_sinal + "_"
  228 + bpy.ops.wm.save_as_mainfile(filepath=getcwd + "/users/" + str(user_id) + "/"+ nome_sinal + ".blend")
228 bpy.context.scene.frame_end = frame_final 229 bpy.context.scene.frame_end = frame_final
229 pyutil.log("Gerando Video... Frames: %i" % (frame_final)) 230 pyutil.log("Gerando Video... Frames: %i" % (frame_final))
230 bpy.ops.render.render(animation = True, write_still = False, layer = "", scene = "") 231 bpy.ops.render.render(animation = True, write_still = False, layer = "", scene = "")