Large memory usage for image acquisition app

5 ビュー (過去 30 日間)
Ramu Pradip
Ramu Pradip 2021 年 9 月 29 日
コメント済み: DGM 2021 年 10 月 5 日
I have written an app for acquiring images from a allied vision camera (gige cam interface) and then to plot histogram of an user defined region of interest. The app works fine for 10 mins and then it failed because memory usage increases steadily.
Camera parameters
app.cam = videoinput('gige', 1, 'Mono8');
app.src = getselectedsource(app.cam);
% Setting initial parameters
app.cam.TriggerRepeat = inf;
app.cam.FramesPerTrigger = 1;
app.cam.Timeout = 30;
Main loop
trigger(app.cam);
frame = getdata(app.cam);
image(app.livecam, 'Cdata', frame);
if ~isempty(app.roi)
app.roi = round(app.roi);
rectangle(app.livecam,'Position',app.roi,'EdgeColor','g')
img = frame(app.roi(2): app.roi(2) + app.roi(4), app.roi(1):app.roi(1)+app.roi(3));
updateHistogram(app, img)
end
Each frame is ca. 800 x 400 pixels.
Could anyone help me solve my app's memory issue ?
Thank you.
  3 件のコメント
Ramu Pradip
Ramu Pradip 2021 年 10 月 5 日
On the contrary to what I read on several threads, found that imshow(frame,'Parent',app.livecam); is less of memory hog than updating just Cdata - image(app.livecam, 'Cdata', frame);
DGM
DGM 2021 年 10 月 5 日
I'm not sure of the behavior given what you've shown, but you might want to double-check to make sure that you're not stacking things in that particular axes. That's kind of a classic way to unintentionally eat memory. Just check the 'children' property of the axes to make sure that there aren't a bunch of images stacked up.

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

回答 (0 件)

製品


リリース

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by