Ejemplo n.º 1
0
def main():

    try:
        d6t = grove_d6t.GroveD6t()

        if not os.path.isdir('csv'):
            os.mkdir('csv')
        # 観測フォルダ番号を振る
        path = set_folder_name()

        file = open(path + 'temperature.csv', 'w')
        w = csv.writer(file)

        i = 0
        temp_ls = []
        while i < 100:
            tpn, tptat = d6t.readData()
            if tpn is None:
                continue
            max_temp = max(tpn)
            temp_ls.append(max_temp)
            w.writerow([str(max_temp)])
            print(str(i) + " : " + str(max_temp))
            i += 1

        file.close()
        with open(path + 'avg.txt', 'w') as f:
            f.write(str(sum(temp_ls) / len(temp_ls)))

        is_tmp = False
        temperature = 0
        while not is_tmp:
            print("Input your body temperature.")
            temp = input()
            try:
                float(temp)
                is_tmp = True
            except ValueError:
                pass
            temperature = float(temp)
        file = open(path + 'correct.csv', 'w')
        w = csv.writer(file)
        w.writerow([temperature])
        file.close()
        file = open(path + 'date.csv', 'w')
        w = csv.writer(file)
        w.writerow([str(datetime.datetime.now())])
        file.close()
        print("Result saved at " + path)
    except KeyboardInterrupt:
        print("done")
faceNet = cv2.dnn.readNet(prototxtPath, weightsPath)
f = open("/home/pi/share/config", 'r')
test_string = f.read()
f.close()
res = json.loads(test_string)
# load the face mask detector model from disk
print("[INFO] loading face mask detector model...")
maskNet = load_model(args["model"])
host_ip = res['host_ip']
port_no = res['port_no']
calib_value = res['calib_value']
temp = res['temp_thresh']
# initialize the video stream and allow the camera sensor to warm up
print("[INFO] starting video stream...")

d6t = grove_d6t.GroveD6t()


def audio_out(mytext):
    language = 'en'
    myobj = gTTS(text=mytext, lang=language, slow=False)
    myobj.save("welcome.mp3")

    # Playing the converted file
    os.system("mpg321 welcome.mp3")


def face_train(Name='nothing'):
    #global data
    try:
        data = face.start(Name)
# Please execute the following command before use "pigpio"
# $ sudo pigpiod

from __future__ import print_function

import time
import datetime

import numpy as np
import matplotlib
matplotlib.use('TkAgg')
from matplotlib import pyplot as plt

import grove_d6t

sensor = grove_d6t.GroveD6t()

def main():
    plt.ion()
    fig = plt.figure()
    x = range(5)
    y = range(5)
    visibleColorBar = False
    print('start')
    
    while True:
            tpn, tptat = sensor.readData()
            if tpn != None and tptat != None:
                print(datetime.datetime.today().strftime("[%Y/%m/%d %H:%M:%S]"),"temperature=%.1f[degC]" %tptat)
                print(tpn[0:4])
                print(tpn[4:8])
Ejemplo n.º 4
0
    db = sql_lib.miyadb(conf.get("setting", "dbfile"), key)

    #dbの中身を削除するときは先に以下の命令を実行
    db.clear()
    db.init_table2()

#####################
#
#   測定関数定義
#
#SH30 temperature
sht = sht30.SHT30()

#omron d6t

d6t = d6t_lib.GroveD6t(conf.get("setting", "D6T_type"))

#omron pressure
psensor = omron_2smpd_lib.Grove2smpd02e()

#####################
#
#    ステートマシンで実装

#状態の定義
states = ['init', 'wait', 'measure1', 'measure2', 'quit']

#遷移の定義
# trigger:遷移の引き金になるイベント、source:トリガーイベントを受ける状態、dest:トリガーイベントを受けた後の状態
# before:遷移前に実施されるコールバック、after:遷移後に実施されるコールバック
transitions = [{