how to compare images in video processing?

4 ビュー (過去 30 日間)
Mehreen Hussain
Mehreen Hussain 2013 年 1 月 22 日
this is my code
imaqhwinfo
info=imaqhwinfo('winvideo')
vid=videoinput('winvideo');
%Open Figure
hFigure=figure(1);
%set parameters for video
%Acquire only one frame each time
triggerconfig(vid,'Manual');
set(vid,'framespertrigger',1);
%Go on forever untill stopped
set(vid,'triggerrepeat',Inf);
%Get a grayscale image
set(vid,'ReturnedColorSpace','grayscale');
start(vid);
preview(vid);
for i=1:5
trigger(vid);
im=getdata(vid);
figure,imshow(im(:,:,:,i));
end
stop(vid),delete(vid),clear(vid);
the problem is that i'm not getting multiple frames in a single figure,more over some times the program run and some times gives the error
?? Error using ==> imaqdevice.start at 19
Multiple VIDEOINPUT objects cannot access the same device simultaneously.
why it happens and how can i solve it plz help
also m not getting the 4 frames ,it dispplay 3 figure windows out of which 2 is blank only 1 frame is showing

採用された回答

Walter Roberson
Walter Roberson 2013 年 1 月 22 日
You have
im=getdata(vid);
so you are writing over all of "im". But on the next line you have
imshow(im(:,:,:,i));
which attempts to extract data only from the "i" slice of "im".
You need to be consistent: either write the data to a slice of "im", or overwrite all of "im" and show all of "im".
  3 件のコメント
Walter Roberson
Walter Roberson 2013 年 1 月 23 日
What result do you want? The images are shown in separate figure windows because you have the call to figure before your imshow()
Mehreen Hussain
Mehreen Hussain 2013 年 1 月 24 日
i want all images in one figure

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by