######### Set these CONSTANTS to suit your system & needs ######### my $STEPS = 4; # Number of pictures in panorama. my $CAM = 0; # Which camera to use (usually zero). my $TILT = 0; # Tilt position to use. my $LSHOST = "localhost"; # Hostname where LogiSphere is running. my $LSPORT = "8080"; # Port LogiSphere is running on. ################################################################### use IO::Socket; $EOL = "\015\012"; $BLANK = $EOL x 2; # PAN START POSITION AND STEP SIZE. $pan = -100; $panstep = 200/($STEPS-1); # MAKE UNIQUE FILENAMES FOR OUTPUT JPEGS. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $basename = sprintf("%04d%02d%02d%02d%02d%02d-", $year+1900,$mon+1,$mday,$hour,$min,$sec); chomp ($ourpath = qx/cd/); # MAKE HTTP REQUEST THAT TRIGGERS IMAGE CAPTURES. $grab = sprintf("GET /current%d.jpg HTTP/1.1%s",$CAM,$EOL); $grab .= "Accept: text/html, image/jpeg$BLANK"; # THE MAIN LOOP - ONE ITERATION PER CAPTURE. for ($i=1;$i<=$STEPS;$i++) { $file = $basename.$i.".jpg"; # MOVE CAMERA TO POSITION. $move = sprintf("GET /pos%d-%d,%d HTTP/1.1%s",$CAM,$pan,$TILT,$BLANK); printf ("Move Cam %1d To: %d,%d\n",$CAM,$pan,$TILT); $logi = hookup($LSHOST,$LSPORT); print $logi "$move"; while (<$logi>) { # Just ignore reply from LogiSphere if ($_ =~ /404/) { # unless somthing bad happened. die "LogiSphere did not accept position command." } } sleep(5); # Allow time for it to really move. # REQUEST AN IMAGE CAPTURE. $logi = hookup($LSHOST,$LSPORT); print $logi "$grab"; while (<$logi>) { # Just ignore Headers from LogiSphere if ($_ =~ /404/) { # unless somthing bad happened. die "LogiSphere did not deliver image." } last if /^\r/ } # WRITE IMAGE TO OUPUT JPEG FILE. open(FH, "> $file") || die "Can't create $file."; binmode(FH); while (<$logi>) {print FH} close(FH); print "Captured File: $ourpath\\$file\n"; # CALC NEXT CAMERA POSITION. $pan += $panstep; } #### SUBROUTINE TO MAKE CONNECTIONS TO LOGISPHERE. #### sub hookup($$) { my($host,$port)=@_; $conn = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => $port, ) or die "cannot connect to the LogiSphere server"; return $conn } 1
######### Set these CONSTANTS to suit your system & needs ######### my $STEPS = 6; # Number of pictures in panorama. my $SLEEP = 10; # Allow time for it to really move. my $CAM = 0; # Which camera to use (usually zero). my $TILT = 0; # Tilt position to use. my $LSHOST = "localhost"; # Hostname where LogiSphere is running. my $LSPORT = "8080"; # Port LogiSphere is running on. ################################################################### use IO::Socket; $EOL = "\015\012"; $BLANK = $EOL x 2; # PAN START POSITION AND STEP SIZE. $pan = -100; $panstep = 200/($STEPS-1); # MAKE UNIQUE FILENAMES FOR OUTPUT JPEGS. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $basename = sprintf("%04d%02d%02d%02d%02d%02d-", $year+1900,$mon+1,$mday,$hour,$min,$sec); chomp ($ourpath = qx/cd/); # MAKE HTTP REQUEST THAT TRIGGERS IMAGE CAPTURES. $grab = sprintf("GET /current%d.jpg HTTP/1.1%s",$CAM,$EOL); $grab .= "Accept: text/html, image/jpeg$BLANK"; # THE MAIN LOOP - ONE ITERATION PER CAPTURE. for ($i=1;$i<=$STEPS;$i++) { $file = $basename.$i.".jpg"; # MOVE CAMERA TO POSITION. $move = sprintf("GET /pos%d-%d,%d HTTP/1.1%s",$CAM,$pan,$TILT,$BLANK); printf ("Move Cam %1d To: %d,%d\n",$CAM,$pan,$TILT); $logi = hookup($LSHOST,$LSPORT); print $logi "$move"; while (<$logi>) { # Just ignore reply from LogiSphere if ($_ =~ /404/) { # unless somthing bad happened. die "LogiSphere did not accept position command." } } sleep($SLEEP); # Allow time for it to really move. # REQUEST AN IMAGE CAPTURE. $logi = hookup($LSHOST,$LSPORT); print $logi "$grab"; while (<$logi>) { # Just ignore Headers from LogiSphere if ($_ =~ /404/) { # unless somthing bad happened. die "LogiSphere did not deliver image." } last if /^\r/ } # WRITE IMAGE TO OUPUT JPEG FILE. open(FH, "> $file") || die "Can't create $file."; binmode(FH); while (<$logi>) {print FH} close(FH); print "Captured File: $ourpath\\$file\n"; # CALC NEXT CAMERA POSITION. $pan += $panstep; } #### SUBROUTINE TO MAKE CONNECTIONS TO LOGISPHERE. #### sub hookup($$) { my($host,$port)=@_; $conn = IO::Socket::INET->new( Proto => "tcp", PeerAddr => $host, PeerPort => $port, ) or die "cannot connect to the LogiSphere server"; return $conn } 1
perl.exe panorama.pl