Commit 59fd78c7 authored by oscar's avatar oscar

提交相机消息iou过滤

parent 8e65a616
......@@ -161,23 +161,23 @@ float calcIOU(cv::RotatedRect rect1, cv::RotatedRect rect2) {
}
double calcIntersectionArea(cv::RotatedRect rect1, cv::RotatedRect rect2)
{
std::vector<cv::Point2f> vertices;
int intersectionType = cv::rotatedRectangleIntersection(rect1, rect2, vertices);
if (vertices.size() == 0)
return 0.0;
else
{
std::vector<cv::Point2f> order_pts;
// 找到交集(交集的区域),对轮廓的各个点进行排序
cv::convexHull(cv::Mat(vertices), order_pts, true);
double area = cv::contourArea(order_pts);
//float inner = (float)(area / (areaRect1 + areaRect2 - area + 0.0001));
return area;
}
}
//double calcIntersectionArea(cv::RotatedRect rect1, cv::RotatedRect rect2)
//{
// std::vector<cv::Point2f> vertices;
// int intersectionType = cv::rotatedRectangleIntersection(rect1, rect2, vertices);
// if (vertices.size() == 0)
// return 0.0;
// else
// {
// std::vector<cv::Point2f> order_pts;
// // 找到交集(交集的区域),对轮廓的各个点进行排序
//
// cv::convexHull(cv::Mat(vertices), order_pts, true);
// double area = cv::contourArea(order_pts);
// //float inner = (float)(area / (areaRect1 + areaRect2 - area + 0.0001));
// return area;
// }
//}
double Track3D::CalculateIou(const std::vector<float>& data)
{
......@@ -238,7 +238,7 @@ double Track3D::CalculateIou(const std::vector<float>& data)
else if (tru_maxz < land_maxz && tru_maxz > land_minz) {
interHeight = tru_maxz - land_minz;
}
if (interHeight > 0)
if (1)//interHeight > 0)
{
//double inter3D = area * interHeight;
//iou_3d = inter3D / (states[4] * states[5] * states[6] + data[5] * data[6] * data[7] - inter3D);
......
......@@ -281,6 +281,8 @@ void TrackingRos::Init(ros::NodeHandle& nh)
SDK_LOG(SDK_INFO, "detect_recv_msg_only = %d", m_recvMsgBit);
nh.param<int32_t>("detct_camera_car_size", m_detectCameraCarSize, 150);
SDK_LOG(SDK_INFO, "detct_camera_car_size = %d", m_detectCameraCarSize);
nh.param<float>("lidar_camera_msg_iou", m_lidar_camera_msg_iou, 0.4);
SDK_LOG(SDK_INFO, "matrix_angle_r_value = %f", m_lidar_camera_msg_iou);
YAML::Node config = YAML::LoadFile(file.c_str());
......@@ -552,7 +554,15 @@ void TrackingRos::TrackingCameraCallBackFunc(const jfx_common_msgs::InferResesCo
{
for (auto& obj : cloudPtr->array)
{
if (abs(obj.x - objMsg.x) < std::max(objMsg.l * 2, (double)3.0) && abs(obj.y - objMsg.y) < std::max(objMsg.w * 2.0, (double)3.0))
//if (abs(obj.x - objMsg.x) < std::max(objMsg.l * 2.0, (double)3.0) && abs(obj.y - objMsg.y) < std::max(objMsg.w * 2.0, (double)3.0))
//{
// duplicate = 1;
// break;
//}
cv::RotatedRect rect1 = cv::RotatedRect(cv::Point2f(objMsg.x, objMsg.y), cv::Size2f(objMsg.l, objMsg.w), objMsg.rot_y);
cv::RotatedRect rect2 = cv::RotatedRect(cv::Point2f(obj.x, obj.y), cv::Size2f(obj.l, obj.w), obj.rot_y * 180 / 3.1415926);
float rate = calcIntersectionRate(rect1, rect2);
if (rate > m_lidar_camera_msg_iou)
{
duplicate = 1;
break;
......
......@@ -61,4 +61,5 @@ public:
int m_recvMsgBit = 0b1111;//处理消息的类型
int m_detectCameraCarSize = 150;//处理相机汽车边长的最小限制
float m_lidar_camera_msg_iou;//相机和雷达消息过滤用iou值
};
......@@ -86,4 +86,30 @@ std::string GetTimeStr(uint64_t timestamp)
sprintf(tStr, ".%d", misc);
std::string timeStr = std::string(str) + std::string(tStr);
return timeStr;
}
\ No newline at end of file
}
double calcIntersectionArea(cv::RotatedRect rect1, cv::RotatedRect rect2)
{
std::vector<cv::Point2f> vertices;
int intersectionType = cv::rotatedRectangleIntersection(rect1, rect2, vertices);
if (vertices.size() == 0)
return 0.0;
else
{
std::vector<cv::Point2f> order_pts;
// 找到交集(交集的区域),对轮廓的各个点进行排序
cv::convexHull(cv::Mat(vertices), order_pts, true);
double area = cv::contourArea(order_pts);
//float inner = (float)(area / (areaRect1 + areaRect2 - area + 0.0001));
return area;
}
}
float calcIntersectionRate(cv::RotatedRect rect1, cv::RotatedRect rect2)
{
double area = calcIntersectionArea(rect1, rect2);
float iou_2d = area / (rect1.size.width * rect1.size.height + rect2.size.width * rect2.size.height);
return iou_2d;
}
......@@ -2,6 +2,7 @@
#include <string>
#include <vector>
#include <opencv2/opencv.hpp>
uint64_t GetCurTime();
......@@ -12,3 +13,7 @@ std::string GetMatrixStr(const float* data_ptr, int col, int row);
std::string GetMatrixStr(const std::vector<std::vector<float>>& data_ptr, int col, int row);
std::string GetMatrixStr(const std::vector<std::vector<double>>& data_ptr, int col, int row);
std::string GetMatrixStr(float** data_ptr, int col, int row);
double calcIntersectionArea(cv::RotatedRect rect1, cv::RotatedRect rect2);
float calcIntersectionRate(cv::RotatedRect rect1, cv::RotatedRect rect2);
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment