diff --git a/Makefile b/Makefile index dfab752..7fb27d2 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,18 @@ -#JSON = $(JSON_CIRCULAR) -JSON = $(JSON_PONTUAL) +JSON = $(JSON_RETILINEO) + +# ---------------------------- +# JSON = $(JSON_CIRCULAR) +# JSON = $(JSON_CONTATO_ALISAR) +# JSON = $(JSON_CONTATO_COCAR) +# JSON = $(JSON_CONTATO_TOCAR) +# JSON = $(JSON_CONTATO_RISCAR) +# JSON = $(JSON_FACIAL) +# JSON = $(JSON_HELICOIDAL) +# JSON = $(JSON_PONTUAL) +# JSON = $(JSON_RETILINEO) +# JSON = $(JSON_SEMI_CIRCULAR) +# JSON = $(JSON_SENOIDAL) +# ---------------------------- JSON_CIRCULAR = \ '{ \ @@ -8,11 +21,7 @@ JSON_CIRCULAR = \ "interpolacao": "normal", \ "movimentos": [ \ { \ - "facial": { \ - "expressao": 10, \ - "transicao": "normal", \ - "duracao": "normal" \ - }, \ + "facial": {}, \ "mao_esquerda": { \ "circular": { \ "plano": "esquerda-cima", \ @@ -25,27 +34,104 @@ JSON_CIRCULAR = \ "orientacao": 20 \ } \ }, \ + "mao_direita": {} \ + } \ + ] \ +}' + +JSON_CONTATO_ALISAR = \ +'{ \ + "userId": "lavid", \ + "sinal": "modelo_contato_alisar", \ + "interpolacao": "normal", \ + "movimentos": [ \ + { \ + "facial": {}, \ "mao_direita": { \ - } \ - }, \ + "contato": { \ + "movimento_orientacao": "paralelo", \ + "alisar": { \ + "articulacao": 71, \ + "configuracao": 19, \ + "orientacao": 11 \ + } \ + } \ + }, \ + "mao_esquerda": {} \ + } \ + ] \ +}' + +JSON_CONTATO_COCAR = \ +'{ \ + "userId": "lavid", \ + "sinal": "modelo_contato_cocar", \ + "interpolacao": "normal", \ + "movimentos": [ \ { \ - "facial": { \ - "expressao": 11, \ - "transicao": "normal", \ - "duracao": "normal" \ + "facial": {}, \ + "mao_direita": { \ + "contato": { \ + "cocar": { \ + "articulacao": 71, \ + "configuracao": 19, \ + "orientacao": 11 \ + } \ + } \ }, \ - "mao_esquerda": { \ + "mao_esquerda": {} \ + } \ + ] \ +}' + +JSON_CONTATO_TOCAR = \ +'{ \ + "userId": "lavid", \ + "sinal": "modelo_contato_tocar", \ + "interpolacao": "normal", \ + "movimentos": [ \ + { \ + "facial": {}, \ + "mao_direita": { \ + "contato": { \ + "tocar": { \ + "articulacao": 71, \ + "configuracao": 19, \ + "orientacao": 11 \ + } \ + } \ }, \ + "mao_esquerda": {} \ + } \ + ] \ +}' + +JSON_CONTATO_RISCAR = \ +'{ \ + "userId": "lavid", \ + "sinal": "modelo_contato_riscar", \ + "interpolacao": "normal", \ + "movimentos": [ \ + { \ + "facial": {}, \ "mao_direita": { \ - } \ + "contato": { \ + "riscar": { \ + "articulacao": 71, \ + "configuracao": 19, \ + "orientacao": 11 \ + } \ + } \ + }, \ + "mao_esquerda": {} \ } \ ] \ }' -JSON_PONTUAL = \ +JSON_FACIAL = \ '{ \ "userId": "lavid", \ - "sinal": "modelo_pontual", \ + "sinal": "modelo_facial", \ "interpolacao": "normal", \ "movimentos": [ \ { \ @@ -54,6 +140,53 @@ JSON_PONTUAL = \ "transicao": "normal", \ "duracao": "normal" \ }, \ + "mao_direita": {}, \ + "mao_esquerda": {} \ + }, \ + { \ + "facial": { \ + "expressao": 11, \ + "transicao": "normal", \ + "duracao": "normal" \ + } \ + "mao_direita": {}, \ + "mao_esquerda": {} \ + } \ + ] \ +}' + +JSON_HELICOIDAL = \ +'{ \ + "userId": "lavid", \ + "sinal": "modelo_helicoidal", \ + "interpolacao": "normal", \ + "movimentos": [ \ + { \ + "facial": {}, \ + "mao_esquerda": { \ + "helicoidal": { \ + "plano": "esquerda-cima", \ + "raio": "pequeno", \ + "velocidade": "normal", \ + "lado_oposto": false, \ + "sentido_inverso": false, \ + "articulacao": 80, \ + "configuracao": 10, \ + "orientacao": 20 \ + } \ + }, \ + "mao_direita": {} \ + } \ +}' + +JSON_PONTUAL = \ +'{ \ + "userId": "lavid", \ + "sinal": "modelo_pontual", \ + "interpolacao": "normal", \ + "movimentos": [ \ + { \ + "facial": {}, \ "mao_direita": { \ "pontual": { \ "articulacao": 71, \ @@ -67,6 +200,82 @@ JSON_PONTUAL = \ ] \ }' +JSON_RETILINEO = \ +'{ \ + "userId": "lavid", \ + "sinal": "modelo_retilineo", \ + "interpolacao": "normal", \ + "movimentos": [ \ + { \ + "facial": {}, \ + "mao_direita": { \ + "retilineo": { \ + "articulacao_inicial": 71, \ + "articulacao_final": 75, \ + "configuracao": 19, \ + "orientacao": 11 \ + } \ + }, \ + "mao_esquerda": { \ + } \ + } \ + ] \ +}' + +JSON_SEMI_CIRCULAR = \ +'{ \ + "userId": "lavid", \ + "sinal": "modelo_semi_circular", \ + "interpolacao": "normal", \ + "movimentos": [ \ + { \ + "facial": {}, \ + "mao_esquerda": { \ + "circular": { \ + "plano": "esquerda-cima", \ + "raio": "pequeno", \ + "velocidade": "normal", \ + "lado_oposto": false, \ + "sentido_inverso": false, \ + "articulacao": 80, \ + "configuracao": 10, \ + "orientacao": 20 \ + } \ + }, \ + "mao_direita": {} \ + } \ + ] \ +}' + +JSON_SENOIDAL = \ +'{ \ + "userId": "lavid", \ + "sinal": "modelo_senoidal", \ + "interpolacao": "normal", \ + "movimentos": [ \ + { \ + "facial": { \ + "expressao": 10, \ + "transicao": "normal", \ + "duracao": "normal" \ + }, \ + "mao_esquerda": { \ + "circular": { \ + "plano": "esquerda-cima", \ + "raio": "pequeno", \ + "velocidade": "normal", \ + "lado_oposto": false, \ + "sentido_inverso": false, \ + "articulacao": 80, \ + "configuracao": 10, \ + "orientacao": 20 \ + } \ + }, \ + "mao_direita": { \ + } \ + } \ +}' + BLEND = avatar_cartoon_v2.74.blend CONTROLLER = controller.py MAIN = libras.py diff --git a/decode.py b/decode.py index 4136a5e..080deb3 100644 --- a/decode.py +++ b/decode.py @@ -3,9 +3,16 @@ import moves import util def circular_semicircular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircular): - # const - dict_ray = {'pequeno': 0.5, 'normal': 1.0, 'grande': 1.5} - dict_period = {'lento': 55, 'normal': 45, 'rapido': 35} + dict_ray = { + 'pequeno': 0.5, + 'normal': 1.0, + 'grande': 1.5 + } + dict_period = { + 'lento': 55, + 'normal': 45, + 'rapido': 35 + } # decodificar valores ray = dict_ray[js_movement['raio']] period = dict_period[js_movement['velocidade']] @@ -39,21 +46,24 @@ def contato(js_movement, current_frame, frame_jump, is_right_hand): current_frame = current_frame + 2*frame_jump return moves.contato(action, sub_type, mov_param, bones, is_right_hand, current_frame, frame_jump) -def espiral(js_movement, current_frame, frame_jump, is_right_hand): - pass - -def redemoinho(js_movement, current_frame, frame_jump, is_right_hand): - pass +def helicoidal(js_movement, current_frame, frame_jump, is_right_hand): + return moves.helicoidal(js_movement, current_frame, frame_jump, is_right_hand) def pontual(js_movement, current_frame, frame_jump, is_right_hand): return moves.pontual(js_movement, current_frame, frame_jump, is_right_hand) +def retilineo(js_movement, current_frame, frame_jump, is_right_hand): + return moves.retilineo(js_movement, current_frame, frame_jump, is_right_hand) + +def semicircular(js_movement, current_frame, frame_jump, is_right_hand, is_semicircular): + return moves.semi_circular(js_movement, current_frame, frame_jump, is_right_hand) + def senoidal(js_movement, current_frame, frame_jump, is_right_hand): - pass + return moves.senoidal(js_movement, current_frame, frame_jump, is_right_hand) def hand_mov(current_frame, frame_jump, js_mao, is_right_hand): if (js_mao == {}): - return + return current_frame movement_name = next(iter(js_mao.keys())) if (movement_name == 'circular'): 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): current_frame = circular_semicircular(js_mao[movement_name], current_frame, frame_jump, is_right_hand, True) elif (movement_name == 'contato'): current_frame = contato(js_mao[movement_name], current_frame, frame_jump, is_right_hand) - elif (movement_name == 'espiral'): + elif (movement_name == 'helicoidal'): current_frame = espiral(js_mao[movement_name], current_frame, frame_jump, is_right_hand) - elif (movement_name == 'redemoinho'): - current_frame = redemoinho(js_mao[movement_name], current_frame, frame_jump, is_right_hand) elif (movement_name == 'pontual'): current_frame = pontual(js_mao[movement_name], current_frame, frame_jump, is_right_hand) + elif (movement_name == 'retilineo'): + current_frame = retilineo(js_mao[movement_name], current_frame, frame_jump, is_right_hand) elif (movement_name == 'senoidal'): current_frame = senoidal(js_mao[movement_name], current_frame, frame_jump, is_right_hand) return current_frame + frame_jump diff --git a/libras.py b/libras.py index c2ac790..fa8d6a7 100644 --- a/libras.py +++ b/libras.py @@ -64,10 +64,11 @@ def main(): # setar pose padrao inicial em todos os bones ('location' e 'rotation_quaternion') endFrame += pose_default(dict_interpolation['inicial']) - timeline_mao_esquerda = endFrame - timeline_mao_direita = endFrame for i in range(0, len(js_movimentos)): + timeline_mao_esquerda = endFrame + timeline_mao_direita = endFrame + # tenta decodificar objetos JSON try: js_facial = js_movimentos[i]['facial'] @@ -84,21 +85,24 @@ def main(): # faz tratamento dos objetos if (js_facial == {}): - pyutil.log(" js_movimentos[%d] >> Exp facial" % (i)) + print("movimento [%d] Exp facial = " % (i)) timeline_facial = facial.set_expression(timeline_facial, 0) else: + print("movimento [%d] Exp facial = [%d]" % (i, js_facial["expressao"])) timeline_facial = facial.decode_expression(timeline_facial, js_facial) if (js_mao_esquerda == {}): - pyutil.log(" js_movimentos[%d] >> Mao esquerda" % (i)) + print("movimento [%d] Mao Esquerda = " % (i)) # TODO posicionar mao esquerda na lateral do corpo else: + print("movimento [%d] Mao Esquerda = [%s]" % (i, next(iter(js_mao_esquerda.keys())))) timeline_mao_esquerda = decode.hand_mov(timeline_mao_esquerda, frame_jump, js_mao_esquerda, False) if (js_mao_direita == {}): - pyutil.log(" js_movimentos[%d] >> Mao direita" % (i)) + print("movimento [%d] Mao Direita = " % (i)) # TODO posicionar mao direita na lateral do corpo else: + print("movimento [%d] Mao Direita = [%s]" % (i, next(iter(js_mao_direita.keys())))) timeline_mao_direita = decode.hand_mov(timeline_mao_direita, frame_jump, js_mao_direita, True) endFrame = max(timeline_facial, timeline_mao_esquerda, timeline_mao_direita) diff --git a/moves.py b/moves.py index 6a7a081..57c43a6 100644 --- a/moves.py +++ b/moves.py @@ -186,10 +186,22 @@ def pontual(js_movement, current_frame, frame_jump, is_right_hand): hand_param = read_hand_param(js_movement) bones = util.right_bones_conf if is_right_hand else util.left_bones_conf hand_actions = util.right_hand_actions if is_right_hand else util.left_hand_actions - util.keyframe_insert(bones, 'location', current_frame) current_frame += frame_jump util.setPose(hand_actions, hand_param, [current_frame], bones) current_frame += frame_jump util.keyframe_insert(bones, 'location', current_frame) return current_frame + +def retilineo(js_movement, current_frame, frame_jump, is_right_hand): + hand_param = [js_movement['configuracao'], js_movement['articulacao_inicial'], js_movement['orientacao']] + bones = util.right_bones_conf if is_right_hand else util.left_bones_conf + hand_actions = util.right_hand_actions if is_right_hand else util.left_hand_actions + util.keyframe_insert(bones, 'location', current_frame) + current_frame += frame_jump + util.setPose(hand_actions, hand_param, [current_frame], bones) + current_frame += 2* frame_jump + hand_param = [js_movement['configuracao'], js_movement['articulacao_final'], js_movement['orientacao']] + util.setPose(hand_actions, hand_param, [current_frame], bones) + util.keyframe_insert(bones, 'location', current_frame) + return current_frame \ No newline at end of file diff --git a/util.py b/util.py index 54da396..919cb68 100644 --- a/util.py +++ b/util.py @@ -225,6 +225,7 @@ def configure_output(): def render_sign(user_id, nome_sinal = "sinal", frame_final = bpy.context.scene.frame_end): getcwd = os.path.dirname(os.path.abspath(__file__)) bpy.context.scene.render.filepath = getcwd + "/users/" + str(user_id) + "/"+ nome_sinal + "_" + bpy.ops.wm.save_as_mainfile(filepath=getcwd + "/users/" + str(user_id) + "/"+ nome_sinal + ".blend") bpy.context.scene.frame_end = frame_final pyutil.log("Gerando Video... Frames: %i" % (frame_final)) bpy.ops.render.render(animation = True, write_still = False, layer = "", scene = "") -- libgit2 0.21.2