What should I do/change/add in my code so my source would be my IP Cam?
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a code wherein my laptop camera would be the source of the video stream. It has a snapshot function once it runs, and the image captured will be saved in a specific folder.
However, I now want to use an IP cam as the source. The IP cam will be accessed through a router (an access point).
What should I add/change on my code and where should I place it (the additional code/change in the code)? The address of my IP cam is 192.168.0.101 at port 80.
I really hope somebody can help me :(
Here's the whole code by the way:
vid = videoinput('winvideo', 1, 'RGB24_640x480');
preview(vid);
pathname = 'C:\Users\Valued User\Documents\5th year, 2nd term\THESIS\imagesss';
if ~exist(pathname, 'dir')
mkdir(pathname);
end
for i=1
data= getsnapshot(vid);
pause(1);
imshow(data);
baseFileName = sprintf('ForDetection.jpg', 1);
fullFileName = fullfile(pathname, baseFileName);
imwrite(data,fullFileName);
end
댓글 수: 0
답변 (2개)
Haiko
2014년 1월 16일
편집: Walter Roberson
2014년 1월 16일
When using an IP-cam it works a bit different. To read a single image something similar as the following line of code can be used, assuming the IP camera uses MJPEG (motion jpeg). In this code the user name is 'admin' and the user password is 'admin' aswell.
Image = imread('http://192.168.0.101/snapshot.cgi?user=admin&pwd=admin');
When multiple pictures are required use a while or for loop.
For i=1:100
Image(i) = imread('http://192.168.0.101/snapshot.cgi?user=admin&pwd=admin');
end
good luck
댓글 수: 3
Haiko
2014년 1월 16일
If you just need the one image, that would probably work. Note; part of the string 'snapshot.cgi?user=admin&pwd=admin' might be different, this depends a on your camera.
Walter Roberson
2014년 1월 16일
You would replace most of the code, not just add that at the top.
data = imread('http://192.168.0.101/snapshot.cgi?user=admin&pwd=admin');
baseFileName = sprintf('ForDetection.jpg', 1);
fullFileName = fullfile(pathname, baseFileName);
imwrite(data, fullFileName);
John Alric
2014년 1월 18일
I manged to get the feed from the IP Cam using this code
url = 'http://ce4563.myfoscam.org:88/snapshot.cgi?user=guest&pwd=1234';
ss = imread(url);
FileNum = 1;
fh = image(ss);
while(1)
pause(1)
ss = imread(url);
set(fh,'CData',ss);
drawnow;
FileNum = FileNum + 1;
end
But the frame rate is slower than the browser stream is there anyway to speed up the video?
댓글 수: 2
Tiwa Romuald
2015년 10월 5일
hi escuse me please how to have stream video from my ipcam to matlab thank you
참고 항목
카테고리
Help Center 및 File 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!