Using webcam to record a specific length of video
14 次查看(过去 30 天)
显示 更早的评论
"I want to record an 8-second video at normal speed using the webcam on my laptop. The requirements are as follows:
- After opening the camera, Matlab will send a trigger, and then start recording; but I think the camera need a warmup time and I dont know how much it is.
- Record the subject's movements in 8 seconds;
- Matlab sends a trigger to end the recording.
%% open camera and record video
clear all;clc;
vobj = videoinput('winvideo', 1);
%% Set Properties for Videoinput Object
vobj.LoggingMode = 'disk&memory';
%% Construct VideoWriter object and set Disk Logger Property
subject_name = 'sl';
v = VideoWriter([date, subject_name,'.avi']);
v.Quality = 50;
v.FrameRate = 60;
vobj.DiskLogger = v;
%% The experiment process
start(vobj)
% need a code to wait camera warm up; it may be the funtion : wait(vobj,
% waittime);
pause(8); % record a 8s video
%% Stop video
stop(vobj)
% Compute actual Frame Rate
elapsedTime = toc;
framesaq = vobj.FramesAcquired;
ActualFR = framesaq/elapsedTime;
% Delete Object
delete(vobj);
1 个评论
Harshit Saini
2023-2-15
Refer to the following documentation link to implement the camera warmup time.
Additionally, you can try to implement wait time using the "wait" function as you have mentioned in the comment. A wait time of 3 seconds should be a good starting point.
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!