MagickReadImage() very slow retrieving images by http
Posted: 2013-03-26T02:39:27-07:00
Back with another question, though this time it's performance not function related.
MagickReadImage is really, really slow when retrieving network files.
I have an IP camera connected by ethernet directly to the computer - no switch, router, anything else. I can point a browser at http://192.168.10.30/image/jpeg.cgi and get a still image of whatever the camera is looking at.
With a browser or command line tool it's very quick - wget reports .03 seconds to retrieve the image. However, MagickReadImage() takes almost 30 seconds:
It also takes about 30 seconds retrieve image files from an internet web address. Watching my network monitor, it appears MagickReadImage() sits for almost 30 seconds and then transfers the file rapidly. Is there anything I can do to speed this up? The difference between .03 seconds and 30 seconds is enormous.
Thank you.
MagickReadImage is really, really slow when retrieving network files.
I have an IP camera connected by ethernet directly to the computer - no switch, router, anything else. I can point a browser at http://192.168.10.30/image/jpeg.cgi and get a still image of whatever the camera is looking at.
With a browser or command line tool it's very quick - wget reports .03 seconds to retrieve the image. However, MagickReadImage() takes almost 30 seconds:
Code: Select all
pgg@g550 ~/test
$ cat test3.c
#include <stdio.h>
#include <sys/timeb.h>
#include <wand/magick_wand.h>
#define ThrowWandException(wand) \
{ \
char *description; \
ExceptionType severity; \
description=MagickGetException(wand,&severity); \
printf("\n\n-----\n%s %s %lu %s\n",GetMagickModule(),description); \
description=(char *) MagickRelinquishMemory(description); \
exit(-1); \
}
int main() {
long milliseconds;
struct timeb timer1, timer2;
MagickWand *mw1 = NULL;
MagickWandGenesis();
mw1 = NewMagickWand();
ftime( &timer1 );
if( !MagickReadImage( mw1, "http://192.168.10.30/image/jpeg.cgi" ) )
ThrowWandException( mw1 );
ftime( &timer2 );
milliseconds = timer2.millitm - timer1.millitm + 1000.0 * (timer2.time-timer1.time);
printf( "Image retrieved in %ld milliseconds.\n", milliseconds );
MagickWriteImage( mw1, "output.jpg" );
mw1 = DestroyMagickWand(mw1);
MagickWandTerminus();
return 0;
}
pgg@g550 ~/test
$ gcc test3.c -o test3 -lMagickWand-6.Q16 -lgdi32 -I./include -L/usr/local/lib -DMAGICKCORE_HDRI_ENABLE=0 -DMAGICKCORE_QUANTUM_DEPTH=16
pgg@g550 ~/test
$ ./test3
Image retrieved in 26942 milliseconds.
pgg@g550 ~/test
$ wget http://192.168.10.30/image/jpeg.cgi
--2013-03-26 14:00:41-- http://192.168.10.30/image/jpeg.cgi
Connecting to 192.168.10.30:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 179537 (175K) [image/jpeg]
Saving to: `jpeg.cgi'
100%[======================================================================================================================================================>] 179,537 --.-K/s in 0.03s
2013-03-26 14:00:41 (6.12 MB/s) - `jpeg.cgi' saved [179537/179537]
It also takes about 30 seconds retrieve image files from an internet web address. Watching my network monitor, it appears MagickReadImage() sits for almost 30 seconds and then transfers the file rapidly. Is there anything I can do to speed this up? The difference between .03 seconds and 30 seconds is enormous.
Thank you.