def proc(): global ls global i global results global adc_threshold1 global counter while (True): start_proc.wait() np.subtract(ls[i - 1], ls[i - 2], out=results) counter = count_above(results, adc_threshold1) print("done", counter) start_proc.clear() next_frame.set()
def diff(background, current, thresh, results): #t.start() #GPIO.setmode(GPIO.BOARD) #GPIO.setup(36,GPIO.OUT,initial=GPIO.LOW) t_start = time.time() np.subtract(background, current, out=results) print(time.time() - t_start) t_start = time.time() # counter = (results>adc_threshold1).sum() counter1 = count_above(results, thresh) # counter1 = (results>adc_threshold1).sum() # counter2 = (results<adc_threshold2).sum() print(time.time() - t_start) return counter1
def run(self, ): # Turn on logging logging.basicConfig( level=logging.DEBUG, format='%(created).6f [%(levelname)s] Stage2 %(message)s', filename='log-stage2.txt', filemode='w') logging.info('started') for f in range(100): # Wait for next frame frame = self.iqueue.get() logging.debug('Received frame %d', f) # Process frame ... np.subtract(ls[f - 1], ls[f - 2], out=results) counter = count_above(results) logging.debug('Forwarding frame %d', f) if (counter > pix_threshold): return True
if(i==0): ls[i] = frame.as_array.reshape(800,1280) print(str(i)) else: ls[i] = frame.as_array.reshape(800,1280) t_start = time.time() print(str(i)) results = np.subtract(ls[i-1],ls[i]) print(time.time()-t_start) t_start=time.time() # counter = (results>adc_threshold1).sum() t_start=time.time() adc_threshold = np.uint8(np.sqrt(np.mean(ls[i-1]))) print(time.time()-t_start) t_start=time.time() counter1 = count_above(results,adc_threshold) # counter1 = (results>adc_threshold1).sum() # counter2 = (results<adc_threshold2).sum() print(time.time()-t_start) counter = counter1 if(counter>pix_threshold): break i+=1 except KeyboardInterrupt: break camera.close_camera() for i in range(100): im = Image.fromarray(ls[i]) im = im.convert("L") im.save(os.path.join(os.getcwd(), "Captures","Buffer-"+"{:02}".format(i)+".png"))
def processing(input_data): background,current = input_data np.subtract(background, current,out=results) counter = count_above(results, adc_threshold1) return counter