Update mqtt_pump_focus_image.py

This commit is contained in:
tpollina 2020-02-01 21:25:49 +01:00 committed by GitHub
parent 65adfa5da4
commit 78de7302ad
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -5,6 +5,7 @@ from adafruit_motor import stepper
from adafruit_motorkit import MotorKit from adafruit_motorkit import MotorKit
from time import sleep from time import sleep
import shutil
import json import json
import os import os
@ -47,12 +48,11 @@ camera = PiCamera()
camera.resolution = (3280, 2464) camera.resolution = (3280, 2464)
camera.iso = 60 camera.iso = 60
sleep(3) sleep(3)
camera.shutter_speed = 100 camera.shutter_speed = 500
camera.exposure_mode = 'off' camera.exposure_mode = 'off'
g = camera.awb_gains g = camera.awb_gains
camera.awb_mode = 'off' camera.awb_mode = 'off'
camera.awb_gains = g camera.awb_gains = g
nb_frame=200
################################################################################ ################################################################################
message = '' message = ''
@ -182,7 +182,6 @@ while True:
for i in range(nb_step): for i in range(nb_step):
pump_stepper.onestep(direction=stepper.FORWARD, style=stepper.DOUBLE) pump_stepper.onestep(direction=stepper.FORWARD, style=stepper.DOUBLE)
sleep(0.01) sleep(0.01)
directory = os.path.join(path, "PlanktonScope") directory = os.path.join(path, "PlanktonScope")
os.makedirs(directory, exist_ok=True) os.makedirs(directory, exist_ok=True)
@ -196,8 +195,8 @@ while True:
path_time = os.path.join(path_date,time) path_time = os.path.join(path_date,time)
os.makedirs(path_time, exist_ok=True) os.makedirs(path_time, exist_ok=True)
while True: while True:
count+=1 count+=1
print(count,nb_frame) print(count,nb_frame)
@ -310,14 +309,25 @@ while True:
Call(client.publish, "receiver/image", object_id) Call(client.publish, "receiver/image", object_id)
p.run() p.run()
#remove directory
shutil.rmtree(import_path)
sleep(sleep_during) sleep(sleep_during)
count=0
for i in range(nb_step): for i in range(nb_step):
pump_stepper.onestep(direction=stepper.FORWARD, style=stepper.DOUBLE) pump_stepper.onestep(direction=stepper.FORWARD, style=stepper.DOUBLE)
sleep(0.01) sleep(0.01)
count=0
date=datetime.now().strftime("%m_%d_%Y")
time=datetime.now().strftime("%H_%M")
path_date = os.path.join(directory, date)
os.makedirs(path_date, exist_ok=True)
path_time = os.path.join(path_date,time)
os.makedirs(path_time, exist_ok=True)
if topic!="image": if topic!="image":
pump_focus.release() pump_focus.release()
print("The imaging has been interrompted.") print("The imaging has been interrompted.")