0

I am writing an OS X app, with cocoa, and trying to figure out how to get a web-cam still image from an axiscam at this url:

http://bigwatersedge.axiscam.net/view/snapshot.shtml?picturepath=/jpg/image.jpg&timestamp=

Using the dispatch/queue/block suggested here:

Getting Image from URL Objective C

it will return the html code of the page.

What is the suggested way to get the image data from the web-cam and not the page? Since there isn't a direct link to a jpg image, it is a bit confusing.

I was able to make this work in C# - Save Webcam Image From Website which is my answer/question at the bottom - looks like I forgot my old accnt and started a new one.

2
  • i suggest you to get url of video stream, as it shows on the website, you can directly stream and show video on IOS device using MPMoviePlayerController, dont need to download image and from that page you cant get anything Commented May 3, 2013 at 4:25
  • My intent is to collect a still image at a defined interval. Also, the video stream is only good for 20 seconds and requires a refresh to continue. The intended platform is OS X not iOS. Commented May 3, 2013 at 15:10

1 Answer 1

0

Looks like I figured this out.

Headers need to be set up as 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];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.