/[opencvs]/eyes/enl_box_range.pl
ViewVC logotype

Contents of /eyes/enl_box_range.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations)
Sat Apr 28 09:50:55 2012 UTC (6 years, 4 months ago) by hib
Branch: MAIN
CVS Tags: HEAD
File MIME type: text/plain
got enlightenment_pattern sorta working, but it crashes when you have 32
open images sometimes cause of the darn memory.
So I will see if I can put a -limit on it programatically.
1 #
2 # This draws lines to make sure we have the right loading
3
4 $es = $ENV{ENLIGHTENMENT_SIZE};
5 $eh = $ENV{ENLIGHTENMENT_HOME};
6 $common = "$eh/common";
7
8
9 @top = &readit("$common/top_points.txt");
10 @bottom = &readit("$common/bottom_points.txt");
11 @l08 = &readit("$common/l08_points.txt");
12 @l16 = &readit("$common/l16_points.txt");
13 @l24 = &readit("$common/l24_points.txt");
14 @left = &readit("$common/left_points.txt");
15 @right = &readit("$common/right_points.txt");
16
17 $pixels=$es;
18 $factor = ($pixels) / 18000.;
19
20 for ($i=0;$i<=32;$i++) {
21 $top[$i] *= $factor;
22 $bottom[$i] *= $factor;
23 $l08[$i] *= $factor;
24 $l16[$i] *= $factor;
25 $l24[$i] *= $factor;
26 $left[$i] *= $factor;
27 $right[$i] *= $factor;
28 }
29 #
30 # 0 1
31 #
32 # 2 3
33
34 for ($row=0;$row<32;$row++) {
35 $l00 = $left[$row];
36 $l08 = $l08[$row];
37 $l16 = $l16[$row];
38 $l24 = $l24[$row];
39 $l32 = $right[$row];
40 $x00 = 0;
41 $x08 = &lint($top[8],$bottom[8],$l08,$pixels);
42 $x16 = &lint($top[16],$bottom[16],$l16,$pixels);
43 $x24 = &lint($top[24],$bottom[24],$l24,$pixels);
44 $x32 = $pixels;
45
46 $l00p = $left[$row+1];
47 $l08p = $l08[$row+1];
48 $l16p = $l16[$row+1];
49 $l24p = $l24[$row+1];
50 $l32p = $right[$row+1];
51 $x00p = 0;
52 $x08p = &lint($top[8],$bottom[8],$l08p,$pixels);
53 $x16p = &lint($top[16],$bottom[16],$l16p,$pixels);
54 $x24p = &lint($top[24],$bottom[24],$l24p,$pixels);
55 $x32p = $pixels;
56
57 for ($col=0;$col<8;$col++) {
58 ($x0,$y0) = &line_line_intersection_point($top[$col],0,$bottom[$col],$pixels,
59 $x00,$l00,$x08,$l08);
60 ($x1,$y1) = &line_line_intersection_point($top[$col+1],0,$bottom[$col+1],$pixels,
61 $x00,$l00,$x08,$l08);
62 ($x2,$y2) = &line_line_intersection_point($top[$col],0,$bottom[$col],$pixels,
63 $x00p,$l00p,$x08p,$l08p);
64 ($x3,$y3) = &line_line_intersection_point($top[$col+1],0,$bottom[$col+1],$pixels,
65 $x00p,$l00p,$x08p,$l08p);
66 print "$col|$row|$x0|$y0|$x1|$y1|$x2|$y2|$x3|$y3\n";
67 }
68 for ($col=8;$col<16;$col++) {
69 ($x0,$y0) = &line_line_intersection_point($top[$col],0,$bottom[$col],$pixels,
70 $x08,$l08,$x16,$l16);
71 ($x1,$y1) = &line_line_intersection_point($top[$col+1],0,$bottom[$col+1],$pixels,
72 $x08,$l08,$x16,$l16);
73 ($x2,$y2) = &line_line_intersection_point($top[$col],0,$bottom[$col],$pixels,
74 $x08p,$l08p,$x16p,$l16p);
75 ($x3,$y3) = &line_line_intersection_point($top[$col+1],0,$bottom[$col+1],$pixels,
76 $x08p,$l08p,$x16p,$l16p);
77 print "$col|$row|$x0|$y0|$x1|$y1|$x2|$y2|$x3|$y3\n";
78 }
79 for ($col=16;$col<24;$col++) {
80 ($x0,$y0) = &line_line_intersection_point($top[$col],0,$bottom[$col],$pixels,
81 $x16,$l16,$x24,$l24);
82 ($x1,$y1) = &line_line_intersection_point($top[$col+1],0,$bottom[$col+1],$pixels,
83 $x16,$l16,$x24,$l24);
84 ($x2,$y2) = &line_line_intersection_point($top[$col],0,$bottom[$col],$pixels,
85 $x16p,$l16p,$x24p,$l24p);
86 ($x3,$y3) = &line_line_intersection_point($top[$col+1],0,$bottom[$col+1],$pixels,
87 $x16p,$l16p,$x24p,$l24p);
88 print "$col|$row|$x0|$y0|$x1|$y1|$x2|$y2|$x3|$y3\n";
89 }
90 for ($col=24;$col<32;$col++) {
91 ($x0,$y0) = &line_line_intersection_point($top[$col],0,$bottom[$col],$pixels,
92 $x24,$l24,$x32,$l32);
93 ($x1,$y1) = &line_line_intersection_point($top[$col+1],0,$bottom[$col+1],$pixels,
94 $x24,$l24,$x32,$l32);
95 ($x2,$y2) = &line_line_intersection_point($top[$col],0,$bottom[$col],$pixels,
96 $x24p,$l24p,$x32p,$l32p);
97 ($x3,$y3) = &line_line_intersection_point($top[$col+1],0,$bottom[$col+1],$pixels,
98 $x24p,$l24p,$x32p,$l32p);
99 print "$col|$row|$x0|$y0|$x1|$y1|$x2|$y2|$x3|$y3\n";
100 }
101 }
102
103
104
105
106
107
108 sub readit {
109 my ($filename) = @_;
110 my @var;
111 open(X,"$filename");
112 while (<X>) {
113 my $r = $_;
114 chomp($r);
115 push(@var,$r);
116 }
117 return @var;
118 }
119
120
121 sub lint {
122 my ($f,$t,$pos,$size) = @_;
123 my ($x);
124 $x = $f + ($t-$f) * $pos / $size;
125 return $x;
126 }
127
128
129
130 sub line_line_intersection_point {
131 # point 1,2 make one line
132 # point 3,4 make the other line
133 my ($x1,$y1,$x2,$y2,$x3,$y3,$x4,$y4) = @_;
134
135 my $denominator = ($x1-$x2)*($y3-$y4)-($y1-$y2)*($x3-$x4);
136 my ($x,$y);
137 if ($denominator != 0) {
138 $x= (($x1 * $y2- $y1 * $x2) * ($x3-$x4) - ($x1-$x2) * ($x3 * $y4 - $y3 * $x4)) / $denominator;
139 $y= (($x1 * $y2- $y1 * $x2) * ($y3-$y4) - ($y1-$y2) * ($x3 * $y4 - $y3 * $x4)) / $denominator;
140 }
141 else {
142 print STDERR "Parallel $x1,$y1,$x2,$y2,$x3,$y3,$x4,$y4\n";
143 exit(-1);
144 }
145 if ($x<0) {$x=0;}
146 if ($x>$pixels) {$x=$pixels;}
147 if ($y<0) {$y=0;}
148 if ($y>$pixels) {$y=$pixels;}
149 #print STDERR "intersect $x1,$y1,$x2,$y2 $x3,$y3,$x4,$y4 -> $x,$y denom $denominator\n";
150 return ($x,$y);
151 }
152
153

  ViewVC Help
Powered by ViewVC 1.1.5