120 Frame per second USB camera

조회 수: 10 (최근 30일)
Tala
Tala 2025년 2월 14일
이동: Cris LaPierre 2025년 2월 15일
I have a camera that supports 120fps at 1920x1080. The camera is connected to my laptop with a USB cable.
I am trying to get to 120 fps in matlab but when I run this code:
cam=webcam('HD USB Camera');
cam.Resolution = '1920x1080';
set(src, 'FrameRate','120');
I get the following error.
'FrameRate' value must be {30.0000}.
I am happy to go to lower resulutions (800x600) to get 120 fps.
What am I missing?
Thanks for your help
  댓글 수: 2
Walter Roberson
Walter Roberson 2025년 2월 15일
You should check
cam.AvailableResolutions
Tala
Tala 2025년 2월 15일
Thanks Walter. I have 23 resolutions and formats avaiable. WHen I look at the camera propoerties on windows, I should be able to get 1920x1080 @ 120 fps. How can I set that in matlab?
Thanks for your support.

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

채택된 답변

Cris LaPierre
Cris LaPierre 2025년 2월 15일
이동: Cris LaPierre 2025년 2월 15일
When using webcam, it appears that FrameRate is a read-only property (i.e. can't be modified). See here.
It may be possible to use the Image Processing Toolbox to acquire images at any framerate the device supports. I'm just not sure if usb cameras are somehow different. I don't think so.
See this answer and this doc page.

추가 답변 (1개)

Umar
Umar 2025년 2월 15일

Hi @Tala,

After reviewing your comments and going through documentation provided at the link below

https://www.mathworks.com/help/matlab/supportpkg/set-properties-for-webcam-acquisition.html

You can resolve the issue of capturing video at 120 fps with your webcam in MATLAB by considering a few important points regarding camera capabilities and MATLAB's handling of webcam properties.

1. Webcam Capabilities: Not all webcams can support high frame rates at high resolutions. In your case, while your camera can record at 1920x1080 resolution, it appears that it only supports a maximum frame rate of 30 fps at this resolution. This limitation is common among many webcams, especially consumer-grade models. The ability to record at 120 fps often requires lower resolutions, such as 800x600 or 640x480.

2. MATLAB's Webcam Object: The error message you received (`'FrameRate' value must be {30.0000}`) indicates that MATLAB has detected that the maximum supported frame rate for your camera at the selected resolution is indeed 30 fps. The `FrameRate` property in MATLAB is read-only for certain cameras, meaning it reflects what the camera can actually provide.

3. Changing Resolution for Higher Frame Rate: To achieve 120 fps, you will need to switch to a lower resolution. Based on your willingness to go down to 800x600, you can try setting the resolution accordingly and then see if you can set the frame rate.

Here’s how you might adjust your code:

% Create webcam object
cam = webcam('HD USB Camera');
% Set resolution to a lower value
cam.Resolution = '800x600';
% Check available resolutions
availableResolutions = cam.AvailableResolutions;
disp('Available Resolutions:');
disp(availableResolutions);
% Try setting frame rate
% Note: FrameRate may not be settable directly depending on your camera
set(cam, 'FrameRate', '120'); % This may still return an error if unsupported

4. Check Available Properties: After adjusting the resolution, check if you can access a higher frame rate by listing out available properties:

   % Display properties of the camera
   disp(cam);

Hope this helps.

  댓글 수: 1
Umar
Umar 2025년 2월 15일

Hi @Tala,

You flagged my comments without reading them. Try to understand what I mentioned, @Cris LaPierre said the same thing, this was mentioned in the documentation in the link provided in my comments above.

2. MATLAB's Webcam Object: The error message you received (`'FrameRate' value must be {30.0000}`) indicates that MATLAB has detected that the maximum supported frame rate for your camera at the selected resolution is indeed 30 fps. The `FrameRate` property in MATLAB is read-only for certain cameras, meaning it reflects what the camera can actually provide.

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

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for IP Cameras에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by