Ejemplo n.º 1
0
def paddle_count():
    patient_id = request.json['patient_id']
    device_id = request.json['device_id']
    connection = get_connection()
    date_time = datetime.datetime.now()
    data = {
        'patient_id': patient_id,
        'device_id': device_id,
        'medium_count': 1,
        'time': date_time
    }
    table_name = 'pedal'
    create_data(table_name, data, connection)
    close_connection(connection)
    return str(1)
def handle_request():
    section_id = request.args.get('section_id')
    seq = request.args.get('seq')
    device_id = request.args.get('device_id')
    imagefile = request.files['image']
    filename = werkzeug.utils.secure_filename(imagefile.filename)
    imagefile.save(filename)
    with open(filename, 'rb') as f:
        data = f.read()
    _url = 'https://westus2.api.cognitive.microsoft.com/face/v1.0/detect'
    _key = 'bc027dc227484433a77d7b613807d230'  #Here you have to paste your primary key
    headers = dict()
    headers['Ocp-Apim-Subscription-Key'] = _key
    headers['Content-Type'] = 'application/octet-stream'

    json = None
    params = {
        'returnFaceId':
        'true',
        'returnFaceLandmarks':
        'false',
        'returnFaceAttributes':
        'age,gender,headPose,smile,facialHair,glasses,emotion,hair,makeup,occlusion,accessories,blur,exposure,noise',
    }

    result = processRequest(json, data, headers, params, _url)

    if result == []:
        return 'no face'
    elif result is None:
        return 'no picture'
    firstface_dic = result[0]
    #print(result[0])
    faceAttributes_dic = firstface_dic['faceAttributes']
    #print(faceAttributes_dic)
    #interval = math.ceil(sec/10)
    smile = faceAttributes_dic['smile']
    gender = faceAttributes_dic['gender']
    #age = faceAttributes_dic['age']
    anger = faceAttributes_dic['emotion']['anger']
    contempt = faceAttributes_dic['emotion']['contempt']
    disgust = faceAttributes_dic['emotion']['disgust']
    fear = faceAttributes_dic['emotion']['fear']
    happiness = faceAttributes_dic['emotion']['happiness']
    neutral = faceAttributes_dic['emotion']['neutral']
    sadness = faceAttributes_dic['emotion']['sadness']
    surprise = faceAttributes_dic['emotion']['surprise']
    connection = get_connection()
    date_time = datetime.datetime.now()
    data = {
        'date': date,
        'session_id': section_id,
        'seq': section_id,
        'device_id': device_id,
        'face_smile': smile,
        'face_anger': anger,
        'face_contempt': contempt,
        'face_disgust': disgust,
        'face_fear': fear,
        'face_happiness': happiness,
        'face_neutral': neutral,
        'face_sadness': sadness,
        'face_surprise': surprise
    }
    #data = {'face_smile_prob':smile}
    table_name = 'test'
    create_data(table_name, data, connection)
    close_connection(connection)
Ejemplo n.º 3
0
if __name__ == '__main__':

    file_name = 'CSV/intergrated_accurate.wav.csv'

    csvFile = open(file_name, "r")
    reader = csv.reader(csvFile)

    connection = get_connection()
    table_name = 'speech_sentiment'

    for row in reader:
        # print(row)
        sentence = ' '
        if len(row) == 8:
            sentence = row[7]

        datum = {
            'time': int(row[0]),
            'video_id': row[1],
            'score_val': float(row[2]),
            'score_max': float(row[3]),
            'score_min': float(row[4]),
            'score_avg': float(row[5]),
            'score_std': float(row[6]),
            'sentence': sentence,
        }
        print(datum)

        create_data(table_name, datum, connection)
Ejemplo n.º 4
0
# driver= '{ODBC Driver 17 for SQL Server}'
#cnxn = pyodbc.connect('DRIVER='+driver+';SERVER='+server+';PORT=1433;DATABASE='+database+';UID='+username+';PWD='+ password)
#cursor = cnxn.cursor()
cnxn = get_connection()

device_id = '001'
patient_id = '001'
id_ = '002'
table_name = 'lung_transaction'
date = datetime.datetime.now()
print("insert columns...")
for i in range(10):
    data = {
        'ID': id_,
        'DATE': date,
        'VALUE': str(i),
        'DEVICE_ID': device_id,
        'PATIENT_ID': patient_id,
        'TYPE': 'pedal'
    }
    create_data(table_name, data, cnxn)

print("fetch data...")
cursor = cnxn.cursor()
cursor.execute("SELECT * FROM lung_transaction WHERE ID='002'")
row = cursor.fetchone()
while row:
    #print (str(row[0]) + " " + str(row[1]))
    print(row)
    row = cursor.fetchone()