Create image.py

This commit is contained in:
tpollina 2019-12-13 11:59:53 -08:00 committed by GitHub
parent a099f11031
commit 8af111e528
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

58
scripts/image.py Normal file
View file

@ -0,0 +1,58 @@
#!/usr/bin/env python
import time
from time import sleep
from picamera import PiCamera
from datetime import datetime, timedelta
import os
import sys
#[t] : ex:tara_pacific
sample_project = int(sys.argv[X])
#[f] : ISO8601 YYYYMMJJ UTC
sample_date = float(sys.argv[X])
#[f] : ISO8601 HHMMSS UTC
sample_time = float(sys.argv[X])
#[i] : ex:24ml
volume = int(sys.argv[X])
#[f] : ex:3ml/min
flowrate = float(sys.argv[X])
duration = (volume/flowrate)*60
max_fps = 0.62
nb_frame = float(duration/max_fps)
path= "/home/pi/Desktop/"+str(sample_project)+"/"+str(sample_date)+"/"+str(sample_time)+"/"
if not os.path.exists(path):
os.makedirs(path)
camera = PiCamera()
camera.resolution = (3280, 2464)
camera.iso = 60
def image(nb_frame, path):
sleep(3)
for frame in range(nb_frame):
time = datetime.now().timestamp()
filename=path+"/"+str(time)+".jpg"
camera.capture(filename)
print(time)
sleep(0.1)
image(nb_frame, path)