matlab截图问题的办法,MATLAB截图

该代码功能是使用MATLAB记录屏幕活动并输出为AVI格式的视频文件。同时,它将帧保存为JPG格式。录制时间接近实际CPU时间,视频质量良好但文件较大。建议用于较短的视频录制,并可以调整为使用JPG格式以获得更好的质量。用户通过指定电影名称和录制秒数来调用函数,完成后会播放提示音。
摘要由CSDN通过智能技术生成

MATLAB截图

1.[代码][其他]代码

function screen_capture(movie_name,recording_time)

%Can be used to record any screen activity and output

%the recorded actions as video file (MOVIE.avi). It also saves the frames used to

%create the movie in a jpg format frames. The images are named as

%scrcapture -frame number- .jpg

%For example the first frame is named scrcapture1.jpg

%The recording time is almost identical to the actual cpu time.

%The quality of the video is excellent, but the size is big. One is advised

%to record short videos(order of minutes).For even better quality, one could replace the

% png format to jpg(simply uncomment the respective commands).

% to call the function, one types:

%

% screen_capture(movie_name,recording_time)

% where

% movie_name: is a string representing the name of the movie

% recording_time: is the length of the capturing (in seconds)

%To try, one might use the following example:

% screen_capture('movie',30)

%When the code is done writing the movie, a gong sound will be played

%to inform the user that the movie is finished.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

%This function is written by :

% Nassim Khaled

% Wayne State University

% Phd Candidate

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

movie_name1=strcat(movie_name,'.avi')

mov = avifile(movie_name1);

count=0;

robo = java.awt.Robot;

t = java.awt.Toolkit.getDefaultToolkit();

rectangle = java.awt.Rectangle(t.getScreenSize());

number_of_frames=round(recording_time/0.65);

display_time_of_frame=10;

for i=1:number_of_frames

name1=strcat('scrcapture',num2str(i),'.png');

% name1=strcat('scrcapture',num2str(i),'.jpg');

image = robo.createScreenCapture(rectangle);

filehandle = java.io.File(name1);

javax.imageio.ImageIO.write(image,'png',filehandle);

% javax.imageio.ImageIO.write(image,'jpg',filehandle);

end

for i=1:number_of_frames

name1=strcat('scrcapture',num2str(i),'.png');

% name1=strcat('scrcapture',num2str(i),'.jpg');

a=imread(name1);

while count

count=count+1;

F = im2frame(a);

mov=addframe(mov,F);

end

count=0;

end

close all

mov=close(mov);

load gong;

% wavplay(y,Fs)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值