Image Acquisition reducing CPU-Load

1 visualización (últimos 30 días)
Martin
Martin el 26 de Jul. de 2011
Hi!
I´d like to reduce my CPU-Load during image Acquisition.
I´m using a Logitech C910 for acquiring images. My Code looks like this:
function [Vid] = InitCAM()
%%Camera Initialisation
% Get the Videoinput
Vid = videoinput( 'winvideo', 1, 'RGB24_1600x1200');
% Set TriggerConfig to manual
triggerconfig(Vid, 'manual');
% Get only one Frame per Trigger
Vid.FramesPerTrigger = 1;
% Get Image-Data as Grayscale
Vid.ReturnedColorSpace = 'grayscale';
set(Vid, 'SelectedSourceName', 'input1')
%%Get Camera Properties for image acquistition
VidSrc = getselectedsource( Vid);
% Adjust properties of Camera
VidSrc.BacklightCompensation = 'on';
VidSrc.FrameRate = '5';
VidSrc.ExposureMode = 'auto';
VidSrc.FocusMode = 'auto';
VidSrc.Gain = 64;
VidSrc.Pan = 0;
VidSrc.Saturation = 32;
VidSrc.Sharpness = 72;
VidSrc.Tilt = 0;
set(VidSrc,'WhiteBalanceMode','auto');
end
After Initialisation i´m starting a GUI where the acquired frames are displayed in an axes.
%%Start Client: Collecting Images and Data-Management
set(Vid,'TimerPeriod', 0.3, 'TimerFcn','BufferImages(Vid, PMMFClient);');
start(Vid)
The TimerFcn looks like this:
function BufferImages(Vid, PMMFClient)
global CurFrame
global OldFrame
global DifFrame
global once
global OldStatusLine
%%Get the Current Frame vom Camera
CurFrame.Image = getsnapshot(Vid);
PMMFClient.Data(1).Image = CurFrame.Image;
% Set the current Time Stamp for this Frame
t = now;
c = datevec ( t );
s = datestr ( c, 0 );
CurFrame.TimeStamp = s;
PMMFClient.Data(1).TimeStamp = uint8(CurFrame.TimeStamp);
imagesc( CurFrame.Image, 'Parent', GuiHandles.axes1);
set(GuiHandles.axes1,'YTick',[],'XTick',[]);
end
I´m using an TimerFcn because i´m doing different image processing things in in the TimerFcn which must be cyclic for each frame.
I want to acquire every 0.3 seconds only one image and process it. My CPU load is now 40% using Intel Core 2Duo 2,8GHZ. For my opinion it´s too much.
Have you any idea reducing the cpu load to do this image acquire?
Many thanks in advance!

Respuestas (1)

David Tarkowski
David Tarkowski el 26 de Jul. de 2011
Looking at your code, the following items are likely to be using the bulk of the CPU time in your code:
  1. Conversion from RGB to monochrome data.
  2. Using imagesc instead of image
  3. Calling imagesc on every execution of the TimerFcn callback
You can use the MATLAB profiler to verify this and identify other areas of your code that might also be taking up significant CPU resources.
A couple of thoughts as to how you might reduce the CPU resources needed:
  1. The format you are using is 'RGB24_1600x1200', but you are converting to monochrome data. If your camera supports a YCbCr color space such as I420 or UYVY, which many webcams do, you should consider using one of those formats instead. Conversion from YCbCr to monochrome is quicker than conversion from RGB to monochrome. The IMAQHWINFO command will show you the supported formats for your device.
  2. This document has some tips on how to speed up image display.
  1 comentario
manoj sambasivam
manoj sambasivam el 2 de Mayo de 2012
Will the image be the same as we convert from rgb to grayscale and Ycbcr format to grayscale?

Iniciar sesión para comentar.

Community Treasure Hunt

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

Start Hunting!

Translated by