Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I wrote a q&d Perl script to acquire an image from my webcam, modify it, and upload it to my website.

The resizing and uploading features work flawlessly, however in order to acquire the image, the camera (via TWAIN) requires that I "Select", "Capture" then "Transfer" the image, a process that takes four clicks. This kills the possibility of allowing the camera to run continuously; it will halt when I'm not there and drive me completely insane when I am.

As far as I know, I have only three options.

  • Find a different module (I'm using Win32::Scanner::EZTWAIN) that acquires without human intervention
  • Have an intermediary program acquire the image and place it in a file (the same as above, but non-Perl)
  • Automate the button pushing somehow (four mouse clicks, options would not change)

Fellow Monks, which of the above seems like a viable and readily instituted solution?

Code follows...

use Win32::Scanner::EZTWAIN; use Net::FTP; use Image::Magick; my $scanner = new Win32::Scanner::EZTWAIN(); print "Select Image Source...\n"; $scanner->select_image_source(""); print "Acquiring File...\n"; $scanner->acquire_to_file("cam.bmp"); my $image = new Image::Magick; print "Opening Image\n"; $image->Read("cam.bmp"); $image->Resize(width=>320, height=>240, filter=>"Cubic"); $image->Annotate(text=>'newrisedesigns.com', font=>"Verdana", pointsize=>12, fill=>"#000000", antialias=>"true", x=>17, y=>20); $image->Annotate(text=>'newrisedesigns.com', font=>"Verdana", pointsize=>12, fill=>"#ffffff", antialias=>"true", x=>15, y=>18); if($ARGV[0] ne ''){ $ARGV[0] .= "\n"; $image->Annotate(text=>$ARGV[0], font=>"Verdana", pointsize=>12, stroke=>"#000000", strokewidth=>1, antialias=>"true", gravity=>"South"); } $image->Set(quality=>80); print "Reformatting Image\n"; $image->Write(filename=>"cam.jpg", compression=>'jpeg'); my $ftp = Net::FTP->new("website.com"); print "Preparing FTP Connection\n"; $ftp->login('username','password'); print "Changing Directory\n"; $ftp->cwd('httpdocs/cam'); print "Putting Image\n"; $ftp->binary(); $ftp->delete('cam.jpg'); $ftp->put('cam.jpg');

Any solutions other than the three above would also be greatly appreciated.

Many thanks,
John J Reiser
newrisedesigns.com


In reply to TWAIN Issues and Perl by newrisedesigns

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (8)
As of 2024-04-23 08:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found