preparing things for mariadb integration --
Changed dateformat for MariaDB in analyze.py
This commit is contained in:
+16
-2
@@ -13,7 +13,7 @@ import librosa
|
||||
import numpy as np
|
||||
import math
|
||||
import time
|
||||
|
||||
from datetime import date, datetime
|
||||
def loadModel():
|
||||
|
||||
global INPUT_LAYER_INDEX
|
||||
@@ -217,9 +217,23 @@ def main():
|
||||
# Write detections to output file
|
||||
min_conf = max(0.01, min(args.min_conf, 0.99))
|
||||
writeResultsToFile(detections, min_conf, args.o)
|
||||
now = datetime.now()
|
||||
|
||||
# Write detections to Database
|
||||
for i in detections:
|
||||
print("\n", detections[i][0],"\n")
|
||||
|
||||
with open('BirdDB.txt', 'a') as rfile:
|
||||
for d in detections:
|
||||
for entry in detections[d]:
|
||||
if entry[1] >= min_conf and (entry[0] in WHITE_LIST or len(WHITE_LIST) == 0):
|
||||
current_date = now.strftime("%Y/%m/%d")
|
||||
current_time = now.strftime("%H:%M:%S")
|
||||
rfile.write(str(current_date) + ';' + str(current_time) + ';' + entry[0].replace('_', ';') + ';' \
|
||||
+ str(entry[1]) +";" + str(args.lat) + ';' + str(args.lon) + ';' + str(min_conf) + ';' + str(week) + ';' \
|
||||
+ str(sensitivity) +';' + str(args.overlap) + '\n')
|
||||
print(str(current_date) + ';' + str(current_time) + ';' + entry[0].replace('_', ';') + ';' + str(entry[1]) +";" + str(args.lat) + ';' + str(args.lon) + ';' + str(min_conf) + ';' + str(week) + ';' + str(sensitivity) +';' + str(args.overlap) + '\n')
|
||||
time.sleep(3)
|
||||
now = datetime.now()
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
|
||||
Executable
+27
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
# test to create a database from bash
|
||||
mysql << 'EOF'
|
||||
CREATE DATABASE IF NOT EXISTS birds;
|
||||
|
||||
USE birds;
|
||||
|
||||
CREATE TABLE IF NOT EXISTS detections (
|
||||
Date DATE,
|
||||
Time TIME,
|
||||
Sci_Name VARCHAR(100) NOT NULL,
|
||||
Com_Name VARCHAR(100) NOT NULL,
|
||||
Confidence FLOAT,
|
||||
Lat FLOAT,
|
||||
Lon FLOAT,
|
||||
Cutoff FLOAT,
|
||||
Week INT,
|
||||
Sens FLOAT,
|
||||
Overlap FLOAT);
|
||||
|
||||
LOAD DATA LOCAL INFILE '/home/pi/Birding-Pi/BirdDB.txt'
|
||||
INTO TABLE detections
|
||||
FIELDS TERMINATED BY ';';
|
||||
SELECT * FROM detections;
|
||||
exit
|
||||
EOF
|
||||
|
||||
Reference in New Issue
Block a user