Which is the fastest way to display gray scale images (480 by 640) ?

5 ビュー (過去 30 日間)
Swanand Kolekar
Swanand Kolekar 2012 年 11 月 20 日
I am developing a motion tracking turret using a webcam. Presently the code works at 10 fps.
I'm using imshow to display images. But only the last image shows up, after the program is terminated. If i use pause(0.5) the images are displayed, but this messes up the frame rate.
Any solutions?

採用された回答

Image Analyst
Image Analyst 2012 年 11 月 20 日
You have to get the handle to the image in your axes, and then assign your webcam snapshot to the CData property (I think that's what it's called). This will be faster than imshow.
  2 件のコメント
Swanand Kolekar
Swanand Kolekar 2012 年 11 月 20 日
編集済み: Swanand Kolekar 2012 年 11 月 20 日
Thank you, it worked. I used set(axes1,'cdata',image1);
Cdata is faster , but i still have to use pause(x) to overcome the "last image problem"
Image Analyst
Image Analyst 2012 年 11 月 20 日
Sometimes with cameras you do need a pause. I've tried to grab stuff with getsnapshot() and view it right away and sometimes the frame seems like it has weird double images or other strange artifacts, so I have code like this:
handleToImageInAxes = image( zeros([videoRes(2), videoRes(1), numberOfBands], 'uint8') );
preview(vidobj, handleToImageInAxes);
% Set up camera parameters.
src= getselectedsource(vidobj);
previewMode = 1;
src.Flipping = 2;
src.Gain=cameraSettings(previewMode).gain;
src.Exposure = cameraSettings(previewMode).exp;
% Need to pause 4 frame times to get rid of double image.
pause(2.1);
% Snap picture from camera.
snappedImage = getsnapshot(vidobj); % This works.

サインインしてコメントする。

その他の回答 (1 件)

Jonathan Sullivan
Jonathan Sullivan 2012 年 11 月 20 日
Try using drawnow instead of pause(x)

Community Treasure Hunt

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

Start Hunting!

Translated by