def save_phase_data(bin_path, save_path, start_bin, end_bin, num_frames, chirp_index=5, is_diff=True): if is_diff: num_frames -= 1 # load Numpy Data adc_data = np.fromfile(bin_path, dtype=np.int16) adc_data = adc_data.reshape(numFrames, -1) adc_data = np.apply_along_axis(DCA1000.organize, 1, adc_data, num_chirps=numChirpsPerFrame, num_rx=numRxAntennas, num_samples=numADCSamples) range_data = dsp.range_processing(adc_data, window_type_1d=Window.BLACKMAN) range_data = arange_tx(range_data, num_tx=numTxAntennas) range_data = range_data[:, chirp_index, :, start_bin:end_bin] range_data = range_data.transpose((1, 2, 0)) # angle and unwrap sig_phase = np.angle(range_data) sig_phase = np.unwrap(sig_phase) # save file np.save(save_path, sig_phase) print("{} npy file saved!".format(save_path))
def plot_heatmap_capon(adc_data_path, save_path, bin_start=4, bin_end=14, diff=False, is_log=False, remove_clutter=True, cumulative=False): num_bins = bin_end - bin_start npy_azi = np.zeros((numFrames, ANGLE_BINS, num_bins)) npy_ele = np.zeros((numFrames, ANGLE_BINS, num_bins)) adc_data = np.fromfile(adc_data_path, dtype=np.int16) adc_data = adc_data.reshape(numFrames, -1) adc_data = np.apply_along_axis(DCA1000.organize, 1, adc_data, num_chirps=numChirpsPerFrame, num_rx=numRxAntennas, num_samples=numADCSamples) # Start DSP processing range_azimuth = np.zeros((ANGLE_BINS, BINS_PROCESSED)) range_elevation = np.zeros((ANGLE_BINS, BINS_PROCESSED)) num_vec, steering_vec = dsp.gen_steering_vec(ANGLE_RANGE, ANGLE_RES, VIRT_ANT_AZI) num_vec_ele, steering_vec_ele = dsp.gen_steering_vec(ANGLE_RANGE, ANGLE_RES, VIRT_ANT_ELE) if cumulative: cum_azi = np.zeros((ANGLE_BINS, num_bins)) cum_ele = np.zeros((ANGLE_BINS, num_bins)) if diff: pre_h = np.zeros((ANGLE_BINS, num_bins)) pre_e = np.zeros((ANGLE_BINS, num_bins)) for frame_index in range(numFrames): frame = adc_data[frame_index] radar_cube = dsp.range_processing(frame) # virtual antenna arrangement radar_cube = arange_tx(radar_cube, num_tx=numTxAntennas, vx_axis=1, axis=0) # --- static clutter removal if remove_clutter: mean = radar_cube.mean(0) radar_cube = radar_cube - mean # --- capon beamforming radar_cube_azi = radar_cube[:, VIRT_ANT_AZI_INDEX, :] radar_cube_ele = radar_cube[:, VIRT_ANT_ELE_INDEX, :] # Note that when replacing with generic doppler estimation functions, radarCube is interleaved and # has doppler at the last dimension. for i in range(BINS_PROCESSED): range_azimuth[:, i], _ = dsp.aoa_capon(radar_cube_azi[:, :, i].T, steering_vec, magnitude=True) range_elevation[:, i], _ = dsp.aoa_capon(radar_cube_ele[:, :, i].T, steering_vec_ele, magnitude=True) """ 3 (Object Detection) """ if is_log: heatmap_azi = 20 * np.log10(range_azimuth[:, bin_start:bin_end]) heatmap_ele = 20 * np.log10(range_elevation[:, bin_start:bin_end]) else: heatmap_azi = range_azimuth[:, bin_start:bin_end] heatmap_ele = range_elevation[:, bin_start:bin_end] if cumulative: cum_azi += heatmap_azi cum_ele += heatmap_ele if diff: heatmap_azi = heatmap_azi - pre_h heatmap_ele = heatmap_ele - pre_e pre_h = heatmap_azi pre_e = heatmap_ele # normalize # heatmap_azi = heatmap_azi / heatmap_azi.max() # heatmap_ele = heatmap_ele / heatmap_ele.max() npy_azi[frame_index] = heatmap_azi npy_ele[frame_index] = heatmap_ele save_path_azi = save_path + "_azi" save_path_ele = save_path + "_ele" np.save(save_path_azi, npy_azi) np.save(save_path_ele, npy_ele) print("{} npy file saved!".format(save_path))
MapRecord(x.strip().split(), root_path) for x in open(annotaton_path) ] half_attention = True plot_debug = True for record in record_list: if record.index_err == 1: adc_data = np.fromfile(record.path, dtype=np.int16) adc_data = adc_data.reshape(numFrames, -1) adc_data = np.apply_along_axis(DCA1000.organize, 1, adc_data, num_chirps=numChirpsPerFrame, num_rx=numRxAntennas, num_samples=numADCSamples) print("{} >> Data Loaded!".format(record.path)) # processing range data range_data = dsp.range_processing(adc_data, window_type_1d=Window.HANNING) # reshape frame data range_data = arange_tx(range_data, num_tx=numTxAntennas) b_index = 8 out = peak_detection(range_data[..., b_index], half=half_attention, plot=plot_debug)