项目结构大变
This commit is contained in:
@@ -2,20 +2,29 @@
|
||||
#include "config.h"
|
||||
#include <cmath>
|
||||
|
||||
BallisticPredictor::BallisticPredictor(float bullet_speed)
|
||||
BallisticPredictor::BallisticPredictor(float bullet_speed)
|
||||
: bullet_speed(bullet_speed), last_ballistic_point(nullptr) {
|
||||
armor_half_width = ARMOR_WIDTH / 2000.0f; // Convert to meters
|
||||
armor_half_height = ARMOR_HEIGHT / 2000.0f; // Convert to meters
|
||||
}
|
||||
|
||||
cv::Point2f* BallisticPredictor::predict_ballistic_point(const cv::Point2f* predicted_center,
|
||||
const cv::Point2f& img_center,
|
||||
BallisticPredictor::~BallisticPredictor() {
|
||||
if (last_ballistic_point != nullptr) {
|
||||
delete last_ballistic_point;
|
||||
last_ballistic_point = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
cv::Point2f* BallisticPredictor::predict_ballistic_point(const cv::Point2f* predicted_center,
|
||||
const cv::Point2f& img_center,
|
||||
const cv::Point2f& target_speed) {
|
||||
// Clean up the last ballistic point before creating a new one
|
||||
if (last_ballistic_point != nullptr) {
|
||||
delete last_ballistic_point;
|
||||
last_ballistic_point = nullptr;
|
||||
}
|
||||
|
||||
if (predicted_center == nullptr) {
|
||||
if (last_ballistic_point != nullptr) {
|
||||
delete last_ballistic_point;
|
||||
last_ballistic_point = nullptr;
|
||||
}
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -36,9 +45,6 @@ cv::Point2f* BallisticPredictor::predict_ballistic_point(const cv::Point2f* pred
|
||||
cv::Point2f ballistic_point(ballistic_x, ballistic_y);
|
||||
|
||||
// Update last ballistic point
|
||||
if (last_ballistic_point != nullptr) {
|
||||
delete last_ballistic_point;
|
||||
}
|
||||
last_ballistic_point = new cv::Point2f(ballistic_point);
|
||||
|
||||
return last_ballistic_point;
|
||||
|
||||
Reference in New Issue
Block a user