plot with reversed y-axis in a normal y-axis
10 ビュー (過去 30 日間)
古いコメントを表示
I have a video plotted (or played frame by fame) and I want to plot a shape representing the corresponding eye position.
The video has its y-axis reversed (can't control it) (0 up). The eye position is with coordinates in which the y-axis is normal (0 at bottom).
I need to plot this eye position somehow with reversed y-axis on the video.
I'm using insertShape but I can't change the position of the shape to be plotted in a reversed y-axis on the video. I tried flip, axis handel, and many things, nothing is working.
Any suggestion please?!
0 件のコメント
採用された回答
Jack
2023 年 3 月 30 日
You can use the image function in MATLAB to display the video frames and then use insertShape to plot the eye position on top of the frame. To reverse the y-axis, you can set the YDir property of the axes object to 'reverse'. Here's some sample code to get you started:
% Load the video file
v = VideoReader('my_video.mp4');
% Create a figure and axes to display the frames
fig = figure;
ax = axes('Parent', fig);
% Set the y-axis direction to 'reverse'
set(ax, 'YDir', 'reverse');
% Loop through the frames and display them
while hasFrame(v)
frame = readFrame(v);
image(ax, frame);
% Get the eye position for the current frame
eye_pos = [x, y, width, height]; % Replace with your own code
% Plot the eye position on top of the frame
insertShape(ax, 'Rectangle', eye_pos, 'Color', 'red');
% Update the figure
drawnow;
end
In this code, x, y, width, and height are the coordinates of the eye position in a normal y-axis coordinate system. You may need to adjust these values to match the dimensions of your video frames. The insertShape function plots a red rectangle at the specified eye position, and the drawnow function updates the figure to display the current frame with the eye position.
4 件のコメント
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Biotech and Pharmaceutical についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!