Video-FrameGrab

 view release on metacpan or  search on metacpan

FrameGrab.pm  view on Meta::CPAN

            my $img = Imager->new();
            my $rc = $img->read( data => $data );
            if(! $rc) {
                LOGWARN "Reading snapshop at time $probe failed ($!)";
                next;
            }
            push @images, $img;
        }
    }

    # average all snapshots to obtain a single overlay image
    my $overlay;

    my $i = 1;

    for my $img (@images) {
        $img->filter(type=>"gaussian", stddev=>10)
               or die $overlay->errstr;

        if(! defined $overlay) {
            $overlay = $img;
            next;
        }
        $overlay->compose( src => $img, combine => 'add' );
        $overlay->filter(type=>"postlevels", levels=>3) or
            die $overlay->errstr;

        if(get_logger()->is_trace()) {
            $overlay->write(file => "i-$i.jpg");
        }
        $i++;
    }

    my @params = $self->cropdetect( 0, { image => $overlay } );

    return @params;

#        my @params = $self->cropdetect( $probe, $opts );
#        if(! defined $params[0] ) {
#            ERROR "cropdetect returned an error";
#            next;
#        }
#        DEBUG "Cropdetect at $probe yielded (@params)";
#        $self->result_push( @params );

FrameGrab.pm  view on Meta::CPAN

The default algorithm is a homegrown detection mechanism 
C<{algorithm =E<gt> "schilli"}>, which first blurs the 
image with the Gaussian Blur algorithm with a radius of
C<$opts-E<gt>{gaussian_blur_radius}> (which defaults to 3),
and then measures if any of the left, right, upper or lower border
pixel lines of the snapped frame average an intensity of less than 
C<$opts-E<gt>{min_intensity_average}>, which defaults to 20.

Note that this is just a guess and might be incorrect at times. In a
dark scene, black pixels might protrude far into the video, making it
impossible to detect the border reliably. However, if you overlay a number
of frames, obtained at several times during the movie (e.g. by using
the equidistant_snap_times method described above), the result
is fairly predicatblye and accurate. C<cropdetect_average>, 
described below, does exactly that.

The alternative algorithm, C<"mplayer">,
asks mplayer to come up with a recommendation on how to crop the video.
This technique delivers incorrect results if there are sporadic white
spots within the dark bars.

=item cropdetect_average( $number_of_probes, [$opts] )

Takes C<$number_of_probes> from the movie at equidistant intervals,
overlays the frames and performs a border detection on the resulting
images, which is almost white in the viewing area.

See C<equidistant_snap_times> for setting the movie length in
the optional C<$opts> parameter.

=item aspect_ratio_guess( ["16:9", "4:3"] )

This function will take the width and height of the video and 
map it to the best matching aspect ratio given in a reference
to an array.

README  view on Meta::CPAN

        The default algorithm is a homegrown detection mechanism "{algorithm
        => "schilli"}", which first blurs the image with the Gaussian Blur
        algorithm with a radius of "$opts->{gaussian_blur_radius}" (which
        defaults to 3), and then measures if any of the left, right, upper
        or lower border pixel lines of the snapped frame average an
        intensity of less than "$opts->{min_intensity_average}", which
        defaults to 20.

        Note that this is just a guess and might be incorrect at times. In a
        dark scene, black pixels might protrude far into the video, making
        it impossible to detect the border reliably. However, if you overlay
        a number of frames, obtained at several times during the movie (e.g.
        by using the equidistant_snap_times method described above), the
        result is fairly predicatblye and accurate. "cropdetect_average",
        described below, does exactly that.

        The alternative algorithm, "mplayer", asks mplayer to come up with a
        recommendation on how to crop the video. This technique delivers
        incorrect results if there are sporadic white spots within the dark
        bars.

    cropdetect_average( $number_of_probes, [$opts] )
        Takes $number_of_probes from the movie at equidistant intervals,
        overlays the frames and performs a border detection on the resulting
        images, which is almost white in the viewing area.

        See "equidistant_snap_times" for setting the movie length in the
        optional $opts parameter.

    aspect_ratio_guess( ["16:9", "4:3"] )
        This function will take the width and height of the video and map it
        to the best matching aspect ratio given in a reference to an array.

    dimensions()



( run in 0.354 second using v1.01-cache-2.11-cpan-65fba6d93b7 )