-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Code to convert polar to cartesian radar #32
Comments
Hi~ 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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi,
Would it be possible to share the code you used for converting the radar data from polar to cartesian?
Thanks!
The text was updated successfully, but these errors were encountered: