how to plot x y over time

4 ビュー (過去 30 日間)
Korrawit
Korrawit 2024 年 10 月 2 日
回答済み: Yash 2024 年 10 月 4 日
this is te first time i used MATLAB i have eyetrack record like this
eyetrackRecord =
struct with fields:
x: [1.3756e+03 1.3734e+03 1.3798e+03 1.3789e+03 … ] (1×5128 double)
y: [416.1000 415.5000 416.6000 410.8000 … ] (1×5128 double)
pa: [1416 1423 1423 1421 1420 1424 1431 1417 … ] (1×5128 double)
t: [281349 281395 281403 281409 281418 281423 … ] (1×5128 double)
missing: [0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 … ] (1×5128 double)
How can I plot the moving heatmap of gazing over the video file in MATLAB

回答 (1 件)

Yash
Yash 2024 年 10 月 4 日
Since you have the "eyetrackRecord" data variable, you can ustilise the hist3 function to get the heatmap.
numBins = [100, 100];
% Sample data
numPoints = 5000; frameWidth = 1920; frameHeight = 1080;
x = frameWidth * rand(1, numPoints);
y = frameHeight * rand(1, numPoints);
% Create a 2D histogram of the gaze data
heatmapData = hist3([y', x'], 'Nbins', numBins);
% Normalize
heatmapData = heatmapData / max(heatmapData(:));
% Display the heatmap
figure;
imagesc(heatmapData);
colormap('jet'); % Use a colormap to represent the heat values
colorbar;
title('Gaze Heatmap'); xlabel('Horizontal Position'); ylabel('Vertical Position');
axis equal;
set(gca, 'YDir', 'normal'); % Flip the Y-axis to match the image coordinates
I hope this helps!

カテゴリ

Help Center および File ExchangeData Distribution Plots についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by