Path: news.mathworks.com!not-for-mail
From: "Michele " <denber.nospam@mindspringNOSPAM.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Web cam access in Matlab
Date: Fri, 24 Aug 2007 20:31:59 +0000 (UTC)
Organization: Michele Denber (ID: 1-A7A3B)
Lines: 22
Message-ID: <fanf7v$h7f$1@fred.mathworks.com>
References: <f9v7iv$76g$1@fred.mathworks.com> <46C5A649.2000705@mathworks.com> <fa4qh4$hli$1@canopus.cc.umanitoba.ca> <fafvn8$q4$1@fred.mathworks.com> <fai2os$5pa$1@fred.mathworks.com> <fal7u9$m0r$1@fred.mathworks.com> <falab2$lve$1@fred.mathworks.com>
Reply-To: "Michele " <denber.nospam@mindspringNOSPAM.com>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1187987519 17647 172.30.248.38 (24 Aug 2007 20:31:59 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 24 Aug 2007 20:31:59 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 174773
Xref: news.mathworks.com comp.soft-sys.matlab:425489


Success!  Turns out that urlread won't read binary data but
urlwrite will, and in fact imread calls urlwrite.  So I just
applied the above authentication mod to urlwrite instead of
urlread.  I can now read frames from my password-protected
Trendnet web cam.  Code:

cam103 = imreadauth ('http://192.168.0.103/image.jpg') ;

"imreadauth" simply calls my modified version of urlwrite.

Note that a lot of other popular web cams (eg. D-Link) use
the same protocols, so this solution should work for them too.

In retrospect, I found the taxonomy of urlread/urlwrite
confusing.  You've got urlread which reads urls as you might
expect.  But urlwrite does not write urls - it just also
reads them and then saves them to a file.  I submit that all
of this would be clearer and simpler if there was only one
function, urlread, with an optional file argument to save
the data to a file.  Either that or let urlread work with
binary data the same way that urlwrite does.  Right now, the
two functions seem to be slightly at odds with one another.