필터 지우기
필터 지우기

How to log acquired data to disk, and save the video file as mp4 or .avi ?

조회 수: 3 (최근 30일)
Koohyar
Koohyar 2020년 9월 7일
댓글: Koohyar 2020년 9월 9일
Hi,
I am trying to log acquired data to disk, and save the video file as mp4 or .avi, but it doesn't create any file in the folder? Any advice would be appreciated.
thanks.
clear ;
close all;
vid = videoinput('winvideo', 1, 'YUY2_640x480');
vid.Timeout = 20;
set(vid, 'FrameGrabInterval', 2);
vid.LoggingMode = 'disk';
logfile = VideoWriter('MATLAB.mp4', 'MPEG-4')
vid.FramesPerTrigger = 20;
start( vid );
wait( vid, Inf );
[d t] = getdata( vid, vid.FramesAvailable );
fps = 1 / mean( diff( t ) );
vid.ReturnedColorSpace = 'grayscale'
preview(vid);
start(vid);
pause(2);
frames = getdata(vid);
stop(vid)
clear vid

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2020년 9월 7일
Hi,
Probably, you'd need to indicate the directory of your log data as a whole, e.g.: '../dir/videos/MATLAB.mp4'
  댓글 수: 5
Koohyar
Koohyar 2020년 9월 8일
I can log to disk according to another script, but not as 'graysclae', whcih I am looking for! I dont know how can I return the colorspace to graysclae?
vidobj = videoinput('winvideo', 1, 'YUY2_640x480');
vidobj.LoggingMode = 'disk'
vidobj.DiskLogger = VideoWriter('logfile.mp4', 'MPEG-4')
vidobj.ReturnedColorSpace = 'grayscale'
vidobj.FramesPerTrigger = 30;
start(vidobj)
wait(vidobj)
while (vidobj.FramesAcquired ~= vidobj.DiskLoggerFrameCount)
pause(.1)
end
vidobj.FramesAcquired
vidobj.DiskLoggerFrameCoun
delete(vidobj)
clear vidobj

댓글을 달려면 로그인하십시오.

Community Treasure Hunt

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

Start Hunting!

Translated by