Why is my code not returning the memory to computer?

I am trying to use the ipcam package to capture and process some images and record them on disk continuously, but after each loop the program is just consuming more and more memory and I can't make the matlab return it to the system. I already tried to stop it and use the command pack and all the possible variants of clear, nothing returns the memory to the system. The problem can be replicate with this code:
url = 'http://172.18.131.248/axis-cgi/mjpg/video.cgi';
cam = ipcam(url);
img = zeros(1280, 720, 3);
while(true)
file_name = strcat(datestr(now,30), '.avi');
outputVideo = VideoWriter(fullfile('./', file_name));
outputVideo.FrameRate = 15;
open(outputVideo);
img = rgb2gray(uint8(snapshot(cam)));
for offset = 0:450
writeVideo(outputVideo, img);
end
close(outputVideo);
clear outputVideo;
end

1 件のコメント

Geoff Hayes
Geoff Hayes 2016 年 11 月 23 日
Bruno - please explain why you have a loop that writes the same image 451 times
for offset = 0:450
writeVideo(outputVideo, img);
end
What is the purpose of this code especially since the offset variable is not being used?

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

回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeMATLAB Support Package for IP Cameras についてさらに検索

質問済み:

2016 年 11 月 23 日

コメント済み:

2016 年 11 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by