ImageProjection

SmoothParticleNets

Description

The ImageProjection layer projects an image feature map onto a set of particles in the view frame of the camera. That is, given an image of C channels, it first projects each particle onto the image using given camera intrinsics (focal length, etc.) and extrinsics (pose). Then it uses bilinear interpolation between the 4 adjacent pixels to generate a feature vector for the given particle. The output is a C-length feature vector for each particle. The ImageProjection layer currently only supports 3D coordinate spaces.

ImageProjection is implemented as a subclass of torch.nn.Module. This allows it to be used in the same manner as any other PyTorch layer (e.g., conv2d). ImageProjection can compute gradients with respect to the camera or particle poses and the image features, and is implemented with Cuda support for efficient computation.

Example

Assume locs is a BxNxD tensor containing the locations of N D-dimensional particles across B batches and image is a [BxHxWxC] feature image.

# First create the ParticleProjection layer.
proj = ImageProjection(camera_fl=540)
# Setup the camera pose.
camera_pose = torch.Tensor([0.0, 0.0, 0.0])
camera_rotation = torch.Tensor([0.0, 0.0, 0.0, 1.0])
new_data = proj(locs, image, camera_pose, camera_rotation)

Documentation

ImageProjection provides two functions: a constructor and forward. Forward is called by calling the layer object itself (in the same manner as any standard PyTorch layer).