Page 1 of 1

Convert image from IP camera

Posted: 2013-10-28T20:22:31-07:00
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??

Re: Convert image from IP camera

Posted: 2013-10-28T21:28:24-07:00
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?

Re: Convert image from IP camera

Posted: 2013-10-29T17:26:09-07:00
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??

Re: Convert image from IP camera

Posted: 2013-10-29T18:31:58-07:00
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.

Re: Convert image from IP camera

Posted: 2013-10-29T18:52:15-07:00
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)

Re: Convert image from IP camera

Posted: 2013-10-29T19:14:56-07:00
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.)

Re: Convert image from IP camera

Posted: 2013-10-29T19:25:21-07:00
by yds
Brilliant!! Thanks very much snibgo. Now to try some test scripts.