MATLAB: Gigecam(), high cpu load after first snapshot().

cpu loadgigecamImage Acquisition ToolboxMATLABsnapchot

Hi
I am acquiring images from two different point grey 'Blackfly BFLY-PGE-50H5M' network cameras. The cameras are triggered by an input from another machine (not a part of the example below). The cameras are loaded via the function gigecam(). Loading the cameras and changing settings does not load the cpu significantly, but first time I call snapshot() to acquire an image the cpu load goes to a high level and stays there. I have made an example. See below. First time I call snapshot(cam1) the cpu load is at 26% and then calling snapshot(cam2) the cpu load is permanently at 52%. Does anyone know if this behavior can be avoided? Doing "clear cam1" is not a good solution as it takes a long time to load the camera again via gigecam() when I want to acquire more images.
clc;
close all;
clear all;
gigecamlist
cam1ID = '16482972';
cam2ID = '14514855';
cam1 = gigecam(cam1ID);
cam2 = gigecam(cam2ID);
cam1.ExposureAuto = 'off';
cam1.ExposureTime = 7000;
cam1.OffsetX = 0;
cam1.OffsetY = 0;
cam1.Width = cam1.WidthMax;
cam1.Height = cam1.HeightMax;
cam1.AcquisitionFrameRateEnabled = 'True';
cam1.AcquisitionFrameRateAuto = 'Off';
cam1.AcquisitionFrameRate = 1;
cam1.GainAuto='Off';
cam1.Gain = 0;
cam1.SharpnessEnabled ='False';
cam1.pgrExposureCompensationAuto = 'Off';
cam1.GevSCPSPacketSize = 9000; %This is the same size as the Jumbo packet

cam1.Timeout =10;
%Here is an example of how to configure some of the camera settings.
cam2.ExposureAuto = 'off';
cam2.ExposureTime = 8000;
cam2.OffsetX = 0;
cam2.OffsetY = 0;
cam2.Width = cam2.WidthMax;
cam2.Height = cam2.HeightMax;
cam2.AcquisitionFrameRateEnabled = 'True';
cam2.AcquisitionFrameRateAuto = 'Off';
cam2.AcquisitionFrameRate = 1;
cam2.GainAuto='Off';
cam2.Gain = 0;
cam2.SharpnessEnabled ='False';
cam2.pgrExposureCompensationAuto = 'Off';
cam2.GevSCPSPacketSize = 9000; %This is the same size as the Jumbo packet
cam2.Timeout =10;
Im1=snapshot(cam1);figure;imshow(Im1)
Im2=snapshot(cam2);figure;imshow(Im2)
Thanks in advance! 🙂

Best Answer

Once the gigecam object is created, it continuously acquires frames from the camera but does not buffer them. When snapshot is called, it just gets the latest frame and passes it to MATLAB. This is the reason you see the constant usage of CPU. This is expected behaviour. For now, clearing the object is the only way to reduce the usage of CPU. Thank you for bringing this up though. I have let the development team know about this issue and they might consider this for our future releases.