def graph_node_from_query_result(result):
  latest_pose_node = Graph_Nodes()
  latest_pose_node.node_id = result[0]
  latest_pose_node.node_type = result[1]
  latest_pose_node.sp_3d_matches_id = result[2]
  latest_pose_node.global_transformation_filepath = result[3]

  return latest_pose_node
def add_new_feature_node(_3d_matches):
  global session
  feature_node = Graph_Nodes()
  feature_node.node_type = 'feature'
  feature_node.sp_3d_matches_id = _3d_matches.sp_3d_matches_id

  session.add(feature_node)
  session.commit()
  return feature_node
def add_new_wpi_feature_node(_3d_matches):
  global session
  feature_node = Graph_Nodes()
  feature_node.node_type = 'wpi_feature'
  feature_node.sp_3d_matches_id = _3d_matches.sp_3d_matches_id

  #this is a wpi node, so optimal global transform is identity

  session.add(feature_node)
  session.commit()

  global_R = np.array([[1, 0, 0], [0, 1, 0], [0, 0, 1]])
  global_t = np.array([[0], [0], [0]])

  transform = [global_R.tolist(), global_t.tolist()]

  global_transform_filepath = save_transform(transform, feature_node)
  feature_node.global_transformation_filepath = global_transform_filepath

  session.commit()
  return feature_node
def create_pose_node(stereo_image_pair_id):
  global session
  global initial_node_set
  global is_debug

  node = Graph_Nodes()
  node.stereo_image_pair_id = stereo_image_pair_id
  node.node_type = 'pose'

  session.add(node)
  session.commit()

  #if we're debugging, set the first node to global coordinates
  if(is_debug and not initial_node_set):
    initial_node_set = True
    T = get_identity_transform()
    filepath = save_global_transform(T, node)
    node.global_transformation_filepath = filepath

  session.commit()
  return node