def thumb_range(auth_key, event, t0, t1, num, off): num = int(num) off = int(off) if not (0 < num <= 16): bottle.abort(400) if not (0 <= off < num): bottle.abort(400) t0f = float(t0) t1f = float(t1) rows = EVENT_ROWS[event] times = EVENT_ROW_TIMES[event] # Left: >= time Right: <= time i, j = get_row_bounds(times, t0f, t1f) print((i, j)) if i != len(times) and j: rows = rows[i:j - 1] skip = 1 if len(rows) > num: skip = len(rows) / num bottle.response.headers['Content-Type'] = 'image/jpeg' bottle.response.headers['Cache-Control'] = 'max-age=2592000' return CLIENT.get_row('images', rows[off * skip], columns=[THUMB_COLUMN])[THUMB_COLUMN] bottle.abort(404)
def extract_data(): global event_sensor_values for d in [DATA['movement']]: # DATA['scene'] cm = {x: {y: 0 for y in d.keys()} for x in d.keys()} # [true][pred] for class_name, slices in d.items(): print(class_name) for s in slices: event = s['event'] row_start, row_stop = get_row_bounds(EVENT_ROW_TIMES[event], s['start'], s['stop']) times = EVENT_ROW_TIMES[event][row_start:row_stop] for _, _, cn in classify_slice(EVENT_ROWS[event][row_start:row_stop], ROW_COLUMNS, times[0], times[-1]): # TODO: Need to fix for other types c = CLASSES['locomotion'][cn['locomotion']] print((class_name, c)) cm[class_name][c] += 1 print(cm)
def extract_data(): global event_sensor_values for d in [DATA['movement']]: # DATA['scene'] cm = {x: {y: 0 for y in d.keys()} for x in d.keys()} # [true][pred] for class_name, slices in d.items(): print(class_name) for s in slices: event = s['event'] row_start, row_stop = get_row_bounds(EVENT_ROW_TIMES[event], s['start'], s['stop']) times = EVENT_ROW_TIMES[event][row_start:row_stop] for _, _, cn in classify_slice( EVENT_ROWS[event][row_start:row_stop], ROW_COLUMNS, times[0], times[-1]): # TODO: Need to fix for other types c = CLASSES['locomotion'][cn['locomotion']] print((class_name, c)) cm[class_name][c] += 1 print(cm)
def thumb_range(auth_key, event, t0, t1, num, off): num = int(num) off = int(off) if not (0 < num <= 16): bottle.abort(400) if not (0 <= off < num): bottle.abort(400) t0f = float(t0) t1f = float(t1) rows = EVENT_ROWS[event] times = EVENT_ROW_TIMES[event] # Left: >= time Right: <= time i, j = get_row_bounds(times, t0f, t1f) if i != len(times) and j: rows = rows[i:j - 1] skip = 1 if len(rows) > num: skip = len(rows) / num bottle.response.headers['Content-Type'] = 'image/jpeg' bottle.response.headers['Cache-Control'] = 'max-age=2592000' return CLIENT.get_row('images', rows[off * skip], columns=[THUMB_COLUMN])[THUMB_COLUMN] bottle.abort(404)