How to set Frames Per second

5 次查看(过去 30 天)
H
H 2011-2-25
Hello,
I used the "getsnapshot" function to capture a frame using my external webcam to analyze an image.
How do i loop it such that my camera will repeat the program infinately for
XXXX frames/second
would this be slower compared to the "real-time video streaming triggering technique?"
  1 个评论
Walter Roberson
Walter Roberson 2011-2-25
You could use a timer function to trigger the snapshot. I don't know what accuracy you would be able to obtain.
I am not familiar with the triggering technique you reference, so I cannot advise on that.

请先登录,再进行评论。

回答(2 个)

David Tarkowski
David Tarkowski 2011-2-25
If you are using the getsnapshot command, please see the Acquiring Single Images in A Loop for tips on how to optimize the performance of the getsnapshot command. If your camera is running at a higher frame rate than what you desire for capture, you can use pause or a timer, as Walter suggests, to capture at a slower rate.
In general webcams don't have a guaranteed consistent frame rate so whatever frame rate you are seeing in normal use might not be exactly sustainable over long periods of time. Using start and getdata as David Young suggests will probably be more efficient, but that is hard to say for sure without more details on exactly what you are trying to accomplish.
  1 个评论
H
H 2011-2-25
I am proccessing an image to detect simple objects like balls, determine centroid --> to control robot to move towards ball, area, etc and drawing a box around the ball.
My program already works for analyzing a single frame i would like to know what is the best method for live-REAL-Time for the robot application.

请先登录,再进行评论。


David Young
David Young 2011-2-25
I do not think getsnapshot is suitable for working with a video stream - it's really for getting a single image at a random time.
You are much better off using the techniques described in the chapters "Acquiring Image Data", "Working with Acquired Image Data" and "Using Events and Callbacks" in the user manual.
Callback functions are especially useful. You can set the camera to any frame rate that it supports, and once you've started the video object you don't have to worry about timing or triggering any more. The callback function can process each image in any way you like, provided it completes in time, and you can check whether it is keeping up. I suspect the overhead is far lower than for repeated calls to getsnapshot.

Community Treasure Hunt

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

Start Hunting!

Translated by