planktoscope/scripts/image.py

67 lines
1.2 KiB
Python
Raw Normal View History

2019-12-13 20:59:53 +01:00
#!/usr/bin/env python
2019-12-13 21:34:09 +01:00
2019-12-13 22:01:34 +01:00
#Imaging a volume with a flowrate
#in folder named "/home/pi/PlanktonScope/acquisitions/sample_project/sample_id/acq_id"
#python3.7 $HOME/PlanktonScope/scripts/image.py tara_pacific sample_project sample_id acq_id volume flowrate
2019-12-13 21:34:09 +01:00
2019-12-13 20:59:53 +01:00
import time
from time import sleep
from picamera import PiCamera
from datetime import datetime, timedelta
import os
import sys
2019-12-13 23:51:50 +01:00
in_path = str(sys.argv[1])
2019-12-13 20:59:53 +01:00
#[t] : ex:tara_pacific
2019-12-13 23:51:50 +01:00
sample_project = str(sys.argv[2])
2019-12-13 20:59:53 +01:00
2019-12-13 22:01:34 +01:00
#[t] : unique identifier
2019-12-13 23:51:50 +01:00
sample_id = str(sys.argv[3])
2019-12-13 20:59:53 +01:00
2019-12-13 22:01:34 +01:00
#[t] : unique identifier
2019-12-13 23:51:50 +01:00
acq_id = str(sys.argv[4])
2019-12-13 20:59:53 +01:00
#[i] : ex:24ml
2019-12-14 10:33:17 +01:00
volume = 24
2019-12-13 21:15:20 +01:00
#[f] : ex:3.2ml/min
2019-12-14 10:33:17 +01:00
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 23:51:50 +01:00
path= in_path+sample_project+"/"+sample_id+"/"+acq_id+"/"
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)