Azzera filtri
Azzera filtri

What should I do/change/add in my code so my source would be my IP Cam?

2 visualizzazioni (ultimi 30 giorni)
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

Risposte (2)

Haiko
Haiko il 16 Gen 2014
Modificato: Walter Roberson il 16 Gen 2014
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 Commenti
Haiko
Haiko il 16 Gen 2014
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
Walter Roberson il 16 Gen 2014
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);

Accedi per commentare.


John Alric
John Alric il 18 Gen 2014
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 Commenti
Tiwa Romuald
Tiwa Romuald il 5 Ott 2015
hi escuse me please how to have stream video from my ipcam to matlab thank you
Walter Roberson
Walter Roberson il 5 Ott 2015
The exact details depend upon your manufacturer and model of camera.

Accedi per commentare.

Categorie

Scopri di più su MATLAB Support Package for IP Cameras in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by