Open Madhusakth opened 2 years ago
Hi~ You can take this code from Oxford radar-robotcar-dataset for reference I've already modified a little bit to fit the polar data provided by Radiate.
def from_polar_to_cart(raw_example_data, cart_resolution: float, cart_pixel_width: int, interpolate_crossover=True):
radar_resolution = np.array([0.0432], np.float32)
azimuths = np.arange(400) * (math.pi/180)*0.9
raw_example_data = raw_example_data.T
fft_data = raw_example_data[:, :].astype(np.float32)[:, :, np.newaxis] / 255.
if (cart_pixel_width % 2) == 0:
cart_min_range = (cart_pixel_width / 2 - 0.5) * cart_resolution
else:
cart_min_range = cart_pixel_width // 2 * cart_resolution
coords = np.linspace(-cart_min_range, cart_min_range, cart_pixel_width, dtype=np.float32)
Y, X = np.meshgrid(coords, -coords)
sample_range = np.sqrt(Y * Y + X * X)
sample_angle = np.arctan2(Y, X)
sample_angle += (sample_angle < 0).astype(np.float32) * 2. * np.pi
# Interpolate Radar Data Coordinates
azimuth_step = azimuths[1] - azimuths[0]
sample_u = (sample_range - radar_resolution / 2) / radar_resolution
sample_v = (sample_angle - azimuths[0]) / azimuth_step
# We clip the sample points to the minimum sensor reading range so that we
# do not have undefined results in the centre of the image. In practice
# this region is simply undefined.
sample_u[sample_u < 0] = 0
if interpolate_crossover:
fft_data = np.concatenate((fft_data[-1:], fft_data, fft_data[:1]), 0)
sample_v = sample_v + 1
polar_to_cart_warp = np.stack((sample_u, sample_v), -1)
cart_img = np.expand_dims(cv2.remap(fft_data, polar_to_cart_warp, None, cv2.INTER_LINEAR), -1)
return cart_img
Hi,
Would it be possible to share the code you used for converting the radar data from polar to cartesian?
Thanks!