<commit_before>#!/usr/bin/env python3
"""
Hyperspectal camera viewer for Raspiberry pi
"""
__author__ = "<NAME> <www.danielcasner.org>"

import picamera
import picamera.array
import infragram
import numpy

WB_GAINS = (1.2, 0.9)


def main():
    with picamera.PiCamera() as camera:
        camera.resolution = (1280, 720)
        camera.awb_mode = 'off'
        camera.awb_gains = WB_GAINS
        camera.framerate = 12
        camera.start_preview()
        overlay = None
        with picamera.array.PiRGBArray(camera, size=camera.resolution) as output:
            while True:
                try:
                    camera.capture(output, format='rgb', use_video_port=True)
                    ndvi_arr = infragram.ndvi(output.array)
                    rgb_arr = numpy.stack([ndvi_arr, ndvi_arr, ndvi_arr], axis=2)
                    if overlay is None:
                        overlay = camera.add_overlay(rgb_arr.tobytes(), format='rgb', layer=3, size=camera.resolution)
                    else:
                        overlay.update(rgb_arr.tobytes())
                    output.seek(0)
                    output.truncate()
                except KeyboardInterrupt:
                    if overlay:
                        camera.remove_overlay(overlay)
                    break


if __name__ == '__main__':<commit_msg>Tuning to make the script kiosk experience more stable.<commit_after>#!/usr/bin/env python3
"""
Hyperspectal camera viewer for Raspiberry pi
"""
__author__ = "<NAME> <www.danielcasner.org>"

import picamera
import picamera.array
import infragram
import numpy
import time

WB_GAINS = (1.2, 0.9)


def main():
    with picamera.PiCamera() as camera:
        camera.resolution = (1280, 720)
        camera.awb_mode = 'off'
        camera.awb_gains = WB_GAINS
        camera.framerate = 0.25
        camera.start_preview()
        overlay = None
        with picamera.array.PiRGBArray(camera, size=camera.resolution) as output:
            while True:
                try:
                    camera.capture(output, format='rgb', use_video_port=True)
                    ndvi_arr = infragram.ndvi(output.array)
                    rgb_arr = numpy.stack([ndvi_arr, ndvi_arr, ndvi_arr], axis=2)
                    if overlay is None:
                        overlay = camera.add_overlay(rgb_arr.tobytes(), format='rgb',
                                                     layer=3, size=camera.resolution, alpha=128)
                    else:
                        overlay.update(rgb_arr.tobytes())
                    output.seek(0)
                    output.truncate()
                    time.sleep(0.05)
                except KeyboardInterrupt:
                    if overlay:
                        camera.remove_overlay(overlay)
                    break


if __name__ == '__main__':
{'fraction_non_alphanumeric': 0.0935838355193194, 'fraction_numerical': 0.014533853243530664, 'mean_word_length': 1.6723484848484849, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7413615', 'n_tokens_mistral': 864, 'n_tokens_neox': 785, 'n_words': 171}