Commit 42629259 authored by Vincent POLLET's avatar Vincent POLLET

[DOC] remove unecessary files, small doc changes

parent 8ea8f474
Pipeline #46652 failed with stages
in 52 seconds
import bob.io.stream
import numpy as np
import bob.io.base
import bob.io.image
import cv2 as cv
import os
d = '/remote/idiap.svm/project.batl/datasets/idiap-batl-phase-2/face-station'
print('hello')
for root, dirs, files in os.walk(d, topdown=False):
for name in files:
path = os.path.join(root, name)
print(name, path)
f = bob.io.stream.StreamFile( path,
'/idiap/temp/dgeissbuhler/batl2_pre/bob.io.stream/bob/io/stream/config/batl2_idiap_config.json')
###
color = f.stream('color')
nir_left = f.stream('nir_left_stereo')
nir_right = f.stream('nir_right_stereo')
nir_left_dark = f.stream('nir_left')
nir_right_dark = f.stream('nir_right')
map_3d = nir_left.stereo(nir_right)
map_3d_dark = nir_left_dark.stereo(nir_right_dark)
rep_color = color.reproject(nir_left, nir_right, map_3d)
rep_color_dark = color.reproject(nir_left, nir_right, map_3d_dark)
# load
data_map_3d = map_3d[0][:,0:1600,400:1200]
data_map_3d_dep = data_map_3d[0]
data_rep_color = rep_color[0][:,0:1600,400:1200]
data_map_3d_dark = map_3d_dark[0][:,0:1600,400:1200]
data_map_3d_dep_dark = data_map_3d_dark[0]
data_rep_color_dark = rep_color_dark[0][:,0:1600,400:1200]
# export
tmin = np.amin(data_map_3d_dep)
tmax = np.amax(data_map_3d_dep)
tmin_dark = np.amin(data_map_3d_dep_dark)
tmax_dark = np.amax(data_map_3d_dep_dark)
tmin = min(tmin, tmin_dark)
tmax = max(tmax, tmax_dark)
exp_map_depth = (data_map_3d_dep - tmin).astype('float')
exp_map_depth = (exp_map_depth * 255.0 / float(tmax - tmin)).astype('uint8')
exp_map_depth= cv.applyColorMap(exp_map_depth, cv.COLORMAP_JET)
exp_map_depth = np.moveaxis(exp_map_depth, 2, 0)
exp_color = np.flip(data_rep_color, axis=0)
exp_map_depth_dark = (data_map_3d_dep_dark - tmin).astype('float')
exp_map_depth_dark = (exp_map_depth_dark * 255.0 / float(tmax - tmin)).astype('uint8')
exp_map_depth_dark = cv.applyColorMap(exp_map_depth_dark, cv.COLORMAP_JET)
exp_map_depth_dark = np.moveaxis(exp_map_depth_dark, 2, 0)
exp_color_dark = np.flip(data_rep_color_dark, axis=0)
print(exp_map_depth.shape, exp_map_depth_dark.shape)
exp_top = np.concatenate((exp_map_depth, exp_map_depth_dark), axis=2)
print(exp_color.shape, exp_color_dark.shape)
exp_bot = np.concatenate((exp_color, exp_color_dark), axis=2)
exp = np.concatenate((exp_top, exp_bot), axis=1)
out_dir = '/idiap/temp/dgeissbuhler/batl2_pre/viz_compare/'
bob.io.base.save(exp, os.path.join(out_dir, name) + '.png')
import bob.io.stream
import numpy as np
import bob.io.base
import bob.io.image
import cv2 as cv
import os
local = True
if local:
input_dir = '/Users/david/Desktop/idiap/data'
input_config = '/Users/david/Desktop/idiap/bob.io.stream/bob/io/stream/config/batl2_idiap_config.json'
out_dir = '/Users/david/Desktop/idiap/viz/'
else:
input_dir = '/remote/idiap.svm/project.batl/datasets/idiap-batl-phase-2/face-station'
input_config = '/idiap/temp/dgeissbuhler/batl2_pre/bob.io.stream/bob/io/stream/config/batl2_idiap_config.json'
out_dir = '/idiap/temp/dgeissbuhler/batl2_pre/viz/'
for root, dirs, files in os.walk(input_dir, topdown=False):
for name in files:
path = os.path.join(root, name)
print(name, path)
f = bob.io.stream.StreamFile(path, input_config)
# define streams
color = f.stream('color')
depth = f.stream('depth').clean()
nir_left = f.stream('nir_left') #_stereo')
nir_right = f.stream('nir_right') #_stereo')
nir_left_735nm = f.stream('nir_left_735nm')
nir_left_850nm = f.stream('nir_left_850nm')
nir_left_940nm = f.stream('nir_left_940nm')
nir_left_1050nm = f.stream('nir_left_1050nm')
nir_left_stereo = f.stream('nir_left_stereo')
swir_940nm = f.stream('swir_940nm').clean()
swir_1050nm = f.stream('swir_1050nm').clean()
swir_1200nm = f.stream('swir_1200nm').clean()
swir_1300nm = f.stream('swir_1300nm').clean()
swir_1450nm = f.stream('swir_1450nm').clean()
swir_1550nm = f.stream('swir_1550nm').clean()
swir_1650nm = f.stream('swir_1650nm').clean()
thermal = f.stream('thermal')
map_3d = nir_left.stereo(nir_right)
swir_norm = swir_1050nm.normalize().stack(swir_1300nm.normalize()).stack(swir_1550nm.normalize())
nir_norm = nir_left_940nm.normalize().stack(nir_left_850nm.normalize()).stack(nir_left_735nm.normalize())
rep_color = color.reproject(nir_left, nir_right, map_3d)
rep_nir_left = nir_left.reproject(nir_left, nir_right, map_3d)
rep_nir_right = nir_right.reproject(nir_left, nir_right, map_3d)
rep_swir_norm = swir_norm.reproject(nir_left, nir_right, map_3d)
rep_thermal = thermal.normalize().reproject(nir_left, nir_right, map_3d)
rep_nir_norm = nir_norm.reproject(nir_left, nir_right, map_3d)
warp_depth = depth.warp(nir_left).normalize(tmin=450, tmax=750)
# load
data_map_3d = map_3d[0][:,100:1500,400:1200]
data_map_3d_dep = data_map_3d[0]
data_rep_thermal = rep_thermal[0][:,100:1500,400:1200]
data_rep_nir_left = rep_nir_left[0][:,100:1500,400:1200]
data_rep_color = rep_color[0][:,100:1500,400:1200]
data_rep_nir_right = rep_nir_right[0][:,100:1500,400:1200]
data_rep_swir_norm = rep_swir_norm[0][:,100:1500,400:1200]
data_rep_nir_norm = rep_nir_norm[0][:,100:1500,400:1200]
data_depth = warp_depth[0][:,100:1500,400:1200]
# export
tmin = np.amin(data_map_3d_dep)
tmax = np.amax(data_map_3d_dep)
exp_map_depth = (data_map_3d_dep - tmin).astype('float')
exp_map_depth = (exp_map_depth * 255.0 / float(tmax - tmin)).astype('uint8')
exp_map_depth= cv.applyColorMap(exp_map_depth, cv.COLORMAP_JET)
exp_map_depth = np.moveaxis(exp_map_depth, 2, 0)
exp_intel_depth = cv.applyColorMap(data_depth[0], cv.COLORMAP_JET)
exp_intel_depth = np.moveaxis(exp_intel_depth, 2, 0)
exp_thermal = data_rep_thermal[0].astype('uint8')
exp_thermal = cv.applyColorMap(exp_thermal, cv.COLORMAP_JET)
exp_thermal = np.moveaxis(exp_thermal, 2, 0)
exp_color = np.flip(data_rep_color, axis=0)
exp_nir_l = data_rep_nir_left[0]
tmin = np.amin(exp_nir_l)
tmax = np.amax(exp_nir_l)
exp_nir_l = (exp_nir_l - tmin).astype('float')
exp_nir_l = (exp_nir_l * 255.0 / float(tmax - tmin)).astype('uint8')
exp_nir_r = data_rep_nir_right[0]
tmin = np.amin(exp_nir_r)
tmax = np.amax(exp_nir_r)
exp_nir_r = (exp_nir_r - tmin).astype('float')
exp_nir_r = (exp_nir_r * 255.0 / float(tmax - tmin)).astype('uint8')
exp_nir_rl = np.stack([exp_nir_l, exp_nir_l/2 + exp_nir_r/2 , exp_nir_r]).astype('uint8')
exp_rep_nir_norm = data_rep_nir_norm.astype('uint8')
exp_rep_swir_norm = data_rep_swir_norm.astype('uint8')
exp_top = np.concatenate((exp_map_depth, exp_color, exp_rep_swir_norm), axis=2)
exp_bot = np.concatenate((exp_intel_depth, exp_rep_nir_norm, exp_thermal), axis=2)
print(exp_top.shape, exp_bot.shape)
exp = np.concatenate((exp_top, exp_bot), axis=1)
bob.io.base.save(exp, os.path.join(out_dir, name) + '.png')
import bob.io.stream
import numpy as np
import bob.io.base
import bob.io.image
import cv2 as cv
import os
d = '/remote/idiap.svm/project.batl/datasets/idiap-batl-phase-2/face-station'
for root, dirs, files in os.walk(d, topdown=False):
for name in files:
path = os.path.join(root, name)
print(name, path)
f = bob.io.stream.StreamFile( path,
'/idiap/temp/dgeissbuhler/batl2_pre/bob.io.stream/bob/io/stream/config/batl2_idiap_config.json')
print('available streams:')
for k in f.get_available_streams():
print(k)
print()
###
color = f.stream('color')
print('available filters:')
for k in color.get_available_filters():
print(k)
print()
# define pipelines
nir_left = f.stream('nir_left_stereo')
nir_right = f.stream('nir_right_stereo')
nir_735 = f.stream('nir_left_735nm')
nir_850 = f.stream('nir_left_850nm')
nir_940 = f.stream('nir_left_940nm')
swir_1050 = f.stream('swir_1050nm').clean()
swir_1300 = f.stream('swir_1300nm').clean()
swir_1550 = f.stream('swir_1550nm').clean()
thermal = f.stream('thermal')
swir = swir_1550.stack(swir_1300).stack(swir_1050)
swir_norm = swir_1550.normalize().stack(swir_1300.normalize()).stack(swir_1550.normalize())
nir = nir_940.stack(nir_850).stack(nir_735)
nir_norm = nir_940.normalize().stack(nir_850.normalize()).stack(nir_735.normalize())
nir_left_gray = nir_left.to_rgb(mode='gray')
map_3d = nir_left.stereo(nir_right)
rep_color = color.reproject(nir_left, nir_right, map_3d)
rep_nir_left = nir_left.reproject(nir_left, nir_right, map_3d)
rep_nir_right = nir_right.reproject(nir_left, nir_right, map_3d)
rep_swir = swir.reproject(nir_left, nir_right, map_3d)
rep_swir_norm = swir_norm.reproject(nir_left, nir_right, map_3d)
rep_thermal = thermal.normalize().reproject(nir_left, nir_right, map_3d)
rep_nir = nir.reproject(nir_left, nir_right, map_3d)
rep_nir_norm = nir_norm.reproject(nir_left, nir_right, map_3d)
rep_swir_1300 = swir_1300.normalize().reproject(nir_left, nir_right, map_3d)
# load
data_map_3d = map_3d[0][:,0:1600,400:1200]
data_map_3d_dep = data_map_3d[0]
data_rep_thermal = rep_thermal[0][:,0:1600,400:1200]
data_rep_nir_left = rep_nir_left[0][:,0:1600,400:1200]
data_rep_color = rep_color[0][:,0:1600,450:1200]
data_rep_nir_right = rep_nir_right[0][:,0:1600,400:1200]
data_rep_swir = rep_swir[0][:,0:1600,400:1200]
data_rep_swir_norm = rep_swir_norm[0][:,0:1600,400:1200]
data_rep_nir = rep_nir[0][:,0:1600,400:1200]
data_rep_nir_norm = rep_nir_norm[0][:,0:1600,400:1200]
# export
tmin = np.amin(data_map_3d_dep)
tmax = np.amax(data_map_3d_dep)
exp_map_depth = (data_map_3d_dep - tmin).astype('float')
exp_map_depth = (exp_map_depth * 255.0 / float(tmax - tmin)).astype('uint8')
exp_map_depth= cv.applyColorMap(exp_map_depth, cv.COLORMAP_JET)
exp_map_depth = np.moveaxis(exp_map_depth, 2, 0)
exp_thermal = data_rep_thermal[0].astype('uint8')
exp_thermal = cv.applyColorMap(exp_thermal, cv.COLORMAP_JET)
exp_thermal = np.moveaxis(exp_thermal, 2, 0)
exp_color = np.flip(data_rep_color, axis=0)
exp_nir_l = data_rep_nir_left[0]
tmin = np.amin(exp_nir_l)
tmax = np.amax(exp_nir_l)
exp_nir_l = (exp_nir_l - tmin).astype('float')
exp_nir_l = (exp_nir_l * 255.0 / float(tmax - tmin)).astype('uint8')
exp_nir_r = data_rep_nir_right[0]
tmin = np.amin(exp_nir_r)
tmax = np.amax(exp_nir_r)
exp_nir_r = (exp_nir_r - tmin).astype('float')
exp_nir_r = (exp_nir_r * 255.0 / float(tmax - tmin)).astype('uint8')
exp_nir_rl = np.stack([exp_nir_l, exp_nir_l/2 + exp_nir_r/2 , exp_nir_r]).astype('uint8')
exp_rep_nir_norm = data_rep_nir_norm.astype('uint8')
exp_rep_swir_norm = data_rep_swir_norm.astype('uint8')
exp = np.concatenate((exp_map_depth, exp_color, exp_nir_rl, exp_rep_nir_norm, exp_rep_swir_norm, exp_thermal), axis=2)
out_dir = '.'
bob.io.base.save(exp, os.path.join(out_dir, name) + '.png')
......@@ -679,7 +679,11 @@ class StreamView(StreamFilter):
# separate frame (axis = 0) and bulk (axis > 0) views
self.frame_view = view_indices[0]
# TODO should case with int on frame index be allowed?
assert self.frame_view is None or isinstance(self.frame_view, slice)
if isinstance(self.frame_view, int):
raise ValueError(
"Can not slice into a single frame. To perform this operation, select first the frame and apply "
"slicing on the numpy array."
)
# bulk views
if len(view_indices) > 1:
self.bulk_view = view_indices[1:]
......
......@@ -95,33 +95,6 @@ def rotate_data(data, angle):
return data
def _crop(video, mask, crop):
"""Crops each image in `video` and associated `mask` to region defined by `crop`.
Parameters
----------
video : :obj:`numpy.ndarray`
Video to crop.
mask : :obj:`numpy.ndarray`
Mask associated with`video`.
crop : tuple
(start_x, start_y, width, height): the two first elements are the starting coordinates of the region to keep in
`video`. The 2 last elements are the width and heigth of the region to keep.
Returns
-------
:obj:`tuple` of :obj:`numpy.ndarray`
Cropped video and associated mask.
"""
startx = crop[0]
starty = crop[1]
width = crop[2]
height = crop[3]
video = video[..., starty : starty + height, startx : startx + width]
mask = mask[..., starty : starty + height, startx : startx + width]
return video, mask
def get_index_list(index, size):
"""From an indexing value of type int, slice, list or None, generates the equivalent list of indices in a 1d array.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment