% load measurement file
tl_content = load(['cfar_10_12_pe' filesep '20200624_Car2_Kreise_1.mat']);

% prepare figure
hfig = figure();
haxes = axes(hfig);

plot_tl_s5 = scatter(nan,nan, 'r', 'filled');
hold(haxes, 'on');
plot_tl_s7 = scatter(nan,nan, 'b', 'filled');
plot_tl_s8 = scatter(nan,nan, 'g', 'filled');

plot_gt_1 = plot(nan, nan, 'k', 'LineWidth', 1.5);
plot_gt_2 = plot(nan, nan, 'k', 'LineWidth', 1.5);
hold(haxes, 'off');

haxes.DataAspectRatio = [1,1,1];
xlim(haxes, [-50,50]);
ylim(haxes, [0,50]);

% plot measurement
num_frames = size(tl_content.data,1);

for i_frame = 1:num_frames
    % plot peak target points of sensor 5
    peak_ids_s5 = tl_content.data.te_peak_ids{i_frame,5};
    plot_tl_s5.XData = tl_content.data.target_list{i_frame,5}.x(peak_ids_s5);
    plot_tl_s5.YData = tl_content.data.target_list{i_frame,5}.y(peak_ids_s5);
    
    % plot peak target points of sensor 7
    peak_ids_s7 = tl_content.data.te_peak_ids{i_frame,7};
    plot_tl_s7.XData = tl_content.data.target_list{i_frame,7}.x(peak_ids_s7);
    plot_tl_s7.YData = tl_content.data.target_list{i_frame,7}.y(peak_ids_s7);
    
    % plot peak target points of sensor 8
    peak_ids_s8 = tl_content.data.te_peak_ids{i_frame,8};
    plot_tl_s8.XData = tl_content.data.target_list{i_frame,8}.x(peak_ids_s8);
    plot_tl_s8.YData = tl_content.data.target_list{i_frame,8}.y(peak_ids_s8);
    
    % plot ground truth OBB of object 1
    gt_1_points = [tl_content.data.ground_truth{i_frame}.polyshape(1).Vertices;
        tl_content.data.ground_truth{i_frame}.polyshape(1).Vertices(1,:)];
    plot_gt_1.XData = gt_1_points(:,1);
    plot_gt_1.YData = gt_1_points(:,2);
    
    % plot ground truth OBB of object 2
    gt_2_points = [tl_content.data.ground_truth{i_frame}.polyshape(2).Vertices;
        tl_content.data.ground_truth{i_frame}.polyshape(2).Vertices(1,:)];
    plot_gt_2.XData = gt_2_points(:,1);
    plot_gt_2.YData = gt_2_points(:,2);
    
    pause(0.1);
%     pause;
end