Convert image from IP camera

Questions and postings pertaining to the usage of ImageMagick regardless of the interface. This includes the command-line utilities, as well as the C and C++ APIs. Usage questions are like "How do I use ImageMagick to create drop shadows?".
Post Reply
yds
Posts: 9
Joined: 2013-09-11T16:56:12-07:00
Authentication code: 6789

Convert image from IP camera

Post by yds »

I have an IP camera, where a snapshot image is available from the URL [url]http://userid:@ip-number:port/snapshot.cgi[/url] (I have a real ip and port number of course). This works fine from a browser. I'd like to grab that image and add a timestamp to it using IM. The command line (or script) I've been tying is

Code: Select all

convert "http://guest:@ip-number:port/snapshot.cgi" -pointsize 18 -fill white -gravity SouthEast -annotate +0+5 "`date`" CamPic.jpg
This doesn't want to work. This is the error message I get.

Code: Select all

sh: 1: html2ps: not found
convert: delegate failed `"html2ps" -U -o "%o" "%i"' @ error/delegate.c/InvokeDelegate/1058.
convert: unable to open image `/tmp/magick-TJIy7e2T':  @ error/blob.c/OpenBlob/2587.
convert: unable to open file `/tmp/magick-TJIy7e2T':  @ error/constitute.c/ReadImage/571.
convert: no data returned `http://guest:@ip-number:port/snapshot.cgi' @ error/url.c/ReadURLImage/231.
convert: missing an image filename `CamPic.jpg' @ error/convert.c/ConvertImageCommand/3011.
I have another ip camera, where the snapshot url is similar, but doesn't have authentication (the "guest:" part) and ends "snapshot.jpg" instead of a cgi extension, and that works fine with convert.

Any ideas??
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image from IP camera

Post by snibgo »

sh: 1: html2ps: not found
convert: delegate failed `"html2ps"
It looks to me that the file seen by IM is HTML, not JPEG or other image. In the past, IM has had problems with colons. Can you (temporarily) change the server so "guest:" isn't required?
snibgo's IM pages: im.snibgo.com
yds
Posts: 9
Joined: 2013-09-11T16:56:12-07:00
Authentication code: 6789

Re: Convert image from IP camera

Post by yds »

snibgo wrote:Can you (temporarily) change the server so "guest:" isn't required?
Unfortunately, that camera won't allow for access without authentication. The guest account was the closest I could get to no authentication. There's also the colon with the port numbers. So if IM doesn't like colon's I suppose it wouldn't like it there either.

One option I thought is that I could use wget to download and save the image first, then run convert on the downloaded image. I tried that and it worked (though seems rather inefficient). However since I would be converting the first downloaded jpeg into another jpeg, I was a bit concerned about loss of quality. Any thoughts on that??
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image from IP camera

Post by snibgo »

On some versions of wget, you can "-O-" to download to standard output, then pipe it into convert. (On Windows, wget stupidly creates a file named "-".) This just makes it slightly faster.

wget won't change the file contents; it simply copies the file.

You are using convert to annotate an image. Saving as a jpeg is lossy. If you can save as something else, that would be better. If you need jpeg as the final output but will be doing some further processing before that, use another format for the intermediate files.
snibgo's IM pages: im.snibgo.com
yds
Posts: 9
Joined: 2013-09-11T16:56:12-07:00
Authentication code: 6789

Re: Convert image from IP camera

Post by yds »

snibgo wrote:On some versions of wget, you can "-O-" to download to standard output, then pipe it into convert.
Can you get me started with how to pipe it to convert?

Code: Select all

wget url | ........??
(sorry, still learing the intracacies of commandline and scripting)
snibgo
Posts: 12159
Joined: 2010-01-23T23:01:33-07:00
Authentication code: 1151
Location: England, UK

Re: Convert image from IP camera

Post by snibgo »

The non-piped version, using a staging file, would be:

Code: Select all

wget -O temp.jpg url
convert temp.jpg {processing} outfile
Piping:

Code: Select all

wget -O- url | convert - {processing} outfile
(That's a capital letter Oh.)
snibgo's IM pages: im.snibgo.com
yds
Posts: 9
Joined: 2013-09-11T16:56:12-07:00
Authentication code: 6789

Re: Convert image from IP camera

Post by yds »

Brilliant!! Thanks very much snibgo. Now to try some test scripts.
Post Reply