parent
							
								
									9aeddde25c
								
							
						
					
					
						commit
						5c56d971cf
					
				@ -1,30 +0,0 @@
 | 
				
			|||||||
#include <iostream>
 | 
					 | 
				
			||||||
using namespace std;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
double Ks_cor(int cover_type)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
    double impact_factor = 0;
 | 
					 | 
				
			||||||
    // 根据植被类型获取影响系数
 | 
					 | 
				
			||||||
    switch (cover_type) {
 | 
					 | 
				
			||||||
    case 1: // 针叶林
 | 
					 | 
				
			||||||
        impact_factor = 0.7;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 2: // 落叶林
 | 
					 | 
				
			||||||
        impact_factor = 0.5;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 3: // 灌木林
 | 
					 | 
				
			||||||
        impact_factor = 0.4;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 4: //枯枝落叶
 | 
					 | 
				
			||||||
        impact_factor = 1.2;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 5: //草原
 | 
					 | 
				
			||||||
        impact_factor = 2;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    default:
 | 
					 | 
				
			||||||
        cout << "植被类型输入错误!" << endl;
 | 
					 | 
				
			||||||
        return -1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return impact_factor;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,19 +0,0 @@
 | 
				
			|||||||
#include "pixel.h"
 | 
					 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace std;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main() {
 | 
					 | 
				
			||||||
    // 传入现实中两个物体的面积和它们在图像中所占像素面积
 | 
					 | 
				
			||||||
    PixelRatioConverter p(5, 10, 100, 200);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 获取像素比例系数
 | 
					 | 
				
			||||||
    double ratio = p.getPixelRatio();
 | 
					 | 
				
			||||||
    cout << "像素比例系数:" << ratio << endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 计算下一步物体在图像中所占像素面积
 | 
					 | 
				
			||||||
    int next_pixel_area = p.getNextPixelArea(15);
 | 
					 | 
				
			||||||
    cout << "下一步物体在图像中所占像素面积:" << next_pixel_area << endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,29 +0,0 @@
 | 
				
			|||||||
class PixelRatioConverter {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    // 构造函数,传入两个现实中的物体面积和它们在图像中所占像素面积
 | 
					 | 
				
			||||||
    PixelRatioConverter(double real_area1, double real_area2, int pixel_area1, int pixel_area2) {
 | 
					 | 
				
			||||||
        this->real_area1 = real_area1;
 | 
					 | 
				
			||||||
        this->real_area2 = real_area2;
 | 
					 | 
				
			||||||
        this->pixel_area1 = pixel_area1;
 | 
					 | 
				
			||||||
        this->pixel_area2 = pixel_area2;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 获取像素比例系数
 | 
					 | 
				
			||||||
    double getPixelRatio() {
 | 
					 | 
				
			||||||
        double ratio = (real_area1 / real_area2) * (pixel_area2 / pixel_area1);
 | 
					 | 
				
			||||||
        return ratio; // 返回像素比例系数
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 根据像素比例系数,计算下一步物体在图像中所占像素面积
 | 
					 | 
				
			||||||
    int getNextPixelArea(int next_real_area) {
 | 
					 | 
				
			||||||
        double ratio = this->getPixelRatio();
 | 
					 | 
				
			||||||
        int next_pixel_area = static_cast<int>(next_real_area / ratio);
 | 
					 | 
				
			||||||
        return next_pixel_area; // 返回下一步物体在图像中所占像素面积
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
    double real_area1; // 第一个现实中的物体面积
 | 
					 | 
				
			||||||
    double real_area2; // 第二个现实中的物体面积
 | 
					 | 
				
			||||||
    int pixel_area1; // 第一个物体在图像中所占像素面积
 | 
					 | 
				
			||||||
    int pixel_area2; // 第二个物体在图像中所占像素面积
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,38 +0,0 @@
 | 
				
			|||||||
#include <iostream>
 | 
					 | 
				
			||||||
using namespace std;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int windToDirection(int type)
 | 
					 | 
				
			||||||
{
 | 
					 | 
				
			||||||
	int direction = 0;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 根据类型获取风向
 | 
					 | 
				
			||||||
    switch (type) {
 | 
					 | 
				
			||||||
    case 1: // 北风
 | 
					 | 
				
			||||||
        direction = 0;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 2: // 东北风
 | 
					 | 
				
			||||||
        direction = 45;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 3: // 东风
 | 
					 | 
				
			||||||
        direction = 90;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 4: // 东南风
 | 
					 | 
				
			||||||
        direction = 135;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 5: // 南风
 | 
					 | 
				
			||||||
        direction = 180;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 6: //西南风
 | 
					 | 
				
			||||||
        direction = 225;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 7: //西风
 | 
					 | 
				
			||||||
        direction = 270;
 | 
					 | 
				
			||||||
        break;
 | 
					 | 
				
			||||||
    case 8: //西北风
 | 
					 | 
				
			||||||
        direction = 315;
 | 
					 | 
				
			||||||
    default:
 | 
					 | 
				
			||||||
        cout << "植被类型输入错误!" << endl;
 | 
					 | 
				
			||||||
        return -1;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
    return direction;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,62 +0,0 @@
 | 
				
			|||||||
#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;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,23 +0,0 @@
 | 
				
			|||||||
#include "Alarm.h"
 | 
					 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace std;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main() {
 | 
					 | 
				
			||||||
    AlarmSystem alarm; // 创建警报系统对象
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    alarm.arm(); // 启动警报系统
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 模拟接收到信息并触发警报
 | 
					 | 
				
			||||||
    string message = "温度异常";
 | 
					 | 
				
			||||||
    alarm.receiveMessage(message);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    alarm.disarm(); // 关闭警报系统
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 再次模拟接收到信息,但由于警报系统已关闭,不会触发警报
 | 
					 | 
				
			||||||
    string message2 = "火灾警报";
 | 
					 | 
				
			||||||
    alarm.receiveMessage(message2);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,46 +0,0 @@
 | 
				
			|||||||
#include <iostream>
 | 
					 | 
				
			||||||
#include <string>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace std;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
class AlarmSystem {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    // 构造函数,初始化警报系统
 | 
					 | 
				
			||||||
    AlarmSystem() {
 | 
					 | 
				
			||||||
        isArmed = false;
 | 
					 | 
				
			||||||
        alarmMessage = "警报!有异常情况发生!";
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 启动警报系统
 | 
					 | 
				
			||||||
    void arm() {
 | 
					 | 
				
			||||||
        isArmed = true;
 | 
					 | 
				
			||||||
        cout << "警报系统已启动" << endl;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 关闭警报系统
 | 
					 | 
				
			||||||
    void disarm() {
 | 
					 | 
				
			||||||
        isArmed = false;
 | 
					 | 
				
			||||||
        cout << "警报系统已关闭" << endl;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 接收信息并触发警报
 | 
					 | 
				
			||||||
    void receiveMessage(const string& message) {
 | 
					 | 
				
			||||||
        if (isArmed) {
 | 
					 | 
				
			||||||
            cout << "接收到信息:" << message << endl;
 | 
					 | 
				
			||||||
            triggerAlarm();
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
        else {
 | 
					 | 
				
			||||||
            cout << "未启动警报系统,忽略信息:" << message << endl;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
    bool isArmed; // 警报系统是否启动
 | 
					 | 
				
			||||||
    string alarmMessage; // 警报信息
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 触发警报
 | 
					 | 
				
			||||||
    void triggerAlarm() {
 | 
					 | 
				
			||||||
        cout << "发出警报:" << alarmMessage << endl;
 | 
					 | 
				
			||||||
        // 这里可以实现具体的警报动作,例如触发声音、发送通知等
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,19 +0,0 @@
 | 
				
			|||||||
#include "Distance.h"
 | 
					 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace std;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main() {
 | 
					 | 
				
			||||||
    // 传入相机的基线长度和树木在两个视角下的像素位移
 | 
					 | 
				
			||||||
    TreeDistanceEstimator treeEstimator(0.1, 30);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 设置相机的焦距
 | 
					 | 
				
			||||||
    treeEstimator.setFocalLength(100);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 估测树木的距离
 | 
					 | 
				
			||||||
    double distance = treeEstimator.estimateDistance();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    cout << "估测的树木距离:" << distance << " 米" << endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,19 +0,0 @@
 | 
				
			|||||||
class TreeDistanceEstimator {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    // 构造函数,传入相机的基线长度和树木在两个视角下的像素位移
 | 
					 | 
				
			||||||
    TreeDistanceEstimator(double baseline, double pixel_displacement) {
 | 
					 | 
				
			||||||
        this->baseline = baseline;
 | 
					 | 
				
			||||||
        this->pixel_displacement = pixel_displacement;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 估测树木的距离
 | 
					 | 
				
			||||||
    double estimateDistance() {
 | 
					 | 
				
			||||||
        double distance = (baseline * focal_length) / pixel_displacement;
 | 
					 | 
				
			||||||
        return distance; // 返回估测的距离
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
    double baseline; // 相机的基线长度
 | 
					 | 
				
			||||||
    double pixel_displacement; // 树木在两个视角下的像素位移
 | 
					 | 
				
			||||||
    double focal_length; // 相机焦距
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
@ -1,19 +0,0 @@
 | 
				
			|||||||
#include "pixel.h"
 | 
					 | 
				
			||||||
#include <iostream>
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
using namespace std;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
int main() {
 | 
					 | 
				
			||||||
    // 传入现实中两个物体的面积和它们在图像中所占像素面积
 | 
					 | 
				
			||||||
    PixelRatioConverter p(5, 10, 100, 200);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 获取像素比例系数
 | 
					 | 
				
			||||||
    double ratio = p.getPixelRatio();
 | 
					 | 
				
			||||||
    cout << "像素比例系数:" << ratio << endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 计算下一步物体在图像中所占像素面积
 | 
					 | 
				
			||||||
    int next_pixel_area = p.getNextPixelArea(15);
 | 
					 | 
				
			||||||
    cout << "下一步物体在图像中所占像素面积:" << next_pixel_area << endl;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    return 0;
 | 
					 | 
				
			||||||
}
 | 
					 | 
				
			||||||
@ -1,29 +0,0 @@
 | 
				
			|||||||
class PixelRatioConverter {
 | 
					 | 
				
			||||||
public:
 | 
					 | 
				
			||||||
    // 构造函数,传入两个现实中的物体面积和它们在图像中所占像素面积
 | 
					 | 
				
			||||||
    PixelRatioConverter(double real_area1, double real_area2, int pixel_area1, int pixel_area2) {
 | 
					 | 
				
			||||||
        this->real_area1 = real_area1;
 | 
					 | 
				
			||||||
        this->real_area2 = real_area2;
 | 
					 | 
				
			||||||
        this->pixel_area1 = pixel_area1;
 | 
					 | 
				
			||||||
        this->pixel_area2 = pixel_area2;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 获取像素比例系数
 | 
					 | 
				
			||||||
    double getPixelRatio() {
 | 
					 | 
				
			||||||
        double ratio = (real_area1 / real_area2) * (pixel_area2 / pixel_area1);
 | 
					 | 
				
			||||||
        return ratio; // 返回像素比例系数
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    // 根据像素比例系数,计算下一步物体在图像中所占像素面积
 | 
					 | 
				
			||||||
    int getNextPixelArea(int next_real_area) {
 | 
					 | 
				
			||||||
        double ratio = this->getPixelRatio();
 | 
					 | 
				
			||||||
        int next_pixel_area = static_cast<int>(next_real_area / ratio);
 | 
					 | 
				
			||||||
        return next_pixel_area; // 返回下一步物体在图像中所占像素面积
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
private:
 | 
					 | 
				
			||||||
    double real_area1; // 第一个现实中的物体面积
 | 
					 | 
				
			||||||
    double real_area2; // 第二个现实中的物体面积
 | 
					 | 
				
			||||||
    int pixel_area1; // 第一个物体在图像中所占像素面积
 | 
					 | 
				
			||||||
    int pixel_area2; // 第二个物体在图像中所占像素面积
 | 
					 | 
				
			||||||
};
 | 
					 | 
				
			||||||
					Loading…
					
					
				
		Reference in new issue