Using webcam to record a specific length of video

13 views (last 30 days)
"I want to record an 8-second video at normal speed using the webcam on my laptop. The requirements are as follows:
  1. 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.
  2. Record the subject's movements in 8 seconds;
  3. 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 Comment
Harshit Saini
Harshit Saini on 15 Feb 2023
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.

Sign in to comment.

Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!