kopia lustrzana https://github.com/dnet/pySSTV
ran 2to3 on examples
rodzic
456040aa6b
commit
5d3d6a2584
|
@ -69,10 +69,10 @@ def main(sstv_class=None):
|
|||
n += 1
|
||||
del lut
|
||||
m_start, m_len = gen_matches(same_as, history, n)
|
||||
for i in xrange(same_as[m_start]):
|
||||
for i in range(same_as[m_start]):
|
||||
yield history[i][0]
|
||||
yield 'for (int row = 0; row < width * {0}; row += width) {{'.format(sstv.HEIGHT)
|
||||
for i in xrange(same_as[m_start], same_as[m_start] + m_len - 1):
|
||||
for i in range(same_as[m_start], same_as[m_start] + m_len - 1):
|
||||
yield ' ' + history[i][1]
|
||||
yield '}'
|
||||
yield '}}\n\n#define FREQ_COUNT {0}'.format(n)
|
||||
|
@ -83,7 +83,7 @@ def gen_matches(same_as, history, n):
|
|||
cur_start = None
|
||||
cur_len = None
|
||||
cur_end = None
|
||||
for i in xrange(n):
|
||||
for i in range(n):
|
||||
if cur_start is None:
|
||||
tmp = same_as.get(i)
|
||||
if tmp is not None:
|
||||
|
@ -114,22 +114,22 @@ def test(img_file):
|
|||
import struct
|
||||
exe = './codegen-test-executable'
|
||||
if not path.exists('stb_image.h'):
|
||||
from urllib import urlretrieve
|
||||
from urllib.request import urlretrieve
|
||||
urlretrieve('https://raw.githubusercontent.com/nothings/stb/master/stb_image.h', 'stb_image.h')
|
||||
try:
|
||||
for sstv_class in supported:
|
||||
print 'Testing', sstv_class
|
||||
print('Testing', sstv_class)
|
||||
gcc = Popen(['gcc', '-xc', '-lm', '-o', exe, '-'], stdin=PIPE)
|
||||
start = datetime.now()
|
||||
with open(path.join(path.dirname(__file__), 'codeman.c')) as cm:
|
||||
c_src = cm.read().replace('#include "codegen.c"', '\n'.join(main(sstv_class)))
|
||||
gcc.communicate(c_src)
|
||||
gen_elapsed = datetime.now() - start
|
||||
print ' - gengcc took', gen_elapsed
|
||||
print(' - gengcc took', gen_elapsed)
|
||||
start = datetime.now()
|
||||
gen = check_output([exe, img_file])
|
||||
native_elapsed = datetime.now() - start
|
||||
print ' - native took', native_elapsed
|
||||
print(' - native took', native_elapsed)
|
||||
img = Image.open(img_file)
|
||||
sstv = sstv_class(img, 44100, 16)
|
||||
start = datetime.now()
|
||||
|
@ -145,13 +145,13 @@ def test(img_file):
|
|||
f.write(struct.pack('ff', freq, msec))
|
||||
with file('/tmp/{0}.c'.format(mode_name), 'w') as f:
|
||||
f.write(c_src)
|
||||
print (" ! Outputs are different, they've been saved to "
|
||||
print((" ! Outputs are different, they've been saved to "
|
||||
"/tmp/{0}-{{c,py}}.bin, along with the C source code "
|
||||
"in /tmp/{0}.c").format(mode_name)
|
||||
"in /tmp/{0}.c").format(mode_name))
|
||||
python_elapsed = datetime.now() - start
|
||||
print ' - python took', python_elapsed
|
||||
print ' - speedup:', python_elapsed.total_seconds() / native_elapsed.total_seconds()
|
||||
print 'OK'
|
||||
print(' - python took', python_elapsed)
|
||||
print(' - speedup:', python_elapsed.total_seconds() / native_elapsed.total_seconds())
|
||||
print('OK')
|
||||
finally:
|
||||
try:
|
||||
remove(exe)
|
||||
|
@ -164,4 +164,4 @@ if __name__ == '__main__':
|
|||
if len(argv) > 2 and argv[1] == 'test':
|
||||
test(argv[2])
|
||||
else:
|
||||
print '\n'.join(main())
|
||||
print('\n'.join(main()))
|
||||
|
|
|
@ -6,13 +6,13 @@
|
|||
|
||||
from gimpfu import register, main, pdb, PF_BOOL, PF_STRING, PF_RADIO, CLIP_TO_IMAGE
|
||||
from PIL import Image, ImageTk
|
||||
from Tkinter import Tk, Canvas, Button, Checkbutton, IntVar, Frame, LEFT, NW
|
||||
from tkinter import Tk, Canvas, Button, Checkbutton, IntVar, Frame, LEFT, NW
|
||||
from pysstv import __main__ as pysstv_main
|
||||
from pysstv.examples.pyaudio_sstv import PyAudioSSTV
|
||||
from pysstv.sstv import SSTV
|
||||
from itertools import repeat
|
||||
from threading import Thread
|
||||
from Queue import Queue, Empty
|
||||
from queue import Queue, Empty
|
||||
from time import sleep
|
||||
import gimp, os
|
||||
|
||||
|
@ -118,12 +118,12 @@ class ProgressCanvas(Canvas):
|
|||
self.height_ratio = 1
|
||||
width, height = image.size
|
||||
pixels = image.load()
|
||||
RED, GREEN, BLUE = range(3)
|
||||
RED, GREEN, BLUE = list(range(3))
|
||||
self.colors = ['#{0:02x}{1:02x}{2:02x}'.format(
|
||||
contrast(sum(pixels[x, y][RED] for x in xrange(width)) / width),
|
||||
contrast(sum(pixels[x, y][GREEN] for x in xrange(width)) / width),
|
||||
contrast(sum(pixels[x, y][BLUE] for x in xrange(width)) / width))
|
||||
for y in xrange(height)]
|
||||
contrast(sum(pixels[x, y][RED] for x in range(width)) / width),
|
||||
contrast(sum(pixels[x, y][GREEN] for x in range(width)) / width),
|
||||
contrast(sum(pixels[x, y][BLUE] for x in range(width)) / width))
|
||||
for y in range(height)]
|
||||
if height / float(width) > 1.5:
|
||||
width *= 2
|
||||
elif width < 200:
|
||||
|
@ -237,7 +237,7 @@ register(
|
|||
"*",
|
||||
[
|
||||
(PF_RADIO, "mode", "SSTV mode", "MartinM1",
|
||||
tuple((n, n) for n in sorted(MODULE_MAP.iterkeys()))),
|
||||
tuple((n, n) for n in sorted(MODULE_MAP.keys()))),
|
||||
(PF_BOOL, "vox", "Include VOX tones", True),
|
||||
(PF_STRING, "fskid", "FSK ID", ""),
|
||||
(PF_RADIO, "ptt_port", "PTT port", None,
|
||||
|
|
|
@ -5,7 +5,7 @@ Demonstrates playing the generated samples directly using PyAudio
|
|||
Tested on PyAudio 0.2.7 http://people.csail.mit.edu/hubert/pyaudio/
|
||||
"""
|
||||
|
||||
from __future__ import division
|
||||
|
||||
from pysstv.sstv import SSTV
|
||||
from time import sleep
|
||||
from itertools import islice
|
||||
|
|
|
@ -8,9 +8,9 @@ simply copying/linking images to the directory or suing an SSTV
|
|||
receiver such as slowrx or QSSTV.
|
||||
"""
|
||||
|
||||
from __future__ import print_function
|
||||
|
||||
from pyinotify import WatchManager, Notifier, ProcessEvent, IN_CREATE
|
||||
from pyaudio_sstv import PyAudioSSTV
|
||||
from .pyaudio_sstv import PyAudioSSTV
|
||||
from pysstv.color import MartinM1, MartinM2, ScottieS1, ScottieS2
|
||||
from pysstv.grayscale import Robot8BW, Robot24BW
|
||||
from PIL import Image
|
||||
|
@ -44,13 +44,13 @@ class EventHandler(ProcessEvent):
|
|||
|
||||
def get_module_for_filename(filename):
|
||||
basename, _ = path.splitext(path.basename(filename))
|
||||
for mode, module in MODE_MAP.iteritems():
|
||||
for mode, module in MODE_MAP.items():
|
||||
if mode in basename:
|
||||
return module
|
||||
|
||||
def get_module_for_image(image):
|
||||
size = image.size
|
||||
for mode in MODE_MAP.itervalues():
|
||||
for mode in MODE_MAP.values():
|
||||
if all(i >= m for i, m in zip(size, (mode.WIDTH, mode.HEIGHT))):
|
||||
return mode
|
||||
|
||||
|
|
Ładowanie…
Reference in New Issue