more testing

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