Filter löschen
Filter löschen

Unable to change frame rate despite adjusting value in videosource

21 Ansichten (letzte 30 Tage)
I am trying to use my camera's 30Hz frame rate while capturing video as directed via matlab. I am able to see that it is able to accomodate this speed (as well as others) when I run:
frameRates = set(src, 'FrameRate')
frameRates =
5×1 cell array
{'30.0000'}
{'20.0000'}
{'15.0000'}
{'10.0000'}
{'7.5000' }
I am also able to set the videosource 'FrameRate' value to '30.0000' using:
set(getselectedsource(pupilCam),'FrameRate',frameRates{1});
get(src, 'FrameRate')
ans =
'30.0000'
However, when I run the following code, based off of previous community help pages, I'm finding that the experimental frame rate is almost exactly the lowest possible one of 7.5Hz. I've even reduced the quality of the video to a lower resolution, but this hasn't changed anything in terms of frame rate. I'm putting my full code below:
recLen = 5; % seconds
imaqmex('feature','-limitPhysicalMemoryUsage',false); % won't work without this
pupilCam = videoinput('winvideo','Microsoft® LifeCam HD-6000 for Notebooks','MJPG_640x480');
% determine frame rate to be fastest
src = getselectedsource(pupilCam);
frameRates = set(src, 'FrameRate')
src.FrameRate = frameRates{1};
set(getselectedsource(pupilCam),'FrameRate',frameRates{1});
get(src, 'FrameRate')
actualRate = str2num( frameRates{1} );
pupilCam.FramesPerTrigger = actualRate * recLen;
% start acquiring images.
start(pupilCam);
waittime = actualRate * (pupilCam.FramesPerTrigger + pupilCam.TriggerFrameDelay) + 5;
wait(pupilCam, waittime);
[frames, timeStamp] = getdata(pupilCam);
1/mean(diff(timeStamp)) % This reports back the value of ~7.49 every time
Please help me to understand what I'm doing wrong. Thank you!

Akzeptierte Antwort

Gowtham
Gowtham am 27 Sep. 2023
Hello Douglas,
I understand that you are using a video input with an adaptor to process it with a specific frame rate, but always getting the experimental frame rate as the least possible value which is not expected.
The code you provided sets up a video input from a 'Microsoft LifeCam HD-6000 for Notebooks' and attempts to determine the frame rate.
I tried to reproduce the same at my end by altering the input adaptor to winvideo and utilizing the system's default camera. I found that the code performed smoothly, resulting in an approximate frame rate of 30. This observation indicates that the problem may be associated with the specific video input adaptor you are currently utilizing.
Additionally, I would like to suggest ensuring proper light exposure during the testing process.
For a sample demonstration of the above process, kindly refer to the updated code snippet provided below:
recLen = 5; % seconds
imaqmex('feature','-limitPhysicalMemoryUsage',false); % won't work without this
pupilCam = videoinput('winvideo', 1, 'YUY2_1280x720');
% pupilCam = videoinput('winvideo','Microsoft® LifeCam HD-6000 for Notebooks','MJPG_640x480');
% determine frame rate to be fastest
% https://www.mathworks.com/add-ons/KINECT/?s_tid=srchtitle
src = getselectedsource(pupilCam);
frameRates = set(src, 'FrameRate');
src.FrameRate = frameRates{1};
set(getselectedsource(pupilCam),'FrameRate',frameRates{1});
get(src, 'FrameRate')
actualRate = str2num( frameRates{1} );
pupilCam.FramesPerTrigger = actualRate * recLen;
% start acquiring images.
start(pupilCam);
waittime = actualRate * (pupilCam.FramesPerTrigger + pupilCam.TriggerFrameDelay) + 5;
wait(pupilCam, waittime);
[frames, timeStamp] = getdata(pupilCam);
result = 1/mean(diff(timeStamp)); % This reports back the value of ~7.49 every time
result
Here is the output generated by the code snippet provided above:
To obtain more information about the installed adaptors, you may consider running the command imaqhwinfo in the MATLAB Command Window.
Kindly refer to the following MATLAB documentation for further understanding on videoinput and installed adaptors
Hope this helps.
Best Regards,
Gowtham
  1 Kommentar
Douglas Vormstein-Schneider
Douglas Vormstein-Schneider am 27 Sep. 2023
Thank you Gowtham, this was very helpful. I was able to get the reported framerate to approximately match the set framerate.

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by