def main():
    level, time = 'moyenne', '9h45'
    level, time = 'faible', '9h28'
    file = config.DICT_DATASET[level][time]
    path = os.path.join('data', file)
    data = open(path)
    raw_data = json.load(data)
    raw_data = data_processing.get_raw_data(raw_data)
    return raw_data
Beispiel #2
0
def main():
    level, time = 'moyenne', '9h45'
    #level, time = 'faible', '9h28'
    file = config.DICT_DATASET[level][time]
    path = os.path.join('data', file)
    data = open(path)
    raw_data = json.load(data)
    raw_data = data_processing.get_raw_data(raw_data)
    raw_data1 = raw_data.copy()
    processed_data = data_processing.processing_by_kalman_filter(raw_data)
    print('processed data ', processed_data[0, :])
    print('mean in z acc processed ', mean(processed_data[:, 2]))
    print()
    print('raw data ', raw_data1[0, :])
    print('mean in z raw data', mean(raw_data1[:, 2]))
    return raw_data1, processed_data
Beispiel #3
0
def movement_detection(raw_data, list_of_state=None):
    """
    :param raw_data: is a dictionnary {'datetime': datetime, 'accelerometer': [{'x': acc_x, 'y': acc_y,
    'z': acc_z}], 'gyroscope': [{'x': gyro_x, 'y': gyro_y, 'z': gyro_z}]}
    last_state = is a dictionary {'datetime': time_of_evenement,  'g_value': force in g, 'state': level_of_evement}
    state : 0: STOP, 1: FORWARD, -1: BACKWARD
    :return: list a dictionnarys of states [{}, {}, {},...]
    """
    raw_data = data_processing.get_raw_data(raw_data)
    data_processed = data_processing.processing_by_kalman_filter(raw_data)
    num_event = 0
    list_of_states = []
    for index, line in enumerate(data_processed):
        print('function is in construction ')
        break
        g_value = utils.calcul_g_value(line[:3])
        this_time = line[-1]
        this_state = utils.find_movement_state(g_value, this_time)
        if not list_of_state:
            list_of_states.append(this_state)
        else:
            if is_tuning_state(state, list_of_state):
                if tuning_step > SKIP_STEP and save_state == find_state(
                        g_value):
                    state = find_state(g_value)
                    time_start_event = time_
                    tuning_step = 0
                    num_event += 1
                else:
                    if save_state == find_state(g_value):
                        tuning_step += 1
                    else:
                        save_state = find_state(g_value)
                        tuning_step = 0
            else:
                if (time_ - time_start_event).total_seconds() > 1:
                    message = get_message(message)
                    time_start_event = time_