File: transform

package info (click to toggle)
ale 0.9.0.3-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 7,260 kB
  • sloc: cpp: 21,826; sh: 10,106; xml: 4,129; ansic: 2,343; makefile: 565; perl: 454; exp: 319
file content (46 lines) | stat: -rwxr-xr-x 1,054 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl -w

#
# This script accepts as input a transformation file, applying the inverse
# of the specified projective transformation.  This script can be used, e.g.,
# like this:
# 
# $ ale --trans-save=a.t --projective 1.jpg 2.jpg 3.jpg a.jpg
# $ transform `grep -A1 2.jpg a.t | tail -1` < a.t > b.t
# $ ale --trans-load=b.t --projective 1.jpg 2.jpg 3.jpg c.jpg
#

if (defined $ARGV[0] && $ARGV[0] =~ /^P/) {
	shift;
}

@ARGV == 10 or die "usage: $0 <projective-args>\n";

while (<STDIN>) {

	$line = $_;

	if ($line =~ /^V 2/) {
		print "V 3\n";
		$line = "P $ARGV[0] $ARGV[1] 0 0 0 $ARGV[1] $ARGV[0] $ARGV[1] $ARGV[0] 0\n";
	}

	if (!($line =~ /^P (.*)/)) {
		print $line;
		next;
	}

	@new_args = split / /, $1;

	print "P " . $new_args[0] . " " . $new_args[1] . " ";
	shift @new_args; shift @new_args;

	while (@new_args > 0) {
		$result = `echo @ARGV $new_args[0] $new_args[1] | ale --ptcalc 2> /dev/null | grep INVERSE`;
		$result =~ /.*\((.*), (.*)\)/;
		print $1 . " " . $2 . " ";
		shift @new_args; shift @new_args;
	}

	print "\n";
}