Пример #1
0
def _pose_estimator(landmark_array, ret_array, command_queue, command_lock,
                    ret_queue):
    global _MODEL_POSE  # pylint: disable=global-statement
    _LOGGER.info("Pose estimator starting up...")
    if _MODEL_POSE is None:
        _LOGGER.info("Loading pose estimation model...")
        _MODEL_POSE = {}
        for start_idx in tqdm.tqdm(range(13, 79, 3)):
            _MODEL_POSE[start_idx] = joblib.load(
                _path.join(_path.dirname(__file__), '..', 'models', '2dto3d',
                           'separate_regressors',
                           'forest_%d%s.z' % (start_idx, _DEBUG_SFX)))
    ret_queue.put('ready')
    _LOGGER.info("Pose estimator ready.")
    rel_ids = {}
    for start_idx in range(13, 79, 3):
        rel_ids[start_idx] = create_featseltuple(lmset_to_use[(start_idx,
                                                               start_idx + 3)])
    while True:
        cmd = command_queue.get()
        if cmd == 'shutdown':
            break
        with command_lock:
            landmarks = landmark_array.reshape((1, 182)).copy()
        for start_idx in range(13, 79, 3):
            ret_array[start_idx - 13:start_idx -
                      10] = versor_to_axis_angle_ipr(
                          matrix_to_versor(
                              project_to_rot_nofailure_ipr(
                                  _MODEL_POSE[start_idx].predict(landmarks[
                                      0:1,
                                      rel_ids[start_idx]]).astype('float32'))))
        ret_queue.put('done')
    _LOGGER.info("Pose estimator shut down.")
Пример #2
0
def _rot_estimator(landmark_array, ret_array, command_queue, command_lock,
                   ret_queue):
    global _MODEL_ROT, _DTA_ROT  # pylint: disable=global-statement, global-variable-not-assigned
    _LOGGER.info("Rotation estimator starting up...")
    if _MODEL_ROT is None:
        _LOGGER.info("Loading rotation estimation model...")
        _MODEL_ROT = joblib.load(
            _path.join(_path.dirname(__file__), '..', 'models', '2dto3d',
                       'separate_regressors', 'forest_10%s.z' % (_DEBUG_SFX)))
    ret_queue.put('ready')
    _LOGGER.info("Rotation estimator ready.")
    rel_ids = create_featseltuple(lmset_to_use[(10, 13)])
    while True:
        cmd = command_queue.get()
        if cmd == 'shutdown':
            break
        with command_lock:
            landmarks = landmark_array.reshape((1, 182))[0:1, rel_ids].copy()
        #qidx = _MODEL_ROT.query(landmarks.reshape((1, 182)), return_distance=False)[0, 0]
        #ret_array[...] = _DTA_ROT[qidx, 10:13]
        ret_array[...] = versor_to_axis_angle_ipr(
            matrix_to_versor(
                project_to_rot_nofailure_ipr(
                    _MODEL_ROT.predict(landmarks).astype('float32'))))
        ret_queue.put('done')
    _LOGGER.info("Rotation estimator shut down.")
Пример #3
0
def _shape_estimator(landmark_array, ret_array, command_queue, command_lock,
                     ret_queue):
    global _MODEL_SHAPE  # pylint: disable=global-statement
    _LOGGER.info("Shape estimator starting up...")
    if _MODEL_SHAPE is None:
        _LOGGER.info("Loading shape estimation model...")
        _MODEL_SHAPE = joblib.load(
            _path.join(_path.dirname(__file__), '..', 'models', '2dto3d',
                       'separate_regressors', 'forest_0%s.z' % (_DEBUG_SFX)))
    ret_queue.put('ready')
    _LOGGER.info("Shape estimator ready.")
    rel_ids = create_featseltuple(lmset_to_use[(0, 10)])
    while True:
        cmd = command_queue.get()
        if cmd == 'shutdown':
            break
        with command_lock:
            landmarks = landmark_array.reshape((1, 182))[0:1, rel_ids].copy()
        ret_array[...] = _MODEL_SHAPE.predict(landmarks)
        ret_queue.put('done')
    _LOGGER.info("Shape estimator shut down.")