xiaojinchi_branch
yuanshi 1 year ago
commit 48ac72df69

@ -0,0 +1,116 @@
#include <math.h>
#include <iostream>
#include "levelToSpeed.h"
using namespace std;
#define M_PI acos(-1)
class ForestFirePrediction {
public:
// 构造函数
ForestFirePrediction(int wind_direction, double wind_level, double slope, double altitude, int cover_type, double fire_size, double temperature, double waterlevel) {
this->wind_direction = wind_direction;
this->wind_level = wind_level;
this->slope = slope;
this->altitude = altitude;
this->cover_type = cover_type;
this->fire_size = fire_size;
this->temperature = temperature;
this->waterlevel = waterlevel;
}
// 计算受阻距离单位km
double get_distance() {
double rad_slope = slope * M_PI / 180.0; // 将坡度转化为弧度
double distance = sin(rad_slope) * altitude / 1000.0; // 计算受阻距离
return distance;
}
// 预测火灾蔓延范围
void predict_range() {
double impact_factor; // 植被类型影响系数
double correction_coef; // 风速补正系数
double distance; // 受阻距离
double composite_index; // 综合指数
// 根据植被类型获取影响系数
switch (cover_type) {
case 1: // 针叶林
impact_factor = 0.7;
break;
case 2: // 落叶林
impact_factor = 0.5;
break;
case 3: // 灌木林
impact_factor = 0.4;
break;
default:
cout << "植被类型输入错误!" << endl;
return;
}
// 计算风速补正系数
int angle = abs(wind_direction - 180); // 计算风向与火灾扩散方向之间的夹角
if (angle <= 45 || angle >= 315) { // 如果夹角较小,则不需要进行风速补正
correction_coef = 1;
}
else {
correction_coef = 0.65 + 0.35 * cos((angle - 45) * M_PI / 270.0); // 使用公式计算风速补正系数
}
// 计算受阻距离
distance = get_distance();
// 计算综合指数
composite_index = correction_coef * (1 + distance) * impact_factor;
// 计算火灾蔓延半径
double radius = sqrt(fire_size * 1000000 * composite_index) / M_PI;
double range = radius * pow(10, 1.5 * levelToSpeed(wind_level) / 30.0);
// 输出预测结果
cout << "火灾蔓延范围预测结果:" << endl;
cout << "火源最可能在" << radius << "米范围内发生。" << endl;
cout << "在风速为 " << wind_level << "级风的情况下,火源最可能的蔓延范围为 " << range << " 米。" << endl;
}
// 预测火灾蔓延速度
double predict_speed() {
double slope_factor; // 坡度影响因子
double speed_factor; // 风速影响因子
double size_factor; // 火源面积影响因子
// 计算坡度影响因子
if (slope > 0) {
slope_factor = pow(3.33, sqrt(slope));
}
else {
slope_factor = 1;
}
// 计算风速影响因子
double wind_speed = levelToSpeed(wind_level);
speed_factor = 5.15 * pow(wind_speed, 0.39) + 0.299 * temperature + 0.009 * (100 - waterlevel) - 0.304;
// 计算火源面积影响因子
size_factor = pow(fire_size, 0.77);
// 计算火灾蔓延速度
double speed = 0.348 * sqrt(size_factor * slope_factor * speed_factor);
// 输出预测结果
return speed;
}
private:
int wind_direction; // 风向(单位:度)
double wind_level; // 风力等级
double slope; // 坡度(单位:度)
double altitude; // 海拔高度单位m
int cover_type; // 植被类型1针叶林2落叶林3灌木林
double fire_size; // 火源面积(单位:平方米)
double temperature; // 温度(单位:摄氏度)
double waterlevel; // 湿度(单位:%
};

Binary file not shown.

After

Width:  |  Height:  |  Size: 700 KiB

@ -0,0 +1,179 @@
#include "Prediction.h"
#include <QJsonObject>
#include <QJsonDocument>
#include "FP.h"
#include <QUrlQuery>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QMessageBox>
double Wind_direction, Wind_speed, Humidity, temp;
double fire_size;
Prediction::Prediction(QPixmap image,double start_pos_x, double start_pos_y,double length,double width, double height, QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
double dis = distance_of_pix(height, length, width);
qDebug() << start_pos_x << " " << start_pos_y;
QRect rect1(start_pos_x, start_pos_y,length , width);
QPainter painter(&image);
painter.setCompositionMode(QPainter::CompositionMode_Clear);
painter.setCompositionMode(QPainter::CompositionMode_SourceOver);
painter.fillRect(rect1, QColor(255, 0, 0, 100));
QString styleSheet = QString("background-image:url(:/background_2.png);\
background-repeat:no-repeat;background-position:center;").arg(QCoreApplication::applicationDirPath());
this->setStyleSheet(styleSheet);
this->resize(1080, 640);
getWeatherInfo("beijing");
fire_size = dis * length * dis * width;
connect(ui.east, &QPushButton::clicked, this, [=] {
int type = 0;
int Tree_Type = ui.Tree_Type->text().toInt();
QPixmap pixmap = ui.display->pixmap();
int grow_pix = onclick_wind_button(dis, type, Tree_Type, start_pos_x, start_pos_y, length, width);
qDebug() << grow_pix << "?";
QPainter painter_1(&pixmap);
QRect rect2(start_pos_x + length, start_pos_y, grow_pix, width);
if (painter_1.isActive()) {
painter_1.fillRect(rect2, QColor(0, 0, 255, 100));
ui.display->setPixmap(pixmap);
}
else {
qDebug() << "painter is not initialized";
return;
}
//painter_1.fillRect(rect2, QColor(0, 0, 255, 100));
//ui.display->setPixmap(pixmap);
});
connect(ui.west, &QPushButton::clicked, this, [=] {
int type = 1;
int Tree_Type = ui.Tree_Type->text().toInt();
QPixmap pixmap = ui.display->pixmap();
int grow_pix = onclick_wind_button(dis, type, Tree_Type, start_pos_x, start_pos_y, length, width);
QPainter painter_1(&pixmap);
QRect rect2(start_pos_x - grow_pix, start_pos_y, grow_pix, width);
if (painter_1.isActive()) {
painter_1.fillRect(rect2, QColor(0, 0, 255, 100));
ui.display->setPixmap(pixmap);
}
else {
qDebug() << "painter is not initialized";
return;
}
//painter_1.fillRect(rect2, QColor(0, 0, 255, 100));
//ui.display->setPixmap(pixmap);
});
connect(ui.north, &QPushButton::clicked, this, [=] {
int type = 2;
int Tree_Type = ui.Tree_Type->text().toInt();
QPixmap pixmap = ui.display->pixmap();
int grow_pix = onclick_wind_button(dis, type, Tree_Type, start_pos_x, start_pos_y, length, width);
QPainter painter_1(&pixmap);
QRect rect2(start_pos_x, start_pos_y - grow_pix, length, grow_pix);
if (painter_1.isActive()) {
painter_1.fillRect(rect2, QColor(0, 0, 255, 100));
ui.display->setPixmap(pixmap);
}
else {
qDebug() << "painter is not initialized";
return;
}
//painter_1.fillRect(rect2, QColor(0, 0, 255, 100));
//ui.display->setPixmap(pixmap);
});
connect(ui.south, &QPushButton::clicked, this, [=] {
int type = 3;
int Tree_Type = ui.Tree_Type->text().toInt();
QPixmap pixmap = ui.display->pixmap();
int grow_pix = onclick_wind_button(dis, type, Tree_Type, start_pos_x, start_pos_y, length, width);
QPainter painter_1(&pixmap);
QRect rect2(start_pos_x, start_pos_y + width, length, grow_pix);
if (painter_1.isActive()) {
painter_1.fillRect(rect2, QColor(0, 0, 255, 100));
ui.display->setPixmap(pixmap);
}
else {
qDebug() << "painter is not initialized";
return;
}
//painter_1.fillRect(rect2, QColor(0, 0, 255, 100));
//ui.display->setPixmap(pixmap);
});
ui.display->setPixmap(image);
}
Prediction::~Prediction()
{
}
double Prediction::distance_of_pix(int height,int length, int width) {
// 假设无人机高度为 H图像中一片区域的像素长度为 L
double f = 50.0; // 摄像头的焦距,单位为毫米
double w = 60.0; // 摄像头的水平视野,单位为度
double A = (2.0 * atan(w / (2.0 * f))) * M_PI / 180.0; // 视角,单位为弧度
double r = height / tan(A); // 实际距离与图像距离的比值
double D = (length * r) / f; // 计算实际长度,单位为米
double res = D / length;
// 输出计算结果
return res;
}
int Prediction::onclick_wind_button(double dis, int type, int Tree_Type, int start_pos_x, int start_pos_y, int length, int wid) {
//0 for east 1 for west 2 for north 3 for south
double wind_level = std::pow(Wind_speed / 0.836, 0.16);
if (type == 0) {
ForestFirePrediction ffp((int)Wind_direction, wind_level, 12, 200, Tree_Type, fire_size, temp, Humidity);
int speed = ffp.predict_speed();
int grow_pix = (speed / 12) / dis;
return grow_pix;
if (type == 1) {
ForestFirePrediction ffp((int)Wind_direction, wind_level, 12, 200, Tree_Type, fire_size, temp, Humidity);
int speed = ffp.predict_speed();
int grow_pix = (speed / 12) / dis;
return grow_pix;
}
if (type == 2) {
ForestFirePrediction ffp((int)Wind_direction, wind_level, 12, 200, Tree_Type, fire_size, temp, Humidity);
int speed = ffp.predict_speed();
int grow_pix = (speed / 12) / dis;
return grow_pix;
qDebug() << speed << " " << grow_pix << "Grow";
}
if (type == 3) {
ForestFirePrediction ffp((int)Wind_direction, wind_level, 12, 200, Tree_Type, fire_size, temp, Humidity);
int speed = ffp.predict_speed();
int grow_pix = (speed / 12) / dis;
return grow_pix;
}
}
}
void Prediction::getWeatherInfo(QString city)
{
// 对城市名称进行 URL 编码
QString encodedCity = QUrl::toPercentEncoding(city);
// 构造 API URL 地址
QString url = "http://api.openweathermap.org/data/2.5/weather?q=" + encodedCity + "&appid=8a4595940d39d20fbb6f4f94ba813c65";
// 创建网络访问管理器对象
QNetworkAccessManager* nam = new QNetworkAccessManager();
// 发送 GET 请求
QNetworkReply* reply = nam->get(QNetworkRequest(QUrl(url)));
// 等待请求完成
while (!reply->isFinished()) {
qApp->processEvents();
}
// 读取返回的 JSON 数据
QByteArray jsonData = reply->readAll();
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonData);
QJsonObject jsonObject = jsonDocument.object();
Wind_direction = jsonObject["wind"].toObject()["deg"].toDouble();
Wind_speed = jsonObject["wind"].toObject()["speed"].toDouble();
Humidity = jsonObject["main"].toObject()["humidity"].toDouble();
temp = jsonObject.value("main").toObject().value("temp").toDouble();
qDebug() << Wind_direction << Wind_speed << Humidity;
}

@ -0,0 +1,24 @@
#pragma once
#include <QMainWindow>
#include "ui_Prediction.h"
#include <QPixmap>
#include <QPainter>
#include <QTcpServer>
#include <QTcpSocket>
class Prediction : public QMainWindow
{
Q_OBJECT
public:
Prediction(QPixmap image, double start_pos_x, double start_pos_y, double length, double width, double height, QWidget *parent = nullptr);
~Prediction();
//QPainter *painter;
private:
Ui::PredictionClass ui;
double distance_of_pix(int height,int length,int width);
int onclick_wind_button(double dis,int type,int Tree_Type,int start_pos_x,int start_pos_y,int length,int wid);
void getWeatherInfo(QString city);
};

@ -0,0 +1,159 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>PredictionClass</class>
<widget class="QMainWindow" name="PredictionClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1130</width>
<height>644</height>
</rect>
</property>
<property name="windowTitle">
<string>Prediction</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>120</x>
<y>50</y>
<width>642</width>
<height>509</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="display">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QLabel" name="Pre_tag">
<property name="geometry">
<rect>
<x>130</x>
<y>30</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>火势状况</string>
</property>
</widget>
<widget class="QPushButton" name="north">
<property name="geometry">
<rect>
<x>830</x>
<y>60</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>北风</string>
</property>
</widget>
<widget class="QPushButton" name="south">
<property name="geometry">
<rect>
<x>830</x>
<y>110</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>南风</string>
</property>
</widget>
<widget class="QPushButton" name="east">
<property name="geometry">
<rect>
<x>830</x>
<y>160</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>东风</string>
</property>
</widget>
<widget class="QPushButton" name="west">
<property name="geometry">
<rect>
<x>830</x>
<y>210</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>西风</string>
</property>
</widget>
<widget class="QLineEdit" name="Tree_Type">
<property name="geometry">
<rect>
<x>830</x>
<y>260</y>
<width>91</width>
<height>31</height>
</rect>
</property>
<property name="placeholderText">
<string>1针叶林2落叶林3灌木林</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1130</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

@ -0,0 +1,56 @@
#include "Setting.h"
#include <QTcpServer>
#include <QTcpSocket>
#include <QMessageBox>
#include <QJsonObject>
#include <QJsonDocument>
Setting::Setting(QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
/*float longitude = ui.longitude->text().toFloat();
float latitude = ui.latitude->text().toFloat();
int hours = ui.hours->text().toInt();
int minutes = ui.minutes->text().toInt();
int seconds = ui.seconds->text().toInt();*/
tcpsocket = new QTcpSocket(this);
tcpsocket->connectToHost("192.168.8.100", 9090);
connect(ui.finished, &QPushButton::clicked, this, &Setting::on_finished_button);
QString styleSheet = QString("background-image:url(:/background_1.png);\
background-repeat:no-repeat;background-position:center;").arg(QCoreApplication::applicationDirPath());
this->setStyleSheet(styleSheet);
this->resize(806, 453);
ui.finished->setStyleSheet("background-color: white;");
}
Setting::~Setting()
{
}
void Setting::on_finished_button() {
float longitude = ui.longitude->text().toFloat();
float latitude = ui.latitude->text().toFloat();
int hours = ui.hours->text().toInt();
int minutes = ui.minutes->text().toInt();
int seconds = ui.seconds->text().toInt();
int x = ui.x->text().toInt();
int y = ui.y->text().toInt();
int z = ui.z->text().toInt();
QJsonObject msg;
msg.insert("type", "Set");
msg.insert("lon", longitude);
msg.insert("lat", latitude);
msg.insert("hours", hours);
msg.insert("minutes", minutes);
msg.insert("seconds", seconds);
msg.insert("x", x);
msg.insert("y", y);
msg.insert("z", z);
QJsonDocument jsonDocument;
jsonDocument.setObject(msg);
QByteArray dataArray = jsonDocument.toJson();
if (tcpsocket->write(dataArray) == -1) {
qDebug() << "send TCP data package failed!";
}
qDebug() << "sent!";
}

@ -0,0 +1,203 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>SettingClass</class>
<widget class="QMainWindow" name="SettingClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>871</width>
<height>571</height>
</rect>
</property>
<property name="windowTitle">
<string>Setting</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QWidget" name="gridLayoutWidget">
<property name="geometry">
<rect>
<x>200</x>
<y>100</y>
<width>451</width>
<height>241</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="2" column="0">
<widget class="QLabel" name="Start_Timer">
<property name="text">
<string>出发时间:</string>
</property>
</widget>
</item>
<item row="2" column="3">
<widget class="QLineEdit" name="seconds">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="placeholderText">
<string>秒</string>
</property>
</widget>
</item>
<item row="2" column="1">
<widget class="QLineEdit" name="hours">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="placeholderText">
<string>时</string>
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLineEdit" name="longitude">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="placeholderText">
<string>经度</string>
</property>
</widget>
</item>
<item row="2" column="2">
<widget class="QLineEdit" name="minutes">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="placeholderText">
<string>分</string>
</property>
</widget>
</item>
<item row="0" column="2">
<widget class="QLineEdit" name="latitude">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="placeholderText">
<string>纬度</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QLabel" name="Speed_Lable">
<property name="maximumSize">
<size>
<width>80</width>
<height>16777215</height>
</size>
</property>
<property name="text">
<string>目的地</string>
</property>
</widget>
</item>
<item row="1" column="0">
<widget class="QLabel" name="label">
<property name="maximumSize">
<size>
<width>16777215</width>
<height>20</height>
</size>
</property>
<property name="text">
<string>x,y,z</string>
</property>
</widget>
</item>
<item row="1" column="1">
<widget class="QLineEdit" name="x">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="placeholderText">
<string>0</string>
</property>
</widget>
</item>
<item row="1" column="2">
<widget class="QLineEdit" name="y">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="placeholderText">
<string>0</string>
</property>
</widget>
</item>
<item row="1" column="3">
<widget class="QLineEdit" name="z">
<property name="maximumSize">
<size>
<width>150</width>
<height>16777215</height>
</size>
</property>
<property name="placeholderText">
<string>0</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="finished">
<property name="geometry">
<rect>
<x>360</x>
<y>370</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>完成</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>871</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>

Binary file not shown.

After

Width:  |  Height:  |  Size: 961 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

@ -0,0 +1,104 @@
#include "UAV_UI_new.h"
#include "Setting.h"
#include "tips.h"
#include <opencv2/opencv.hpp>
#include <string.h>
#include <qlabel.h>
#include <qdebug.h>
#include <QTcpServer>
#include <QTcpSocket>
#include <QMessageBox>
#include <QJsonObject>
#include <QJsonDocument>
using namespace cv;
using namespace std;
VideoCapture cap;
Prediction* Predict_UI;
int length, wid, start_pos_x, start_pos_y, heig,slope,elevation;
const string VideoCaptureAdress = "http://admin:admin@192.168.8.126:8081";
//const string VideoCaptureAdress = "rtsp://192.168.144.108:8000/375897"; //热成像
//const string VideoCaptureAdress = "rtsp://192.168.144.108:8000/165506"; //nomal
//const string VideoCaptureAdress = "C:\\Users\\87334\\Videos\\Captures\\Fast_sent.mp4";
UAV_UI_new::UAV_UI_new(QWidget* parent)
: QMainWindow(parent)
{
ui.setupUi(this);
timer = new QTimer(this);
ui.display->setStyleSheet("border:1px solid black ");
ui.play_tag->setStyleSheet("background-color:white");
connect(ui.Settings, &QPushButton::clicked, this, &UAV_UI_new::onclick_Setting_button);
connect(ui.connection, &QPushButton::clicked, this, &UAV_UI_new::on_connection_button);
connect(ui.stop, &QPushButton::clicked, this, &UAV_UI_new::on_stop_button);
connect(ui.Prediction, &QPushButton::clicked, this, &UAV_UI_new::on_predict_button);
connect(timer, SIGNAL(timeout()), this, SLOT(importImage()));
tcpsocket = new QTcpSocket(this);
tcpsocket->connectToHost("192.168.8.100", 9090);
connect(tcpsocket, &QTcpSocket::connected, [=]() {
QMessageBox *tip = new QMessageBox(this);
//QLabel *tip = new QLabel(this);
tip->setText("连接成功");
tip->setInformativeText("connected successfully");
tip->setStandardButtons(QMessageBox::Ok);
tip->show();
});
connect(tcpsocket, &QTcpSocket::readyRead, [=]() {
QByteArray jsonData = tcpsocket->readAll(); // 接收 JSON 数据
QJsonDocument jsonDocument = QJsonDocument::fromJson(jsonData);
QJsonObject jsonObject = jsonDocument.object();
QString type = jsonObject.value("type").toString();
if (type == "Alarming") {
QPixmap image_Pre(":/Fire.png");
tips* tip = new tips(image_Pre);
tip->show();
ui.Prediction->setStyleSheet("color:red");
length = jsonObject.value("length").toDouble();
wid = jsonObject.value("width").toDouble();
qDebug() << jsonObject.value("center_x").toDouble() << jsonObject.value("length").toDouble() / 2;
start_pos_x = jsonObject.value("center_x").toDouble() - jsonObject.value("length").toDouble() / 2;
start_pos_y = jsonObject.value("center_y").toDouble() - jsonObject.value("width").toDouble() / 2;
qDebug() << start_pos_x << " " << start_pos_y << "mAIN";
slope = jsonObject.value("slope").toDouble();
elevation = jsonObject.value("slope").toDouble();
}
if (type == "Set") {
heig = jsonObject.value("z").toInt();
}
});
QString styleSheet = QString("background-image:url(:/background_3.png);\
background-repeat:no-repeat;background-position:center;").arg(QCoreApplication::applicationDirPath());
this->setStyleSheet(styleSheet);
this->resize(1440, 720);
}
UAV_UI_new::~UAV_UI_new()
{}
void UAV_UI_new::on_connection_button() {
cap.open(VideoCaptureAdress);
timer->start(100);
};
void UAV_UI_new::onclick_Setting_button() {
Settings_UI.show();
}
void UAV_UI_new::importImage() {
Mat image;
cap >> image;
cvtColor(image, image, COLOR_BGR2RGB);
cv::resize(image, image, Size(640, 480));
QPixmap showimage = QPixmap::fromImage(QImage((const uchar*)(image.data),
image.cols,
image.rows,
image.step,
QImage::Format_RGB888));
ui.display->setPixmap(showimage);
image_Pre = showimage;
}
void UAV_UI_new::on_stop_button() {
timer->stop();
cap.release();
ui.display->clear();
}
void UAV_UI_new::on_predict_button() {
QPixmap image_Pre(":/Fire.png");
Predict_UI = new Prediction(image_Pre, start_pos_x,start_pos_y,length,wid,100);
Predict_UI->show();
}

@ -0,0 +1,37 @@
#pragma once
#include <QtWidgets/QMainWindow>
#include "ui_UAV_UI_new.h"
#include "Setting.h"
#include "Prediction.h"
#include <QTimer>
#include <qpushbutton.h>
#include <QPushbutton>
#include <opencv2/opencv.hpp>
#include <QTcpServer>
#include <QTcpSocket>
class UAV_UI_new : public QMainWindow
{
Q_OBJECT
public:
UAV_UI_new(QWidget *parent = nullptr);
~UAV_UI_new();
private:
Ui::UAV_UI_newClass ui;
QTimer* timer;
double rate;
QTcpServer* tcpserver;
QTcpSocket* tcpsocket;
Setting Settings_UI;
QPixmap image_Pre;
private slots:
void on_connection_button();
void on_stop_button();
void importImage();
void onclick_Setting_button();
void on_predict_button();
};

@ -0,0 +1,9 @@
<RCC>
<qresource prefix="/">
<file>background_1.png</file>
<file>background_2.png</file>
<file>background_3.png</file>
<file>Fire.png</file>
<file>kill_fire.jpg</file>
</qresource>
</RCC>

@ -0,0 +1,173 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>UAV_UI_newClass</class>
<widget class="QMainWindow" name="UAV_UI_newClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1440</width>
<height>1000</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>0</width>
<height>0</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1440</width>
<height>1200</height>
</size>
</property>
<property name="windowTitle">
<string>UAV_UI_new</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
<rect>
<x>90</x>
<y>60</y>
<width>642</width>
<height>509</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QLabel" name="display">
<property name="enabled">
<bool>true</bool>
</property>
<property name="minimumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QPushButton" name="stop">
<property name="geometry">
<rect>
<x>820</x>
<y>140</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>关闭图像</string>
</property>
</widget>
<widget class="QPushButton" name="connection">
<property name="geometry">
<rect>
<x>820</x>
<y>70</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>连接图像</string>
</property>
</widget>
<widget class="QLabel" name="play_tag">
<property name="geometry">
<rect>
<x>100</x>
<y>40</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>实时图像</string>
</property>
</widget>
<widget class="QPushButton" name="Settings">
<property name="geometry">
<rect>
<x>1350</x>
<y>0</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>设置</string>
</property>
</widget>
<widget class="QPushButton" name="action">
<property name="geometry">
<rect>
<x>820</x>
<y>200</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>出警</string>
</property>
</widget>
<widget class="QPushButton" name="Prediction">
<property name="geometry">
<rect>
<x>820</x>
<y>260</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>预测</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1440</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources>
<include location="UAV_UI_new.qrc"/>
</resources>
<connections/>
</ui>

@ -0,0 +1,130 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="17.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{FB496CF3-A3CE-4A50-BAC4-A9F43A71A5F9}</ProjectGuid>
<Keyword>QtVS_v304</Keyword>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">10.0.22000.0</WindowsTargetPlatformVersion>
<WindowsTargetPlatformVersion Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">10.0.22000.0</WindowsTargetPlatformVersion>
<QtMsBuild Condition="'$(QtMsBuild)'=='' OR !Exists('$(QtMsBuild)\qt.targets')">$(MSBuildProjectDirectory)\QtMsBuild</QtMsBuild>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<PlatformToolset>v143</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt_defaults.props')">
<Import Project="$(QtMsBuild)\qt_defaults.props" />
</ImportGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="QtSettings">
<QtInstall>6.2.4</QtInstall>
<QtModules>core;gui;network;widgets</QtModules>
<QtBuildConfig>debug</QtBuildConfig>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="QtSettings">
<QtInstall>6.2.4</QtInstall>
<QtModules>core;gui;widgets</QtModules>
<QtBuildConfig>release</QtBuildConfig>
</PropertyGroup>
<Target Name="QtMsBuildNotFound" BeforeTargets="CustomBuild;ClCompile" Condition="!Exists('$(QtMsBuild)\qt.targets') or !Exists('$(QtMsBuild)\qt.props')">
<Message Importance="High" Text="QtMsBuild: could not locate qt.targets, qt.props; project may not build correctly." />
</Target>
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="Shared" />
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(QtMsBuild)\Qt.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="$(QtMsBuild)\Qt.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
<IncludePath>D:\OpenCV\opencv\build\include\opencv2;D:\OpenCV\opencv\build\include;$(IncludePath)</IncludePath>
<LibraryPath>D:\OpenCV\opencv\build\x64\vc15\lib;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Link>
<AdditionalLibraryDirectories>D:\OpenCV\opencv\build\x64\vc15\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>opencv_world455d.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'" Label="Configuration">
<ClCompile>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'" Label="Configuration">
<ClCompile>
<TreatWChar_tAsBuiltInType>true</TreatWChar_tAsBuiltInType>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<DebugInformationFormat>None</DebugInformationFormat>
<Optimization>MaxSpeed</Optimization>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>false</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<QtRcc Include="UAV_UI_new.qrc" />
<QtUic Include="Prediction.ui" />
<QtUic Include="Setting.ui" />
<QtUic Include="tips.ui" />
<QtUic Include="UAV_UI_new.ui" />
<QtMoc Include="UAV_UI_new.h" />
<ClCompile Include="Prediction.cpp" />
<ClCompile Include="Setting.cpp" />
<ClCompile Include="tips.cpp" />
<ClCompile Include="UAV_UI_new.cpp" />
<ClCompile Include="main.cpp" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="tips.h" />
</ItemGroup>
<ItemGroup>
<QtMoc Include="Prediction.h" />
<ClInclude Include="FP.h" />
<ClInclude Include="levelToSpeed.h" />
<ClInclude Include="resource1.h" />
<QtMoc Include="Setting.h" />
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="UAV_UI_new1.rc" />
</ItemGroup>
<ItemGroup>
<Image Include="background.jpg" />
<Image Include="Settings.jpg" />
<Image Include="Settings_2.jpg" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Condition="Exists('$(QtMsBuild)\qt.targets')">
<Import Project="$(QtMsBuild)\qt.targets" />
</ImportGroup>
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>qml;cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>qrc;rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="Form Files">
<UniqueIdentifier>{99349809-55BA-4b9d-BF79-8FDBB0286EB3}</UniqueIdentifier>
<Extensions>ui</Extensions>
</Filter>
<Filter Include="Translation Files">
<UniqueIdentifier>{639EADAA-A684-42e4-A9AD-28FC9BCB8F7C}</UniqueIdentifier>
<Extensions>ts</Extensions>
</Filter>
</ItemGroup>
<ItemGroup>
<QtRcc Include="UAV_UI_new.qrc">
<Filter>Resource Files</Filter>
</QtRcc>
<QtUic Include="UAV_UI_new.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtMoc Include="UAV_UI_new.h">
<Filter>Header Files</Filter>
</QtMoc>
<ClCompile Include="UAV_UI_new.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClCompile Include="main.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="tips.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Setting.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="Prediction.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<QtMoc Include="tips.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="Setting.h">
<Filter>Header Files</Filter>
</QtMoc>
<QtMoc Include="Prediction.h">
<Filter>Header Files</Filter>
</QtMoc>
</ItemGroup>
<ItemGroup>
<QtUic Include="tips.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="Setting.ui">
<Filter>Form Files</Filter>
</QtUic>
<QtUic Include="Prediction.ui">
<Filter>Form Files</Filter>
</QtUic>
</ItemGroup>
<ItemGroup>
<ClInclude Include="resource1.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="levelToSpeed.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="FP.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="UAV_UI_new1.rc">
<Filter>Resource Files</Filter>
</ResourceCompile>
</ItemGroup>
<ItemGroup>
<Image Include="background.jpg">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Settings.jpg">
<Filter>Resource Files</Filter>
</Image>
<Image Include="Settings_2.jpg">
<Filter>Resource Files</Filter>
</Image>
</ItemGroup>
</Project>

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<QtLastBackgroundBuild>2023-06-14T08:40:27.1306328Z</QtLastBackgroundBuild>
</PropertyGroup>
<PropertyGroup Label="QtSettings" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<QtLastBackgroundBuild>2023-06-14T08:40:27.2066207Z</QtLastBackgroundBuild>
</PropertyGroup>
</Project>

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 134 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 232 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 661 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 KiB

@ -0,0 +1,62 @@
#include<iostream>
using namespace std;
double levelToSpeed(int level) {
double speed = 0;
if (level >= 0 && level <= 12) {
double speed = 0;
switch (level) {
case 1:
speed = 0.3;
break;
case 2:
speed = 1.6;
break;
case 3:
speed = 3.4;
break;
case 4:
speed = 5.5;
break;
case 5:
speed = 8.0;
break;
case 6:
speed = 10.8;
break;
case 7:
speed = 13.9;
break;
case 8:
speed = 17.2;
break;
case 9:
speed = 20.8;
break;
case 10:
speed = 24.5;
break;
case 11:
speed = 28.5;
break;
case 12:
speed = 32.7;
break;
}
}
else if (level == 13) {
speed = 35.8;
}
else if (level == 14) {
speed = 41.5;
}
else if (level == 15) {
speed = 48.2;
}
else {
cout << "无效的风力等级!" << endl;
}
return speed;
}

@ -0,0 +1,14 @@
#include "UAV_UI_new.h"
#include <QtWidgets/QApplication>
#include <opencv2/opencv.hpp>
#include <string.h>
using namespace std;
using namespace cv;
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
UAV_UI_new w;
w.show();
return a.exec();
}

@ -0,0 +1,20 @@
#include "tips.h"
tips::tips(QPixmap image,QWidget *parent)
: QMainWindow(parent)
{
ui.setupUi(this);
ui.display->setPixmap(image);
connect(ui.action, &QPushButton::clicked, this, &tips::on_action_button);
ui.action->setStyleSheet("background-color:red;");
QString styleSheet = QString("background-image:url(:/kill_fire.jpg);\
background-repeat:no-repeat;background-position:center;").arg(QCoreApplication::applicationDirPath());
this->setStyleSheet(styleSheet);
}
tips::~tips()
{
}
void tips::on_action_button() {
//·Å¾¯±¨
}

@ -0,0 +1,17 @@
#pragma once
#include <QMainWindow>
#include "ui_tips.h"
class tips : public QMainWindow
{
Q_OBJECT
public:
tips(QPixmap image, QWidget *parent = nullptr);
~tips();
private:
Ui::tipsClass ui;
void on_action_button();
};

@ -0,0 +1,107 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>tipsClass</class>
<widget class="QMainWindow" name="tipsClass">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1130</width>
<height>644</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>1130</width>
<height>644</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>1130</width>
<height>644</height>
</size>
</property>
<property name="windowTitle">
<string>tips</string>
</property>
<widget class="QWidget" name="centralWidget">
<widget class="QLabel" name="Pre_tag">
<property name="geometry">
<rect>
<x>19</x>
<y>6</y>
<width>81</width>
<height>31</height>
</rect>
</property>
<property name="text">
<string>火势状况</string>
</property>
</widget>
<widget class="QLabel" name="display">
<property name="enabled">
<bool>true</bool>
</property>
<property name="geometry">
<rect>
<x>20</x>
<y>30</y>
<width>640</width>
<height>480</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>640</width>
<height>480</height>
</size>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QPushButton" name="action">
<property name="geometry">
<rect>
<x>830</x>
<y>40</y>
<width>93</width>
<height>29</height>
</rect>
</property>
<property name="text">
<string>出警</string>
</property>
</widget>
</widget>
<widget class="QMenuBar" name="menuBar">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>1130</width>
<height>26</height>
</rect>
</property>
</widget>
<widget class="QToolBar" name="mainToolBar">
<attribute name="toolBarArea">
<enum>TopToolBarArea</enum>
</attribute>
<attribute name="toolBarBreak">
<bool>false</bool>
</attribute>
</widget>
<widget class="QStatusBar" name="statusBar"/>
</widget>
<layoutdefault spacing="6" margin="11"/>
<resources/>
<connections/>
</ui>
Loading…
Cancel
Save