more testing
This commit is contained in:
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+659
-1546
File diff suppressed because one or more lines are too long
Regular → Executable
+1
@@ -1,3 +1,4 @@
|
||||
#!/home/pi/BirdNET-Pi/birdnet/bin/python3
|
||||
import argparse
|
||||
import socket
|
||||
|
||||
|
||||
+17
-18
@@ -95,9 +95,8 @@ run_analysis() {
|
||||
WEEK="$(echo "${WEEK_OF_YEAR} + 4" |bc -l)"
|
||||
fi
|
||||
|
||||
cd ${HOME}/BirdNET-Pi/scripts || exit 1
|
||||
for i in "${files[@]}";do
|
||||
echo "${1}/${i}" > ../analyzing_now.txt
|
||||
echo "${1}/${i}" > /home/pi/BirdNET-Pi/analyzing_now.txt
|
||||
[ -z ${RECORDING_LENGTH} ] && RECORDING_LENGTH=15
|
||||
[ ${RECORDING_LENGTH} == "60" ] && RECORDING_LENGTH=01:00
|
||||
FILE_LENGTH="$(ffmpeg -i ${1}/${i} 2>&1 | awk -F. '/Duration/ {print $1}' | cut -d':' -f3-4)"
|
||||
@@ -131,7 +130,7 @@ run_analysis() {
|
||||
done
|
||||
fi
|
||||
if [ -f ${1}/${i} ] && [ ! -f ${INCLUDE_LIST} ] && [ ! -f ${EXCLUDE_LIST} ] && [ -z $BIRDWEATHER_ID ];then
|
||||
echo "python3 analyze.py \
|
||||
echo "analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -140,7 +139,7 @@ run_analysis() {
|
||||
--overlap "${OVERLAP}" \
|
||||
--sensitivity "${SENSITIVITY}" \
|
||||
--min_conf "${CONFIDENCE}""
|
||||
"${VENV}"/bin/python analyze.py \
|
||||
analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -150,7 +149,7 @@ run_analysis() {
|
||||
--sensitivity "${SENSITIVITY}" \
|
||||
--min_conf "${CONFIDENCE}"
|
||||
elif [ -f ${1}/${i} ] && [ -f ${INCLUDELIST} ] && [ ! -f ${EXCLUDE_LIST} ] && [ -z $BIRDWEATHER_ID ];then
|
||||
echo "python3 analyze.py \
|
||||
echo "analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -160,7 +159,7 @@ run_analysis() {
|
||||
--sensitivity "${SENSITIVITY}" \
|
||||
--min_conf "${CONFIDENCE}" \
|
||||
--include_list "${INCLUDE_LIST}""
|
||||
"${VENV}"/bin/python analyze.py \
|
||||
analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -171,7 +170,7 @@ run_analysis() {
|
||||
--min_conf "${CONFIDENCE}" \
|
||||
--include_list "${INCLUDE_LIST}"
|
||||
elif [ -f ${1}/${i} ] && [ ! -f ${INCLUDE_LIST} ] && [ -f ${EXCLUDE_LIST} ] && [ -z $BIRDWEATHER_ID ];then
|
||||
echo "python3 analyze.py \
|
||||
echo "analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -181,7 +180,7 @@ run_analysis() {
|
||||
--sensitivity "${SENSITIVITY}" \
|
||||
--min_conf "${CONFIDENCE}" \
|
||||
--exclude_list "${EXCLUDE_LIST}""
|
||||
"${VENV}"/bin/python analyze.py \
|
||||
analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -192,7 +191,7 @@ run_analysis() {
|
||||
--min_conf "${CONFIDENCE}" \
|
||||
--exclude_list "${EXCLUDE_LIST}"
|
||||
elif [ -f ${1}/${i} ] && [ -f ${INCLUDE_LIST} ] && [ -f ${EXCLUDE_LIST} ] && [ -z $BIRDWEATHER_ID ];then
|
||||
echo "python3 analyze.py \
|
||||
echo "analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -203,7 +202,7 @@ run_analysis() {
|
||||
--min_conf "${CONFIDENCE}" \
|
||||
--include_list "${INCLUDE_LIST}" \
|
||||
--exclude_list "${EXCLUDE_LIST}""
|
||||
"${VENV}"/bin/python analyze.py \
|
||||
analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -215,7 +214,7 @@ run_analysis() {
|
||||
--include_list "${INCLUDE_LIST}" \
|
||||
--exclude_list "${EXCLUDE_LIST}"
|
||||
elif [ -f ${1}/${i} ] && [ ! -f ${INCLUDE_LIST} ] && [ ! -f ${EXCLUDE_LIST} ] && [ ! -z $BIRDWEATHER_ID ];then
|
||||
echo "python3 analyze.py \
|
||||
echo "analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -225,7 +224,7 @@ run_analysis() {
|
||||
--sensitivity "${SENSITIVITY}" \
|
||||
--min_conf "${CONFIDENCE}" \
|
||||
--birdweather_id "IN_USE""
|
||||
"${VENV}"/bin/python analyze.py \
|
||||
analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -236,7 +235,7 @@ run_analysis() {
|
||||
--min_conf "${CONFIDENCE}" \
|
||||
--birdweather_id "${BIRDWEATHER_ID}"
|
||||
elif [ -f ${1}/${i} ] && [ -f ${INCLUDE_LIST} ] && [ ! -f ${EXCLUDE_LIST} ] && [ ! -z $BIRDWEATHER_ID ];then
|
||||
echo "python3 analyze.py \
|
||||
echo "analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -247,7 +246,7 @@ run_analysis() {
|
||||
--min_conf "${CONFIDENCE}" \
|
||||
--include_list "${INCLUDE_LIST}" \
|
||||
--birdweather_id "IN_USE""
|
||||
"${VENV}"/bin/python analyze.py \
|
||||
analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -259,7 +258,7 @@ run_analysis() {
|
||||
--include_list "${INCLUDE_LIST}" \
|
||||
--birdweather_id "${BIRDWEATHER_ID}"
|
||||
elif [ -f ${1}/${i} ] && [ ! -f ${INCLUDE_LIST} ] && [ -f ${EXCLUDE_LIST} ] && [ ! -z $BIRDWEATHER_ID ];then
|
||||
echo "python3 analyze.py \
|
||||
echo "analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -270,7 +269,7 @@ run_analysis() {
|
||||
--min_conf "${CONFIDENCE}" \
|
||||
--exclude_list "${EXCLUDE_LIST}" \
|
||||
--birdweather_id "IN_USE""
|
||||
"${VENV}"/bin/python analyze.py \
|
||||
analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -282,7 +281,7 @@ run_analysis() {
|
||||
--exclude_list "${EXCLUDE_LIST}" \
|
||||
--birdweather_id "${BIRDWEATHER_ID}"
|
||||
elif [ -f ${1}/${i} ] && [ -f ${INCLUDE_LIST} ] && [ -f ${EXCLUDE_LIST} ] && [ ! -z $BIRDWEATHER_ID ];then
|
||||
echo "python3 analyze.py \
|
||||
echo "analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
@@ -294,7 +293,7 @@ run_analysis() {
|
||||
--include_list "${INCLUDE_LIST}" \
|
||||
--exclude_list "${EXCLUDE_LIST}" \
|
||||
--birdweather_id "IN_USE""
|
||||
"${VENV}"/bin/python analyze.py \
|
||||
analyze.py \
|
||||
--i "${1}/${i}" \
|
||||
--o "${1}/${i}.csv" \
|
||||
--lat "${LATITUDE}" \
|
||||
|
||||
@@ -22,3 +22,5 @@ CREATE TABLE IF NOT EXISTS detections (
|
||||
Overlap FLOAT,
|
||||
File_Name VARCHAR(100) NOT NULL);
|
||||
EOF
|
||||
sudo chown pi:pi /home/pi/BirdNET-Pi/scripts/birds.db
|
||||
sudo chmod g+w /home/pi/BirdNET-Pi/scripts/birds.db
|
||||
|
||||
@@ -12,28 +12,28 @@ echo "Binary: $binary";
|
||||
revbinary=$(echo $binary|rev)
|
||||
if echo $binary | grep 1 ;then
|
||||
echo "ISSUES DETECTED"
|
||||
if [ ${revbinary:0:1} -eq 1 ];then
|
||||
if [ ${revbinary:0:1} -eq 1 &> /dev/null ];then
|
||||
echo "Under-voltage detected"
|
||||
fi
|
||||
if [ ${revbinary:1:1} -eq 1 ];then
|
||||
if [ ${revbinary:1:1} -eq 1 &> /dev/null ];then
|
||||
echo "Arm frequency capped"
|
||||
fi
|
||||
if [ ${revbinary:2:1} -eq 1 ];then
|
||||
if [ ${revbinary:2:1} -eq 1 &> /dev/null ];then
|
||||
echo "Currently Throttled"
|
||||
fi
|
||||
if [ ${revbinary:3:1} -eq 1 ];then
|
||||
if [ ${revbinary:3:1} -eq 1 &> /dev/null ];then
|
||||
echo "Soft temperatue limit active"
|
||||
fi
|
||||
if [ ${revbinary:16:1} -eq 1 ];then
|
||||
if [ ${revbinary:16:1} -eq 1 &> /dev/null ];then
|
||||
echo "Under-voltage has occurred"
|
||||
fi
|
||||
if [ ${revbinary:17:1} -eq 1 ];then
|
||||
if [ ${revbinary:17:1} -eq 1 &> /dev/null ];then
|
||||
echo "Arm frequency capping has occurred"
|
||||
fi
|
||||
if [ ${revbinary:18:1} -eq 1 ];then
|
||||
if [ ${revbinary:18:1} -eq 1 &> /dev/null ];then
|
||||
echo "Throttling has occurred"
|
||||
fi
|
||||
if [ ${revbinary:19:1} -eq 1 ];then
|
||||
if [ ${revbinary:19:1} -eq 1 &> /dev/null ];then
|
||||
echo "Soft temperature limit has occurred"
|
||||
fi
|
||||
fi
|
||||
|
||||
+1
-23
@@ -10,23 +10,6 @@ $theDate = date('Y-m-d');
|
||||
}
|
||||
$chart = "Combo-$theDate.png";
|
||||
$chart2 = "Combo2-$theDate.png";
|
||||
$mysqli = mysqli_connect();
|
||||
$mysqli->select_db('birds');
|
||||
|
||||
if ($mysqli->connect_error) {
|
||||
die('Connect Error (' .
|
||||
$mysqli->connect_errno . ') '.
|
||||
$mysqli->connect_error);
|
||||
}
|
||||
|
||||
// SQL query to select data from database
|
||||
|
||||
$sql1 = "SELECT COUNT(*)
|
||||
FROM detections
|
||||
WHERE DATE = \"$theDate\"";
|
||||
$dayscount = $mysqli->query($sql1);
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
|
||||
<head>
|
||||
@@ -69,12 +52,7 @@ hr {
|
||||
<table>
|
||||
<tr>
|
||||
<th>Total Detections For The Day</th>
|
||||
<?php
|
||||
while($row=$dayscount->fetch_assoc()){
|
||||
?>
|
||||
<td><?php echo $row['COUNT(*)'];?></td>
|
||||
<?php
|
||||
}?>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ a {
|
||||
<form action="/scripts/filemanager/filemanager.php" target="_top">
|
||||
<button type="submit" class="block">File Manager</button>
|
||||
</form>
|
||||
<form action="/scripts/adminer.php" target="_top">
|
||||
<form action="/scripts/adminer.php?sqlite=&username=&db=birds.db" target="_top">
|
||||
<button type="submit" class="block">Database Maintenance</button>
|
||||
</form>
|
||||
<form action="/scripts/config.php">
|
||||
|
||||
@@ -18,42 +18,30 @@ update_system() {
|
||||
|
||||
set_hostname() {
|
||||
if [ "$(hostname)" == "raspberrypi" ];then
|
||||
echo "Setting hostname to 'birdnetpi'"
|
||||
hostnamectl set-hostname birdnetpi
|
||||
sed -i 's/raspberrypi/birdnetpi/g' /etc/hosts
|
||||
fi
|
||||
}
|
||||
|
||||
install_lynx() {
|
||||
if ! which lynx &> /dev/null;then
|
||||
apt -y install lynx
|
||||
fi
|
||||
}
|
||||
|
||||
install_ftpd() {
|
||||
if ! [ -f /etc/ftpuseres ];then
|
||||
apt -y install ftpd
|
||||
fi
|
||||
}
|
||||
|
||||
install_scripts() {
|
||||
echo "Installing BirdNET-Pi scripts to /usr/local/bin"
|
||||
ln -sf ${my_dir}/* /usr/local/bin/
|
||||
rm /usr/local/bin/index.html
|
||||
}
|
||||
|
||||
install_mariadb() {
|
||||
if ! which sqlite3 &> /dev/null;then
|
||||
echo "Installing SQLite3"
|
||||
apt -qqy install sqlite3 php-sqlite3
|
||||
echo "SQLite Installed"
|
||||
fi
|
||||
echo "Initializing the database"
|
||||
apt -qqy install sqlite3 php-sqlite3
|
||||
${my_dir}/createdb.sh
|
||||
}
|
||||
|
||||
install_birdnet_analysis() {
|
||||
echo "Installing the birdnet_analysis.service"
|
||||
cat << EOF > /etc/systemd/system/birdnet_analysis.service
|
||||
[Unit]
|
||||
Description=BirdNET Analysis
|
||||
@@ -72,7 +60,6 @@ EOF
|
||||
}
|
||||
|
||||
install_birdnet_server() {
|
||||
echo "Installing the birdnet_server.service"
|
||||
cat << EOF > /etc/systemd/system/birdnet_server.service
|
||||
[Unit]
|
||||
Description=BirdNET Analysis Server
|
||||
@@ -90,7 +77,6 @@ EOF
|
||||
}
|
||||
|
||||
install_extraction_service() {
|
||||
echo "Installing the extraction.service and extraction.timer"
|
||||
cat << EOF > /etc/systemd/system/extraction.service
|
||||
[Unit]
|
||||
Description=BirdNET BirdSound Extraction
|
||||
@@ -99,26 +85,14 @@ Restart=on-failure
|
||||
RestartSec=3
|
||||
Type=simple
|
||||
User=${USER}
|
||||
ExecStart=/usr/local/bin/extract_new_birdsounds.sh
|
||||
ExecStart=/usr/bin/env bash -c 'while true;do extract_new_birdsounds.sh;sleep ${RECORDING_LENGTH};done'
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
cat << EOF > /etc/systemd/system/extraction.timer
|
||||
[Unit]
|
||||
Description=BirdNET BirdSound Extraction Timer
|
||||
Requires=extraction.service
|
||||
[Timer]
|
||||
Unit=extraction.service
|
||||
OnCalendar=*:*:0/10
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
systemctl enable extraction.timer
|
||||
systemctl enable extraction.service
|
||||
}
|
||||
|
||||
install_pushed_notifications() {
|
||||
echo "Installing Pushed.co mobile notifications"
|
||||
cat << EOF > /etc/systemd/system/pushed_notifications.service
|
||||
[Unit]
|
||||
Description=BirdNET-Pi Pushed.co Notifications
|
||||
@@ -138,8 +112,6 @@ create_necessary_dirs() {
|
||||
echo "Creating necessary directories"
|
||||
[ -d ${EXTRACTED} ] || sudo -u ${USER} mkdir -p ${EXTRACTED}
|
||||
[ -d ${EXTRACTED}/By_Date ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/By_Date
|
||||
[ -d ${EXTRACTED}/By_Common_Name ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/By_Common_Name
|
||||
[ -d ${EXTRACTED}/By_Scientific_Name ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/By_Scientific_Name
|
||||
[ -d ${EXTRACTED}/Charts ] || sudo -u ${USER} mkdir -p ${EXTRACTED}/Charts
|
||||
[ -d ${PROCESSED} ] || sudo -u ${USER} mkdir -p ${PROCESSED}
|
||||
|
||||
@@ -148,7 +120,6 @@ create_necessary_dirs() {
|
||||
BIRDNETLOG_URL="$(echo ${BIRDNETLOG_URL} | sed 's/\/\//\\\/\\\//g')"
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/${BIRDNETLOG_URL}/g" $(dirname ${my_dir})/homepage/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/${BIRDNETLOG_URL}/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/${BIRDNETLOG_URL}/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/${BIRDNETLOG_URL}/g" $(dirname ${my_dir})/scripts/*.php
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8080/${BIRDNETLOG_URL}/g" $(dirname ${my_dir})/scripts/*/*.php
|
||||
fi
|
||||
@@ -156,10 +127,8 @@ create_necessary_dirs() {
|
||||
WEBTERMINAL_URL="$(echo ${WEBTERMINAL_URL} | sed 's/\/\//\\\/\\\//g')"
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/${WEBTERMINAL_URL}/g" $(dirname ${my_dir})/homepage/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/${WEBTERMINAL_URL}/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/${WEBTERMINAL_URL}/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/${WEBTERMINAL_URL}/g" $(dirname ${my_dir})/scripts/*.php
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local:8888/${WEBTERMINAL_URL}/g" $(dirname ${my_dir})/scripts/*/*.php
|
||||
|
||||
fi
|
||||
|
||||
sudo -u ${USER} ln -fs $(dirname ${my_dir})/model/labels.txt ${my_dir}/
|
||||
@@ -167,14 +136,12 @@ create_necessary_dirs() {
|
||||
if [ -z ${BIRDNETPI_URL} ];then
|
||||
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/homepage/*.html
|
||||
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*.php
|
||||
sudo -u${USER} sed -i "s/birdnetpi.local/$(hostname).local/g" $(dirname ${my_dir})/scripts/*/*.php
|
||||
else
|
||||
BIRDNETPI_URL="$(echo ${BIRDNETPI_URL} | sed 's/\/\//\\\/\\\//g')"
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/homepage/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*.html
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*.php
|
||||
sudo -u${USER} sed -i "s/http:\/\/birdnetpi.local/${BIRDNETPI_URL}/g" $(dirname ${my_dir})/scripts/*/*.php
|
||||
fi
|
||||
|
||||
+8
-51
@@ -5,40 +5,7 @@ error_reporting(E_ALL);
|
||||
header("refresh: 300;");
|
||||
$myDate = date('Y-m-d');
|
||||
$chart = "Combo-$myDate.png";
|
||||
$mysqli = mysqli_connect();
|
||||
$mysqli->select_db('birds');
|
||||
|
||||
if ($mysqli->connect_error) {
|
||||
die('Connect Error (' .
|
||||
$mysqli->connect_errno . ') '.
|
||||
$mysqli->connect_error);
|
||||
}
|
||||
|
||||
// SQL query to select data from database
|
||||
$sql0 = "SELECT COUNT(*) AS 'Total' FROM detections";
|
||||
$totalcount = $mysqli->query($sql0);
|
||||
|
||||
$sql1 = "SELECT Com_Name, Sci_Name, Date, Time FROM detections
|
||||
ORDER BY Date DESC, Time DESC LIMIT 1";
|
||||
$mostrecent = $mysqli->query($sql1);
|
||||
|
||||
$sql2 = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||
WHERE Date = CURDATE()";
|
||||
$todayscount = $mysqli->query($sql2);
|
||||
|
||||
$sql3 = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||
WHERE Date = CURDATE()
|
||||
AND Time >= DATE_SUB(NOW(),INTERVAL 1 HOUR)";
|
||||
$lasthourcount = $mysqli->query($sql3);
|
||||
|
||||
$sql4 = "SELECT Com_Name
|
||||
FROM detections
|
||||
WHERE Date = CURDATE()
|
||||
GROUP BY Com_Name";
|
||||
$specieslist = $mysqli->query($sql4);
|
||||
$speciescount = mysqli_num_rows($specieslist);
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -77,27 +44,17 @@ a {
|
||||
<h2>Overview</h2>
|
||||
<div class="row">
|
||||
<div class="column2">
|
||||
<?php // LOOP TILL END OF DATA
|
||||
while($rows=$mostrecent ->fetch_assoc())
|
||||
{
|
||||
$dbname = preg_replace('/ /', '_', $rows['Com_Name']);
|
||||
$dbname = preg_replace('/\'/', '', $dbname);
|
||||
$dbsciname = preg_replace('/ /', '_', $rows['Sci_Name']);
|
||||
?>
|
||||
<table>
|
||||
<tr>
|
||||
<th>Most Recent Detection</th>
|
||||
<td><a href="/By_Common_Name/<?php echo $dbname;?>"><?php echo $rows['Com_Name'];?></a></td>
|
||||
<td><a href="/By_Date/<?php echo $rows['Date'];?>"/><?php echo $rows['Date'];?></a></td>
|
||||
<td><?php echo $rows['Time'];?></td>
|
||||
<td><a href="https://wikipedia.org/wiki/<?php echo $dbsciname;?>" target="top"/>More Info</a></td>
|
||||
<td><a href="/By_Common_Name/"></a></td>
|
||||
<td><a href="/By_Date/"/></a></td>
|
||||
<td></td>
|
||||
<td><a href="https://wikipedia.org/wiki/" target="top"/>More Info</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
<div class="row">
|
||||
<div class="column">
|
||||
@@ -110,9 +67,9 @@ while($rows=$mostrecent ->fetch_assoc())
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Number of Detections</th>
|
||||
<td><?php while ($row = $totalcount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||
<td><?php while ($row = $todayscount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||
<td><?php while ($row = $lasthourcount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
@@ -120,7 +77,7 @@ while($rows=$mostrecent ->fetch_assoc())
|
||||
<table>
|
||||
<tr>
|
||||
<th>Species Detected Today</th>
|
||||
<td><?php echo $speciescount;?></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
+4
-4
@@ -46,7 +46,7 @@ except:
|
||||
# Open most recent Configuration and grab DB_PWD as a python variable
|
||||
with open('/home/pi/BirdNET-Pi/thisrun.txt', 'r') as f:
|
||||
this_run = f.readlines()
|
||||
db_pwd = str(str(str([i for i in this_run if i.startswith('DB_PWD')]).split('=')[1]).split('\\')[0])
|
||||
audiofmt = "." + str(str(str([i for i in this_run if i.startswith('AUDIOFMT')]).split('=')[1]).split('\\')[0])
|
||||
|
||||
|
||||
def loadModel():
|
||||
@@ -350,16 +350,16 @@ def handle_client(conn, addr):
|
||||
Sens = str(args.sensitivity)
|
||||
Overlap = str(args.overlap)
|
||||
File_Name = Com_Name.replace(" ", "_") + '-' + Confidence + '-' + \
|
||||
Date.replace("/", "-") + '-birdnet-' + Time + '.mp3'
|
||||
Date.replace("/", "-") + '-birdnet-' + Time + audiofmt
|
||||
|
||||
#Connect to SQLite Database
|
||||
con = sqlite3.connect('/home/pi/BirdNET-Pi/scripts/birds2.db')
|
||||
con = sqlite3.connect('/home/pi/BirdNET-Pi/scripts/birds.db')
|
||||
cur = con.cursor()
|
||||
cur.execute("INSERT INTO detections VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", (Date, Time, Sci_Name, Com_Name, str(score), Lat, Lon, Cutoff, Week, Sens, Overlap, File_Name))
|
||||
|
||||
con.commit()
|
||||
con.close()
|
||||
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(args.sensitivity) +';' + str(args.overlap) + Com_Name.replace(" ", "_") + '-' + str(score) + '-' + str(current_date) + '-birdnet-' + str(current_time) + '.mp3' + '\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(args.sensitivity) +';' + str(args.overlap) + Com_Name.replace(" ", "_") + '-' + str(score) + '-' + str(current_date) + '-birdnet-' + str(current_time) + audiofmt + '\n')
|
||||
|
||||
if birdweather_id != "99999":
|
||||
|
||||
|
||||
+9
-79
@@ -3,60 +3,6 @@ ini_set('display_errors', 1);
|
||||
ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
$mysqli = mysqli_connect();
|
||||
$mysqli->select_db('birds');
|
||||
|
||||
if ($mysqli->connect_error) {
|
||||
die('Connect Error (' .
|
||||
$mysqli->connect_errno . ') '.
|
||||
$mysqli->connect_error);
|
||||
}
|
||||
|
||||
// SQL query to select data from database
|
||||
$sql = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||
ORDER BY Date DESC, Time DESC";
|
||||
$totalcount = $mysqli->query($sql);
|
||||
|
||||
$sql1 = "SELECT Com_Name, COUNT(*), MAX(Confidence)
|
||||
FROM detections
|
||||
GROUP BY Com_Name
|
||||
ORDER BY COUNT(*) DESC";
|
||||
$stats = $mysqli->query($sql1);
|
||||
|
||||
$sql2 = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||
WHERE Date = CURDATE()";
|
||||
$todayscount = $mysqli->query($sql2);
|
||||
|
||||
$sql3 = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||
WHERE Date = CURDATE()
|
||||
AND Time >= DATE_SUB(NOW(),INTERVAL 1 HOUR)";
|
||||
$lasthourcount = $mysqli->query($sql3);
|
||||
|
||||
$sql4 = "SELECT Com_Name, Date, Time, MAX(Confidence)
|
||||
FROM detections
|
||||
GROUP BY Com_Name
|
||||
ORDER BY MAX(Confidence) DESC";
|
||||
$specieslist = $mysqli->query($sql4);
|
||||
$speciescount = mysqli_num_rows($specieslist);
|
||||
|
||||
$sql5 = "SELECT Com_Name,COUNT(*)
|
||||
AS 'Total'
|
||||
FROM detections
|
||||
GROUP BY Com_Name
|
||||
ORDER BY Total DESC";
|
||||
$speciestally = $mysqli->query($sql5);
|
||||
|
||||
$getspecies = "SELECT Com_Name from detections
|
||||
GROUP BY Com_Name";
|
||||
$result = $mysqli->query($getspecies);
|
||||
|
||||
if(isset($_POST['species'])){
|
||||
$selection = $_POST['species'];
|
||||
$specificspecies = "SELECT Com_Name, Sci_Name, COUNT(*), MAX(Confidence) from detections
|
||||
WHERE Com_Name = \"$selection\"";
|
||||
$specificstats = $mysqli->query($specificspecies);}
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -179,10 +125,10 @@ form {
|
||||
<th>Number of Unique Species</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php while ($row = $totalcount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||
<td><?php while ($row = $todayscount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||
<td><?php while ($row = $lasthourcount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||
<td><?php echo $speciescount;?></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
<h3>Summary</h3>
|
||||
@@ -192,36 +138,20 @@ form {
|
||||
<th>Occurrences</th>
|
||||
<th>Max Confidence Score</th>
|
||||
</tr>
|
||||
<?php // LOOP TILL END OF DATA
|
||||
while($rows=$stats ->fetch_assoc())
|
||||
{
|
||||
$MAX = sprintf("%.1f%%", $rows['MAX(Confidence)'] * 100);
|
||||
$links = preg_replace('/ /', '_', $rows['Com_Name']);
|
||||
$links = preg_replace('/\'/', '', $links);
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="../By_Common_Name/<?php echo $links;?>"><?php echo $rows['Com_Name'];?></a></td>
|
||||
<td><?php echo $rows['COUNT(*)'];?></td>
|
||||
<td><?php echo $MAX;?></td>
|
||||
<td><a href="../By_Common_Name/"></a></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
<div class="column">
|
||||
<form action="stats.php" method="POST">
|
||||
<h3>Species Stats</h3>
|
||||
<select name="species" >
|
||||
<option value="<?php if(isset($_POST['species'])){echo $selection;}?>"><?php if(isset($_POST['species'])){echo $selection;}else{echo "--Choose Species--";}?></option>
|
||||
<?php
|
||||
while($row = $result->fetch_assoc()) {
|
||||
?>
|
||||
<option value="<?php echo $row['Com_Name'];?>"><?php echo $row['Com_Name'];?></option>"
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<option value=""></option>
|
||||
<option value=""></option>"
|
||||
</select>
|
||||
</p>
|
||||
<button type="submit" class="block"/>Show Species Statistics</button>
|
||||
|
||||
+9
-69
@@ -4,51 +4,6 @@ ini_set('display_startup_errors', 1);
|
||||
error_reporting(E_ALL);
|
||||
|
||||
header("refresh: 30;");
|
||||
$mysqli = mysqli_connect();
|
||||
$mysqli->select_db('birds');
|
||||
|
||||
if ($mysqli->connect_error) {
|
||||
die('Connect Error (' .
|
||||
$mysqli->connect_errno . ') '.
|
||||
$mysqli->connect_error);
|
||||
}
|
||||
|
||||
// SQL query to select data from database
|
||||
$sql = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||
ORDER BY Date DESC, Time DESC";
|
||||
$totalcount = $mysqli->query($sql);
|
||||
|
||||
$sql1 = "SELECT Date, Time, Sci_Name, Com_Name, MAX(Confidence)
|
||||
FROM detections
|
||||
WHERE Date = CURDATE()
|
||||
GROUP BY Date, Time, Sci_Name, Com_Name
|
||||
ORDER BY Time DESC";
|
||||
$mosttable = $mysqli->query($sql1);
|
||||
|
||||
$sql2 = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||
WHERE Date = CURDATE()";
|
||||
$todayscount = $mysqli->query($sql2);
|
||||
|
||||
$sql3 = "SELECT COUNT(*) AS 'Total' FROM detections
|
||||
WHERE Date = CURDATE()
|
||||
AND Time >= DATE_SUB(NOW(),INTERVAL 1 HOUR)";
|
||||
$lasthourcount = $mysqli->query($sql3);
|
||||
|
||||
$sql4 = "SELECT Com_Name, Date, Time, MAX(Confidence)
|
||||
FROM detections
|
||||
GROUP BY Com_Name
|
||||
ORDER BY MAX(Confidence) DESC";
|
||||
$specieslist = $mysqli->query($sql4);
|
||||
$speciescount = mysqli_num_rows($specieslist);
|
||||
|
||||
$sql5 = "SELECT Com_Name,COUNT(*)
|
||||
AS 'Total'
|
||||
FROM detections
|
||||
GROUP BY Com_Name
|
||||
ORDER BY Total DESC";
|
||||
$speciestally = $mysqli->query($sql5);
|
||||
|
||||
$mysqli->close();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
@@ -81,16 +36,15 @@ a {
|
||||
<th>Number of Unique Species</th>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><?php while ($row = $totalcount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||
<td><?php while ($row = $todayscount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||
<td><?php while ($row = $lasthourcount->fetch_assoc()) { echo $row['Total']; };?></td>
|
||||
<td><?php echo $speciescount;?></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
<td></td>
|
||||
</tr>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
<h2>Today's Detections</h2>
|
||||
<!-- TABLE CONSTRUCTION-->
|
||||
<table>
|
||||
<tr>
|
||||
<th>Time</th>
|
||||
@@ -99,25 +53,11 @@ a {
|
||||
<th>Confidence</th>
|
||||
<th>Links</th>
|
||||
</tr>
|
||||
<!-- PHP CODE TO FETCH DATA FROM ROWS-->
|
||||
<?php // LOOP TILL END OF DATA
|
||||
while($rows=$mosttable ->fetch_assoc())
|
||||
{
|
||||
$Confidence = sprintf("%.1f%%", $rows['MAX(Confidence)'] * 100);
|
||||
$dbname = preg_replace('/ /', '_', $rows['Com_Name']);
|
||||
$dbname = preg_replace('/\'/', '', $dbname);
|
||||
$dbsciname = preg_replace('/ /', '_', $rows['Sci_Name']);
|
||||
?>
|
||||
<tr>
|
||||
<!--FETCHING DATA FROM EACH
|
||||
ROW OF EVERY COLUMN-->
|
||||
<td><?php echo $rows['Time'];?></td>
|
||||
<td><a href="/By_Scientific_Name/<?php echo $dbsciname;?>"/><?php echo $rows['Sci_Name'];?></a></td>
|
||||
<td><a href="/By_Common_Name/<?php echo $dbname;?>"/><?php echo $rows['Com_Name'];?></a></td>
|
||||
<td><?php echo $Confidence;?></td>
|
||||
<td><a class="a2" href="https://allaboutbirds.org/guide/<?php echo $dbname;?>" target="top">All About Birds</a>, <a class="a2" href="https://wikipedia.org/wiki/<?php echo $dbsciname;?>" target="top">Wikipedia</a></td>
|
||||
<td></td>
|
||||
<td><a href="/By_Scientific_Name/"/></a></td>
|
||||
<td><a href="/By_Common_Name/"/></a></td>
|
||||
<td></td>
|
||||
<td><a class="a2" href="https://allaboutbirds.org/guide/" target="top">All About Birds</a>, <a class="a2" href="https://wikipedia.org/wiki/" target="top">Wikipedia</a></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
|
||||
Reference in New Issue
Block a user