Image Processing Loop Crashes - Memory
Show older comments
Hi, I'm coding a program that captures a image from my webcam and threat it through a function 'IsolarBola', which applies a HSV filter in the image to isolate the yellow color in the image, continually. The problem is that after a while the program is running, it crashes, saying that Matlab Run Out of Memory. I'd like to know how could I fix this memory problem. Also, I'd know how to make the loop in the program 'while(camera1.FramesAcquired<=10000' just stops when I press a button, instead of with the condition 'FramesAcquired'. Thanks in advance for the help.
Here's the code of the program(sorry for the comments in portuguese):
%declaração das câmeras
camera1 = videoinput('winvideo',1,'YUY2_160x120');
%define as propriedades do video
set(camera1,'FramesPerTrigger', Inf);
set(camera1,'ReturnedColorSpace','rgb');
%inicio da captura de dados das câmeras
start(camera1);
%Inicia Loop que para depois de 200 frames adquiridos
while(camera1.FramesAcquired<=10000)
%pega uma foto do frame atual
data1=getsnapshot(camera1);
%Função para Isolar a bola e exibir a imagem da câmera
IsolarBola(data1);
end
%para a aquisição de vídeo
stop(camera1);
%limpa a memoria
flushdata(camera1);
%limpa todas as variáveis
clear all;
sprintf('%s','Fim da execução do programa');
Accepted Answer
More Answers (0)
Categories
Find more on Image Preview and Device Configuration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!