2013-05-23 16:11:53 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
from __future__ import division
|
2013-05-23 16:22:30 +02:00
|
|
|
from sstv import SSTV, byte_to_freq
|
2013-05-23 16:11:53 +02:00
|
|
|
|
|
|
|
|
class GrayscaleSSTV(SSTV):
|
|
|
|
|
def gen_freq_bits(self):
|
|
|
|
|
for item in SSTV.gen_freq_bits(self):
|
|
|
|
|
yield item
|
|
|
|
|
for line in xrange(self.HEIGHT):
|
|
|
|
|
for item in self.horizontal_sync():
|
|
|
|
|
yield item
|
|
|
|
|
for item in self.encode_line(line):
|
|
|
|
|
yield item
|
|
|
|
|
|
|
|
|
|
def encode_line(self, line):
|
|
|
|
|
msec_pixel = self.SCAN / self.WIDTH
|
|
|
|
|
image = self.image
|
|
|
|
|
for col in xrange(self.WIDTH):
|
|
|
|
|
pixel = image.getpixel((col, line))
|
2013-05-23 16:22:30 +02:00
|
|
|
freq_pixel = byte_to_freq(sum(pixel) / len(pixel))
|
2013-05-23 16:11:53 +02:00
|
|
|
yield freq_pixel, msec_pixel
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Robot8BW(GrayscaleSSTV):
|
|
|
|
|
VIS_CODE = 0x02
|
|
|
|
|
WIDTH = 160
|
|
|
|
|
HEIGHT = 120
|
|
|
|
|
SYNC = 10
|
|
|
|
|
SCAN = 56
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Robot24BW(GrayscaleSSTV):
|
|
|
|
|
VIS_CODE = 0x0A
|
|
|
|
|
WIDTH = 320
|
|
|
|
|
HEIGHT = 240
|
|
|
|
|
SYNC = 12
|
|
|
|
|
SCAN = 93
|