Experimental Image::BoxFind module:    Image/t/01-looks_rectangular.t


     # Test file created outside of h2xs framework.
# Run this like so: `perl Image-BoxFind.t'
#   doom@kzsu.stanford.edu     2007/09/29 05:22:54

#########################

use warnings;
use strict;
$|=1;

my $DEBUG = 0;

use Data::Dumper;

use Test::More;
BEGIN { plan tests => 5 };

use FindBin qw( $Bin );
use lib "$Bin/../..";

BEGIN {
  use_ok( 'Image::BoxFind' );
}

ok(1, "Traditional: If we made it this far, we're ok.");

{
  my $test_name = "looks_rectangular method";

  # doesn't matter which for this test
  my $image_file = "$Bin/dat/images/gimp_open_dialog.png";
  my $bf = Image::BoxFind->new( { image_file  => $image_file,
                                  DEBUG       => $DEBUG,
                                } );

  # 33 x 110
  my $corners = [
                 [20,66],
                 [130,66],
                 [130,99],
                 [20,99],
                ];

  my $rectangularity = $bf->looks_rectangular( $corners );

  is($rectangularity, 1, "$test_name: perfect rectangle");

     $corners = [
                 [522,566],
                 [630,564],
                 [631,600],
                 [520,599],
                ];

  $rectangularity = $bf->looks_rectangular( $corners );
  is($rectangularity, 1, "$test_name: near rectangle");


     $corners = [
                 [1522,566],
                 [630,564],
                 [631,600],
                 [520,599],
                ];
  $rectangularity = $bf->looks_rectangular( $corners );
  isnt($rectangularity, 1, "$test_name: not a rectangle");

}





     

Joseph Brenner, Tue Nov 27 17:40:02 2007