summaryrefslogtreecommitdiffstats
path: root/video_signal_captures/hp54522c/foo.pl
blob: 4bea715f274bed20ce274f8dc16dbdf324b4e4cb (plain)
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/usr/bin/env perl

use Data::Dumper;

my $x = 1000;
my $y = 1000;

my $done=0;
my $fl;
my $m;

sub foo($) {
    my $l = shift;

    my $ov = $fl->[9];
    my $oh = $fl->[10];
    my $v  = $l->[9];
    my $h  = $l->[10];

    $x++;

    if ( ( $oh eq '1' ) and ( $h eq '0' ) ) {
        $x = 0;

        $y++;

        $y = 0 if   $v eq '0';
    }

    if (($ov eq '1') and ($v eq'0')) {
	$done++;
	}


    if ( ( $x < 1000 ) and ( $y < 1000 ) ) {
        my $p  = ord( pack( 'b8', join( "", @$l[ 1 .. 8 ] ) ) );
        my $lx = $x - 190;
        my $ly = $y - 22;

        if ( ( $ly >= 0 ) && ( $ly < 384 ) ) {
            if ( ( $lx >= 0 ) && ( $lx < 640 ) ) {
                $m->[ ( $ly * 640 ) + $lx ] = $p;
            }
        }
    }

    $fl = $l;

}

open FISH, '<', 'in.csv';
my ( $l, $ol );

<FISH>;
<FISH>;
<FISH>;
<FISH>;
<FISH>;

while ($done!=3) {
	my $e=<FISH>;
    chomp $e;
    chomp $e;
    chop $e;

    $l = [ split /,/, $e ];

    if ( ( $ol->[12] eq '1' ) and ( $l->[12] eq '0' ) ) {
        foo($l);
    }

    $ol = $l;

}
close FISH;

print "P3\n";
print  "316 480\n";
#print  "632 480\n";
#print  "1272 480\n";
print "255\n";


sub pixel($)
{
my $p=shift;

if ($p & 1) {
	print "255 ";
} else {
	print "0   ";
}

if ($p & 2) {
	print "255 ";
} else {
	print "0   ";
}

if ($p & 0xfc) {
	print "255 ";
} else {
	print "0   ";
}
}

my $o = 0;
for ( $y = 0 ; $y < 960; $y++ ) {
    for ( $x = 0 ; $x < 316 ; $x++ ) {

        my $v=int( $m->[$o] );

        pixel($v);
	print "\n";
        $o++;
    }
if (($y %2) =='1') {
$o++;
$o++;
$o++;
$o++;
}

}