how to take pictures from webcam connected from phone on matlab

조회 수: 3 (최근 30일)
Sang
Sang 2022년 11월 9일
댓글: DGM 2022년 11월 9일
i have a video connected webcam from phone as follows. so how can i capture images directly from them
url = 'http://192.168.2.6:8080/shot.jpg';
ss = imread(url);
fh = image(ss);
while(1)
ss = imread(url);
set(fh,'CData',ss);
drawnow;
end
try
info = imaqhwinfo;
catch
errordlg('Webcam aquisition not supported.')
return
end

답변 (1개)

Adam Danz
Adam Danz 2022년 11월 9일
Use exportgraphics to capture the image within your axes.
  댓글 수: 5
Adam Danz
Adam Danz 2022년 11월 9일
If there cases where exportgraphics distorts image geometry, I'd like to be aware of them. imwrite is another good option, thanks @DGM.
DGM
DGM 2022년 11월 9일
I wouldn't say "distorts", but if it behaves like print() or saveas(), then the output geometry will be a function of figure geometry instead of strictly being equal to the image geometry, (e.g. with any added padding, etc)
hi = imshow('peppers.png'); % [384 512]
% use print
print('useprint.png','-dpng')
S = imfinfo('useprint.png');
[S.Height S.Width]
ans = 1×2
656 874
% use saveas
saveas(gca,'usesaveas.png')
S = imfinfo('usesaveas.png');
[S.Height S.Width]
ans = 1×2
656 874
% use exportgraphics
saveas(hi,'useexpg.png') % try to use the image object itself
S = imfinfo('useexpg.png');
[S.Height S.Width]
ans = 1×2
656 874
I'm sure there are ways around this, but I don't see the point in pursuing the hazard if the source image was available in the first place.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 MATLAB Support Package for IP Cameras에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by