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
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 Exchange 中查找有关 MATLAB Support Package for IP Cameras 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!