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

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에 대해 자세히 알아보기

질문:

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