This system was built to keep track of hours each member spent during the 2018 Build Season FIRST Robotics competition
The script was made to be used with a raspberry pi using the full desktop version of raspbian as well as a usb camera
Written in Python 3.6.2; however, support for Python 2 is unknown
You will only need three of the files to run the script spreadsheets.py
BarcodeScanner.py
main.py
I may combine the three scripts into one file
There are a few necessary modules to run the program
the shell code only applies if you have only python 3 installed, if not you will need to us
pip3 install
to correctly install the modules
- gspread and oauth2client from Google API
pip install gspread oauth2client
- Pillow
pip install Pillow
- opencv 3
pip install opencv-python
- numpy
pip install numpy
- zbar
pip install zbar-py
- Setup a worksheet with 3 spreadsheets in google spreadsheet
your first 2 spreadsheets should resemble with row 4 acting as a divider
Last Name | First Name | Student ID | 1/1 | 1/2 | etc | |
---|---|---|---|---|---|---|
Smith | John | 55555555 | ||||
Generic | Jill | 55555556 |
your last sheet should look something like this
Last Name | First Name | Student ID | total time | |
---|---|---|---|---|
Smith | John | 55555555 | ||
Generic | Jill | 55555556 |
- Go to google api developer credentials and create a new service account key as an editor, rename the file to
client_secret.json
, and put the file in the same folder as your other files
- Open the
client_secret.json
and copy the client email in the file which looks something like this
"client_email": "[email protected]",
- On your google spreadsheet, share the file to the
"client_email"
from theclient_secret.json
in the previous step - Open
main.py
and look for andself.s = spreadsheet("test")
by adding your worksheet file title instead of"test"
which is located on line 44
42 self.read = readBarcode() 43 self.results = "" 44 self.s = spreadsheet("YOUR FILE NAME HERE") #place worksheet title here 45 46 self.stopEvent= threading.Event()
- If you already have a camera on the pi or any other device and don't want to use that camera, then change
cap = cv2.VideoCapture(0)
on line 151 to1
or any other number instead of0
(built or first camera plugged in)
149 #1 is for usb camera on a computer with a webcam builtin, 150 #0 is for the first camera 151 cap = cv2.VideoCapture(1)
- You can either run the script in idle or in terminal.
To run the script in idle, open
main.py
the file in idle and go to the drop down menu Run and run module or use F5.To run in terminal, open the terminal and
cd
into your folder then run the code usingpython main.py
orpython3 main.py
if you have python 2 installed