commenting preview of video raises error
3 ビュー (過去 30 日間)
古いコメントを表示
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
0 件のコメント
採用された回答
Image Analyst
2015 年 11 月 6 日
I'm not sure if a preview window is needed or not. If it is, maybe you can set the size of the window really small, like a pixel or so, if you don't want it to show.
videoRes = get(vidobj, 'VideoResolution');
numberOfBands = get(vidobj, 'NumberOfBands');
axes(handles.axesImage);
cla('reset');
handleToImageInAxes = image( zeros([videoRes(2), videoRes(1), numberOfBands], 'uint8') );
preview(vidobj, handleToImageInAxes);
start(vidobj);
% Make axes a single pixel.
set(handles.axesImage, 'Units', 'normalized', 'Position', [1, 1, .001, .001]);
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!