web cam image from url using objective-c -
i writing os x app, cocoa, , trying figure out how web-cam still image axiscam @ url:
http://bigwatersedge.axiscam.net/view/snapshot.shtml?picturepath=/jpg/image.jpg×tamp=
using dispatch/queue/block suggested here:
it return html code of page.
what suggested way image data web-cam , not page? since there isn't direct link jpg image, bit confusing.
i able make work in c# - save webcam image website answer/question @ bottom - looks forgot old accnt , started new one.
looks figured out.
headers need set follows:
self.bweheader = @"http://bigwatersedge.axiscam.net/view/snapshot.shtml?picturepath=/jpg/image.jpg?timestamp="; self.bweimage = @"http://bigwatersedge.axiscam.net/jpg/image.jpg?timestamp="; self.bwehost = @"bigwatersedge.axiscam.net"; nsmutableurlrequest *therequest = [nsmutableurlrequest requestwithurl:[nsurl urlwithstring:[self.bweimage stringbyaddingpercentescapesusingencoding:nsutf8stringencoding]] cachepolicy:nsurlrequestreloadignoringcachedata timeoutinterval:60.0]; [therequest sethttpmethod:@"get"]; [therequest addvalue:self.bwehost forhttpheaderfield:@"host"]; [therequest addvalue:self.bweheader forhttpheaderfield:@"referer"]; nsdata *data = [nsurlconnection sendsynchronousrequest:therequest returningresponse:&response error:&returnerror]; nsimage *camimage = [[nsimage alloc] initwithdata:data]; [self.imageview setimage:camimage]; [self.imageview setimagescaling:nsimagescaleproportionallyupordown];
Comments
Post a Comment