def test_main(resource, tmpdir): out_file = os.path.join(tmpdir.dirname, 'face-output.jpg') in_file = resource('face-input.jpg') # Make sure there isn't already a green box im = Image.open(in_file) pixels = im.getdata() greens = sum(1 for (r, g, b) in pixels if r == 0 and g == 255 and b == 0) assert greens < 1 main(in_file, out_file, 10) # Make sure there now is some green drawn im = Image.open(out_file) pixels = im.getdata() greens = sum(1 for (r, g, b) in pixels if r == 0 and g == 255 and b == 0) assert greens > 10
def run(self): while True: try: # logger.info('start') if os.path.isfile("/home/pi/project/images/input.jpg"): logger.info("find image") faces.main("/home/pi/project/images/input.jpg", "/home/pi/project/images/out_put.jpg", 4) os.remove("/home/pi/project/images/input.jpg") logger.info("send bot") bot.send_photo( "290652509", open('/home/pi/project/images/out_put.jpg', 'rb')) os.remove('/home/pi/project/images/out_put.jpg') time.sleep(1) except Exception as e: logger.exception("message")
def send_photo(message): faces.main("/home/pi/project/images/abba.png", "/home/pi/project/images/out_put.png", 4) bot.send_photo(message.chat.id, open('/home/pi/project/images/out_put.png', 'rb'), reply_to_message_id=message.message_id)