Skip to content
This repository was archived by the owner on Mar 23, 2024. It is now read-only.

Commit dc8987e

Browse files
committed
Update due to new specs
1 parent bfff228 commit dc8987e

File tree

1 file changed

+11
-12
lines changed

1 file changed

+11
-12
lines changed

Diff for: raspberry_pi/wave_mirror.py

+11-12
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
# -*-coding:Utf-8 -*
22

3-
"""This script is the main program of our project.
3+
"""This is the main Raspberry Pi's program of our project.
44
5-
It was developped for Python version 2.7.13
6-
If you wish to upgrade to Python3, you must install the Pillow
7-
library instead of PIL.
5+
It it for use with Python version 2.7.13
6+
If you wish to upgrade to Python3, you must use Pillow instead of PIL.
87
98
The goal is to capture the image of the PiCamera, convert it to black & white,
10-
cut the image in 12*10 squares of pixels, get the grayscale values of each of
9+
cut the image in the required squares of pixels, get the grayscale values of each of
1110
those squares, and then send these values to each Arduino via I2C.
1211
1312
You can find the Arduino's code at :
@@ -29,12 +28,12 @@
2928
camera = picamera.PiCamera()
3029
stream = BytesIO()
3130

32-
output_width = 12 # Number of Arduinos
33-
output_height = 10 # Number of Servos an Arduino controls
31+
output_width = 8 # Number of Arduinos
32+
output_height = 6 # Number of Servos per Arduino
3433

3534
# The larger the resolution, the clearer the image
3635
# This also means bigger procession time
37-
camera.resolution = (800, 600)
36+
camera.resolution = (480, 360)
3837
(width, height) = camera.resolution
3938

4039
# We calculate the width and height of each square in the grid
@@ -45,7 +44,7 @@
4544
nb_pixels = tailleH * tailleL
4645

4746
# Uncomment below this if you want a live preview of what the camera captures
48-
# It only works if the Raspberry Pi's is connected to a monitor, not VNC
47+
# It only works if the Raspberry Pi's is connected to a monitor, not VNC or SSH
4948
### camera.start_preview()
5049

5150
# Let enough time for the camera to warmup
@@ -83,15 +82,14 @@
8382
coordY = y + (pixHDepart)
8483
current_pixel_value = Image.getpixel(image, (coordX, coordY))
8584
sum_gray += current_pixel_value
86-
a += 1
8785

8886
# We divide the sum of gray in the square by the number
8987
# of pixels the square have, to get its average greyscale value
90-
average_gray = int(sum_gray / nb_pixels)
88+
average_gray = int(sum_gray/nb_pixels)
9189

9290
# Each Arduino treats a row, so we send 12 values to each of them.
9391
# That means if we have sent 12 values, we change Arduinos.
94-
if (case%12)+1 == 1 :
92+
if (case%output_width)+1 == 1 :
9593
arduino += 1
9694
case +=1
9795

@@ -100,3 +98,4 @@
10098

10199
# Let the program rest a bit
102100
sleep(0.001)
101+
sleep(0.01)

0 commit comments

Comments
 (0)