Does anyone have a good solution to record a live video feed from an external camera (not the inbuilt webcam) in Matlab?
1 view (last 30 days)
Show older comments
I need to synchronise recording of a specific number of frames from a digital camera (a dslr or compact either outputting a hdmi signal or through usb or similar) with other events controlled by a script. The recording must be more or less instantaneous and time with the other events. I have looked at products from Blackmagic to input a hdmi feed, these work, but the capturing then happens in the Blackmagic software and I have not found a way to trigger the capture from my script. Ideally the frames would be stored directly as Matlab matrices. Does anyone have any tips?
0 Comments
Answers (1)
Samar
on 27 Mar 2025
You can achieve a synchronization between image frames recorded by a camera and other events in a script by using the “MATLAB Support Package for USB Webcam” provided by MathWorks. A “webcam” object can be created using this support package which can access the camera and take snapshots whenever required by leveraging “snapshot” function. I have attached an example MATLAB code which can help you understand the functionality.
Code:
cam = webcam(‘cameraName’); % Connect to the webcam, where ‘cameraname’ is the name of your webcam
numFrames = 100; % Number of frames to capture
frames = cell(1, numFrames);
for i = 1:numFrames
frames{i} = snapshot(cam); % Capture a frame
% Synchronize with other events here
end
clear cam; % Release the camera
To refer the MathWorks documentation of “webcam” class, you can type “doc webcam” in the command prompt window of MATLAB which will open the documentation specific to the MATLAB Release being used.
Hope this helps.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!