SPCSim.data_loaders package

Submodules

SPCSim.data_loaders.perpixel_loaders module

class SPCSim.data_loaders.perpixel_loaders.PerPixelLoader(num_dists=1, min_dist=0, max_dist=1, sig_bkg_list=[[1, 1]], tmax=100, num_runs=1, device='cpu')[source]

Bases: object

This class loads a custom RGB-D image with each row consisting of different distance values and avg signal-background photons and R columns where R is the number of runs to be captured for each pixel with a specific SBR and distance combination.

Note

If A is the output transient matrix then A[i,j] gives readings for dist_idx = i % len(SBR_list), SBR_Pair_idx = (i/num_dists), and Run_idx = j.

get_data()[source]

Method to generate the rgb-d data along with the average signal and background photon flux per cycle.

Returns:

Dictionary containing the generated RGB, distance image, albedo, signal and bkg flux

Return type:

data (dictionary)

get_row(sbr_idx=0, dist_idx=0)[source]

SPCSim.data_loaders.rgbd_loaders module

class SPCSim.data_loaders.rgbd_loaders.NYULoader1(Nr, Nc, crop_r1=44, crop_r2=470, crop_c1=40, crop_c2=600, device='cpu', n_tbins=1000, tmax=100, folder='train')[source]

Bases: RGBDLoader

dist_preproc(dist)[source]

Method to preprocess the distance image

class SPCSim.data_loaders.rgbd_loaders.RGBDLoader(Nr, Nc, crop_r1=0, crop_r2=-1, crop_c1=0, crop_c2=-1, device='cpu', n_tbins=1000, tmax=100, folder='train')[source]

Bases: object

General class to load RGB-D datasets

albedo_preproc(albedo)[source]

Method to preprocess the albedo image

dist_preproc(dist)[source]

Method to preprocess the distance image

get_data(rgb_pth, dist_pth, albedo_pth='', intensity_pth='')[source]

Method to get the RGB-D data

Parameters:
  • rgb_pth (str) – File path to rgb image

  • dist_pth (str) – File path to distance image

  • albedo_pth (str, optional) – _description_. Defaults to “”.

  • intensity_pth (str, optional) – _description_. Defaults to “”.

Returns:

Dictionary containing the rgb, intensity, albedo and distance image

Return type:

data (dictionary)

intensity_preproc(intensity)[source]

Method to preprocess the intensity image

load_albedo(albedo_pth, read_mode=0)[source]

Method to load the albedo image

load_dist(dist_pth)[source]

Method to load the distance image

load_intensity(intensity_pth, read_mode=0)[source]

Method to load the intensity image

load_rgb(rgb_pth)[source]

Method to load the rgb image

Note

The color channels are flipped as cv2.imread reads bgr image instead of rgb

rgb_preproc(rgb)[source]

Method to preprocess the rgb image

SPCSim.data_loaders.transient_loaders module

class SPCSim.data_loaders.transient_loaders.TransientGenerator(Nr=1, Nc=1, N_tbins=1000, tmax=100, FWHM=1, device='cpu')[source]

Bases: object

get_shifted_laser_pulse_mesh(gt_dist)[source]

Method to compute the time shifted gaussian pulse based on the true distance

Parameters:

gt_dist (torch.tensor) – Scene ground truth distance image of dimension (Nr, Nc)

Returns:

Tensor of time shifted laser pulse for each pixel based on the true distance

Return type:

tr (torch.tensor)

get_signal_attenuation(albedo, dist)[source]

Method to calculate attenuation factor from albedo information and dist information.

Parameters:
  • albedo (torch.tensor) – Scene albedo image of dimension (Nr, Nc)

  • dist (torch.tensor) – Scene ground truth distance image of dimension (Nr, Nc)

Returns:

Attenuated signal

Return type:

signal_attn (torch.tensor)

get_transient(gt_dist, albedo, intensity, alpha_sig, alpha_bkg)[source]

Method to add noise and attenuation to ideal transient

Parameters:
  • gt_dist (torch.tensor) – Scene ground truth distance image of dimension (Nr, Nc)

  • albedo (torch.tensor) – Scene albedo image of dimension (Nr, Nc)

  • intensity (torch.tensor) – Scene intensity image of dimension (Nr, Nc)

  • alpha_sig (float) – Average signal photons per laser cycle

  • alpha_bkg (float) – Average background photons per laser cycle (not per bin)

Note

Signal attenuation only depends on scene albedo and background flux depends on the total scene intensity.

Returns:

Time shifted attenuated laser pulse representing the photon density incident on the SPAD camera.

Return type:

r_t1 (torch.tensor)

gt_shift_idx(gt_dist)[source]

Method to compute the peak location in bins unit for given scene distance

Parameters:

gt_dist (torch.tensor) – Scene ground truth distance image of dimension (Nr, Nc)

Returns:

Tensor consisting of integer values corresponding to the peak location.

Return type:

shift_idx (torch.tensor)

Module contents