120 Frame per second USB camera

50 ビュー (過去 30 日間)
Tala
Tala 2025 年 2 月 14 日 22:51
移動済み: Cris LaPierre 2025 年 2 月 15 日 22:53
この 質問 は Umar さんによってフラグが設定されました
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 日 4:37
You should check
cam.AvailableResolutions
Tala
Tala 2025 年 2 月 15 日 12:19
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 日 13:27
移動済み: Cris LaPierre 2025 年 2 月 15 日 22:53
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 日 4:14
この 回答 は Tala さんによってフラグが設定されました

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 日 16:14

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 Center および File ExchangeMATLAB 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