I am trying to run a program that opens a webcam, takes a screenshot, processes it, and shows the output. My code runs correctly and I am getting output, but when I close the output window I get this error every-time:
Matlab System Error: Matlab has encountered an internal problem and needs to close.
As I am new to Matlab can anyone help me? I am using Windows 8 operating system and Matlab R2013a.
This is the code:
clear all;
close all;
clc;
video=videoinput('winvideo',1);
preview(video);
while(true)
data=getsnapshot(video);
R=data(:,:,1);
G=data(:,:,2);
B=data(:,:,3);
for i=1:768
for j=1:1024
if(R(i,j)<128)
out(i,j)=1;
else
out(i,j)=0;
end
end
end
cla; % Prevent stuffing too many images into the axes.
imshow(out);
drawnow;
end