From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Machine Vision

cancel
Showing results for 
Search instead for 
Did you mean: 

programmatically setting the frame rate of a webcam

Solved!
Go to solution

Hello,

I want to set the frame rate of my webcam to 10fps whose default is 30.Everytime i acquire images it automatically chooses the default value and I have to use property page vi to adjust it......this causes problem as i process the image upon acquisition and it is time synchronized.Hence Iam thinking of setting the default to 10, but I cannot access my webcam in MAX......even the webcam driver does not change the default......anyone has a solution?

0 Kudos
Message 1 of 16
(7,878 Views)

@Prathiksha wrote:
[...] and I have to use property page vi to adjust it......[...]

Does this mean that you can set the frame rate by writing a value to a property node?  

0 Kudos
Message 2 of 16
(7,877 Views)

well i use the dialog box to adjust the settings everytime for acquisition......can we use a property node to set it? 

0 Kudos
Message 3 of 16
(7,873 Views)

I don't know.  I never use webcams. Smiley Surprised

Another idea:  Use every third frame for processing. That way, your camera works at 30fps, your analysis at 10fps.

Message 4 of 16
(7,871 Views)

Hello,

 

why don't you try controling the acquisitin via loop execution control:

 

Example_VI_BD.png

 

Best regards,

K


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 5 of 16
(7,866 Views)

hello,

i can't seem to locate this vi.....can you please name it...

vi.jpg  

 

0 Kudos
Message 6 of 16
(7,859 Views)
median ptbypt...

https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 7 of 16
(7,851 Views)

Thank you that worked nicely......i know this is silly but i understood the vi upto the point where it waited for 100msec so at the end of a sec we grab 10 frames....i would like to know the calculations to display frame rate....and also iam concerned as to whether there might be some performance issues as my camera will be grabbing at 30fps but the while loop acquiring at only 10fps?

0 Kudos
Message 8 of 16
(7,841 Views)

Hello,

 

the actual frame rate is calculated as the difference of the current and the previous millisecond timer value.

The "Wait until next ms multiple" does what is says - it waits for the multipliers of the input millisecond value. That means if one of your functions in the loop takes longer to execute, it will wait for the next multiple value - thus dropping the effective frame rate.

 

After the difference, the ms are converted to fps (dividing by 1000 to get seconds and inverting the value to get the fps).

 

You should have no problem with camera working at 30 fps, you are just going to take every third frame - the actual fps should be constant. Plot a chart of actual fps if you don't belive me 🙂

 

Everything you need to do is to keep an eye on the setted and the actual refresh reate. Ideally, they should be the same. If not, check your functions inside the while loop - something is delaying the execution... In that case, you need to lower your refresh rate or optimize your program.

 

Hope this helps.

 

Best regards,

K

 


https://decibel.ni.com/content/blogs/kl3m3n



"Kudos: Users may give one another Kudos on the forums for posts that they found particularly helpful or insightful."
Message 9 of 16
(7,832 Views)
Solution
Accepted by topic author Prathiksha

Thank you..Smiley Happy

0 Kudos
Message 10 of 16
(7,820 Views)