2013-05-23 16:11:53 +02:00
|
|
|
#!/usr/bin/env python
|
|
|
|
|
|
|
|
|
|
from __future__ import division
|
2014-06-07 11:19:47 +02:00
|
|
|
from pysstv.sstv import SSTV, byte_to_freq
|
2013-05-23 16:11:53 +02:00
|
|
|
|
2013-06-19 00:15:18 +02:00
|
|
|
|
2013-05-23 16:11:53 +02:00
|
|
|
class GrayscaleSSTV(SSTV):
|
2013-11-22 18:36:58 +01:00
|
|
|
def on_init(self):
|
|
|
|
|
self.pixels = self.image.convert('LA').load()
|
2013-06-19 00:15:18 +02:00
|
|
|
|
2013-06-19 16:17:42 +02:00
|
|
|
def gen_image_tuples(self):
|
2014-06-07 11:27:21 +02:00
|
|
|
for line in range(self.HEIGHT):
|
2014-06-07 11:32:43 +02:00
|
|
|
yield from self.horizontal_sync()
|
|
|
|
|
yield from self.encode_line(line)
|
2013-06-19 00:15:18 +02:00
|
|
|
|
|
|
|
|
def encode_line(self, line):
|
|
|
|
|
msec_pixel = self.SCAN / self.WIDTH
|
2013-11-22 18:36:58 +01:00
|
|
|
image = self.pixels
|
2014-06-07 11:27:21 +02:00
|
|
|
for col in range(self.WIDTH):
|
2013-07-01 16:20:19 +02:00
|
|
|
pixel = image[col, line]
|
2013-11-22 18:36:58 +01:00
|
|
|
freq_pixel = byte_to_freq(pixel[0])
|
2013-06-19 00:15:18 +02:00
|
|
|
yield freq_pixel, msec_pixel
|
2013-05-23 16:11:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Robot8BW(GrayscaleSSTV):
|
2013-06-19 00:15:18 +02:00
|
|
|
VIS_CODE = 0x02
|
|
|
|
|
WIDTH = 160
|
|
|
|
|
HEIGHT = 120
|
|
|
|
|
SYNC = 7
|
|
|
|
|
SCAN = 60
|
2013-05-23 16:11:53 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
|
class Robot24BW(GrayscaleSSTV):
|
2013-06-19 00:15:18 +02:00
|
|
|
VIS_CODE = 0x0A
|
|
|
|
|
WIDTH = 320
|
|
|
|
|
HEIGHT = 240
|
2013-11-22 18:40:25 +01:00
|
|
|
SYNC = 7
|
2013-06-19 00:15:18 +02:00
|
|
|
SCAN = 93
|
2013-06-17 13:02:16 +02:00
|
|
|
|
|
|
|
|
MODES = (Robot8BW, Robot24BW)
|