From 8af111e528149f5a176301f565691c4300ab4301 Mon Sep 17 00:00:00 2001 From: tpollina Date: Fri, 13 Dec 2019 11:59:53 -0800 Subject: [PATCH] Create image.py --- scripts/image.py | 58 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) create mode 100644 scripts/image.py diff --git a/scripts/image.py b/scripts/image.py new file mode 100644 index 0000000..5e1bf93 --- /dev/null +++ b/scripts/image.py @@ -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)