Hello

I am using Image::Grab to gr1ab images off an IP Camera. That is all working OK.

The problem I have is that the timeout for a bad connection is 3minutes but I expect to be grabbing images every 60 seconds. If there is a problem with the camera, I will end up with multiple threads running waiting for an image. I have looked at the documentation here http://search.cpan.org/~mahex/Image-Grab-1.4.2/lib/Image/Grab.pod

I need to change the value of Timeout.

My code looks like this:

#get the latest image from the IP camera my $snapshot = new Image::Grab; $snapshot->timeout(5); #sets the timeout (sec) for image::grab (defau +lt is 180s) $snapshot->url("$Camera{$key}"); # create the grab object $snapshot->grab; # grab the image open (IMAGE, ">$lastsnap{$key}") || die syslog(LOG_ERR, "Couldn't ope +n file, $!"); # opens and clears th$ binmode IMAGE; # for MSDOS derivations. print IMAGE $snapshot->image; # save the image to the /var/images/Tra +ckcam folder close IMAGE or die $!;
Perl debugger spits out the following error message:
Can't access `timeout' field in class Image::Grab at upload-images.pl +line 79. at /usr/local/share/perl/5.18.2/Image/Grab.pm line 81. Image::Grab::AUTOLOAD('Image::Grab=HASH(0x8698344)', 5) called + at upload-images.pl line 79

My question is how do I change the Timeout property to 5sec?


In reply to Setting Timeout in Image::Grab?? by dazz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.