Matlab 8.1.0.604 Image Processing Tool Box version 8.2(R2013a)
Hello all, Im trying to apply my algorithm on a live video and a command preview(vid) opens up a window with camera input ,every thing is working fine with code.
when I close the preview window or comment the command in the line "preview(vid)" it arise error.
'Timeout error during getsnapshot()'
is there any way that I dont want to use that preview. In debugging mode when I move step by step it doesnt show up any problem.
Here is my code snippet
% code
vid = videoinput(caminfo.InstalledAdaptors{1,ifcam},camdev.DeviceIDs{1});start(vid); % to start a video camera
preview(vid); % Preview Video
% i get error when I comment the line above.
%%Acquire Image.
figure('Name','BG Subtraction','Numbertitle','Off','Menubar','None','units','pixels','Position',[200 500 1500 500]);while true Im = getsnapshot(vid); subplot(1,3,1); imshow(Im); [r c p] = size(Im); %Extract individuals plane from RGB image
imR = squeeze(Im(:,:,1)); imG = squeeze(Im(:,:,2)); imB = squeeze(Im(:,:,3)); %Thresholding on individual planes
imBinaryR = im2bw(imR,graythresh(imR)); imBinaryG = im2bw(imR,graythresh(imG)); imBinaryB = im2bw(imR,graythresh(imB)); imBinary = imcomplement(imBinaryR & imBinaryG & imBinaryB); subplot(1,3,2); imshow(imBinary);end
Best Answer