planktoscope/scripts/image.py

61 lines
1 KiB
Python
Raw Normal View History

2019-12-13 20:59:53 +01:00
#!/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
2019-12-13 21:15:20 +01:00
sample_project = str(sys.argv[1])
2019-12-13 20:59:53 +01:00
#[f] : ISO8601 YYYYMMJJ UTC
2019-12-13 21:15:20 +01:00
sample_date = str(sys.argv[2])
2019-12-13 20:59:53 +01:00
#[f] : ISO8601 HHMMSS UTC
2019-12-13 21:15:20 +01:00
sample_time = str(sys.argv[3])
2019-12-13 20:59:53 +01:00
#[i] : ex:24ml
2019-12-13 21:15:20 +01:00
volume = int(sys.argv[4])
#[f] : ex:3.2ml/min
flowrate = float(sys.argv[5])
2019-12-13 20:59:53 +01:00
2019-12-13 21:15:20 +01:00
warm_up_duration=3
2019-12-13 20:59:53 +01:00
2019-12-13 21:15:20 +01:00
duration = (volume/flowrate)*60 - warm_up_duration
2019-12-13 20:59:53 +01:00
2019-12-13 21:15:20 +01:00
max_fps = 0.7
2019-12-13 20:59:53 +01:00
2019-12-13 21:15:20 +01:00
nb_frame = int(duration/max_fps)
2019-12-13 20:59:53 +01:00
2019-12-13 21:15:20 +01:00
path= "/home/pi/Desktop/"+sample_project+"/"+sample_date+"/"+sample_time+"/"
2019-12-13 20:59:53 +01:00
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)
2019-12-13 21:15:20 +01:00