def __init__(self, freq): self.freq = freq self.wav = None self.histeresis = HISTERESIS_UP self.old_histeresis = 0 self.is_recording = False self.memory_up = [] self.insert_timestamp = False # Energy (signal strength) estimation self.dbfs_avg = None self.dbfs_off = 0 self.display_count = 0 # Autocorrelation average self.ac_avg = None # IF self.if_freq = freq - CENTER # works because both if_freq and INPUT_RATE are multiples of STEP self.carrier_table = [ cmath.exp((0 - 1j) * tau * t * (self.if_freq / INPUT_RATE)) for t in range(0, INGEST_SIZE * 2) ] self.carrier_table = numpy.array(self.carrier_table) self.if_period = INPUT_RATE // STEP self.if_phase = 0 self.last_if_sample = numpy.array([]) # IF filtering # complex samples, filter goes from -freq to +freq self.if_filter = filters.low_pass(INPUT_RATE, IF_BANDWIDTH / 2, 48) self.if_decimator = filters.decimator(INPUT_RATE // IF_RATE) # Audio filter self.audio_filter = filters.low_pass(IF_RATE, AUDIO_BANDWIDTH, 24) self.audio_decimator = filters.decimator(IF_RATE // AUDIO_RATE) self.dc_filter = filters.high_pass(AUDIO_RATE, 100, 6) # Thread def worker(): while True: iqsamples = self.queue.get() if iqsamples is None: break self._ingest(iqsamples) self.queue.task_done() self.queue = queue.Queue() self.thread = threading.Thread(target=worker) self.thread.start()
def prepare(image, show_image, logger): # TODO comment im_l = image.convert('L') show_image(im_l, "ITU-R 601-2 luma transform") logger("edge detection") im_edges = filters.edge_detection(im_l) show_image(im_edges, "edge detection") im_h = filters.high_pass(im_edges, 100) show_image(im_h, "high pass filters") return im_h
def transform(image, hough, show_image): # TODO comment im_hough = hough.transform(image) show_image(im_hough, "hough transform") # im_hough = filters.peaks(im_hough) # show_image(im_hough, "peak extraction") im_h2 = filters.high_pass(im_hough, 128) show_image(im_h2, "second high pass filters") im_h2 = filters.components(im_h2, 2) show_image(im_h2, "components centers") return im_h2
def transform(image, hough, show_image): """Produces a simplified Hough transformation of the input image.""" # TODO comment im_hough = hough.transform(image) show_image(im_hough, "hough transform") # im_hough = filters.peaks(im_hough) # show_image(im_hough, "peak extraction") im_h2 = filters.high_pass(im_hough, 128) show_image(im_h2, "second high pass filters") im_h2 = filters.components(im_h2, 2) show_image(im_h2, "components centers") return im_h2