<commit_before>#! /usr/bin/python
"""
ppp.py
peggy.pi.pic
Take picture with Raspberry Pi camera and then display
    as 25 x 25 pixel image (16 shades) on Peggy2
"""

# http://picamera.readthedocs.org/en/release-1.9/recipes1.html#capturing-to-a-pil-image
import io
import time
import picamera
from PIL import Image

# Create the in-memory stream
stream = io.BytesIO()
with picamera.PiCamera() as camera:
    camera.hflip = True
    camera.vflip = True
    camera.start_preview()
    time.sleep(2)
    camera.capture(stream, format='jpeg')
# "Rewind" the stream to the beginning so we can read its content
stream.seek(0)
image = Image.open(stream)

# initial test - show image
image.show()
time.sleep(10)

# #crop square
# image = image.crop((0,0,720,720))
# #convert to grey
# image = image.convert('L')
#
# image.thumbnail((25,25))
#
# pxls = list(image.getdata())
<commit_msg>test convert image to square, grey<commit_after>#! /usr/bin/python
"""
ppp.py
peggy.pi.pic
Take picture with Raspberry Pi camera and then display
    as 25 x 25 pixel image (16 shades) on Peggy2
"""

# http://picamera.readthedocs.org/en/release-1.9/recipes1.html#capturing-to-a-pil-image
import io
import time
import picamera
from PIL import Image

# Create the in-memory stream
stream = io.BytesIO()
with picamera.PiCamera() as camera:
    camera.hflip = True
    camera.vflip = True
    camera.start_preview()
    time.sleep(2)
    camera.capture(stream, format='jpeg')
# "Rewind" the stream to the beginning so we can read its content
stream.seek(0)
image = Image.open(stream)

#crop square
image = image.crop((0,0,720,720))
#convert to grey
image = image.convert('L')

# test - show image
image.show()
#
# image.thumbnail((25,25))
#
# pxls = list(image.getdata())

{'fraction_non_alphanumeric': 0.13172966781214204, 'fraction_numerical': 0.0286368843069874, 'mean_word_length': 4.093294460641399, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '687117', 'n_tokens_mistral': 656, 'n_tokens_neox': 618, 'n_words': 173}