[b69cf9]: bin / qtvr2erect  Maximize  Restore  History

Download this file

97 lines (67 with data), 2.4 kB

#!/usr/bin/perl

use strict;
use warnings;

use File::Temp qw/ tempdir /;
use File::Spec;
use Panotools::Script;

my $qtvr = shift or die "no qtvr specified";
$qtvr = quotemeta $qtvr;
my $outfile = shift or die "no output TIFF specified";
$outfile = quotemeta $outfile;

our $CLEANUP = 1;
$CLEANUP = 0 if defined $ENV{DEBUG};
my $tempdir = tempdir (CLEANUP => $CLEANUP);

`qtdechunk $qtvr $tempdir/chunk`;
die 'Dechunking failed' if $!;
`find $tempdir -type f | while read line; do mv \$line \$line.jpg; done`;
`mogrify -rotate 90 $tempdir/*.jpg`;
die 'No JPEG chunks found' if $!;

opendir (TEMPDIR, $tempdir);
my @files = readdir TEMPDIR;
@files = grep /jpg/, @files;
@files = sort @files;
closedir TEMPDIR;

my $tiles = scalar @files;

my $grid = int (sqrt ($tiles / 6));

die "Cubic images not found" unless ($grid * $grid * 6 == $tiles);
print STDERR "Cubic QTVR found (probably)\n";

for my $face (1 .. 6)
{
    for my $row (1 .. $grid)
    {
        my @jpeg;
        for my $column (1 .. $grid)
        {
            push @jpeg, ("$tempdir/" . shift @files);
        }
        my $cmd = 'convert -append ' . (join ' ', @jpeg) . " $tempdir/img-$face-$row.png";
        `$cmd`;
        `mogrify -rotate -90 $tempdir/img-$face-$row.png`;
    }
    `convert -append $tempdir/img-$face-*.png $tempdir/face-$face.tif`;
    print STDERR "Face $face assembled\n";
}

`cubic2erect $tempdir/face-*.tif $outfile`;

__END__

=head1 NAME

qtvr2erect - Utility to convert cubic QTVR files to equirectangular

=head1 Synopsis

  qtvr2erect /path/to/panorama.mov /path/to/panorama.PNG

=head1 DESCRIPTION

`qtvr2erect' is a command-line utility program for converting cubic QTVR .mov
files to TIFF format equirectangular files suitable for viewing with
`panoglview'.

This script is a cludge, it uses the `qtdechunk' tool from libquicktime to
extract JPEG tiles, guesses the correct re-assembly order, sticks them together
with the ImageMagick `convert' tool and remaps them with `PTmender'.

It is slow, but it works for common QTVR files found in the wild.

=head1 Calling syntax

  qtvr2erect <mov-file> <TIFF-file>

=head1 License

This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=head1 See Also

L<http://libquicktime.sourceforge.net/>, L<http://panotools.sourceforge.net/>

=head1 Author

Bruno Postle, E<lt>bruno (at) postle.netE<gt>

=cut

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks