Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
J
jfx_kalman_filter_src
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
oscar
jfx_kalman_filter_src
Commits
27623ffb
Commit
27623ffb
authored
Dec 13, 2021
by
oscar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交修改iou
parent
480e4702
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
13 deletions
+52
-13
Track3D.cpp
BaseTracker/Track3D.cpp
+52
-13
No files found.
BaseTracker/Track3D.cpp
View file @
27623ffb
...
...
@@ -85,6 +85,24 @@ 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
Track3D
::
CalculateIou
(
const
std
::
vector
<
float
>&
data
)
{
std
::
vector
<
float
>
states
;
...
...
@@ -100,22 +118,43 @@ double Track3D::CalculateIou(const std::vector<float>& data)
cv
::
RotatedRect
rect2
=
cv
::
RotatedRect
(
cv
::
Point2f
(
data
[
0
],
data
[
1
]),
cv
::
Size2f
(
data
[
3
],
data
[
4
]),
data
[
6
]);
uint64_t
begin
=
GetCurTime
();
double
iou_2d
=
calcIOU
(
rect1
,
rect2
);
double
iou_3d
=
0
;
if
(
iou_2d
>
0
)
{
//SDK_LOG(SDK_INFO, " iou_2d = %f", iou_2d);
double
tru_minz
=
states
[
2
]
-
states
[
5
];
double
tru_maxz
=
states
[
2
]
+
states
[
5
];
double
land_minz
=
data
[
2
]
-
data
[
5
];
double
land_maxz
=
data
[
2
]
+
data
[
5
];
double
iou_3d
=
0.0
f
;
//double iou_2d = calcIOU(rect1,rect2);
//if (iou_2d > 0) {
// //SDK_LOG(SDK_INFO, " iou_2d = %f", iou_2d);
// double tru_minz = states[2] - states[5]/2;
// double tru_maxz = states[2] + states[5]/2;
// double land_minz = data[2] - data[5]/2;
// double land_maxz = data[2] + data[5]/2;
// if (land_maxz <= tru_maxz && land_maxz >= tru_minz) {
// double height_iou = (land_maxz - tru_minz) / (tru_maxz - land_minz);
// iou_3d = iou_2d * height_iou;
// }
// else if (tru_maxz < land_maxz && tru_maxz > land_minz) {
// double height_iou = (tru_maxz - land_minz) / (land_maxz - tru_minz);
// iou_3d = iou_2d * height_iou;
// }
//}
double
area
=
calcIntersectionArea
(
rect1
,
rect2
);
if
(
area
>
0
)
{
double
interHeight
=
0.0
f
;
double
tru_minz
=
states
[
2
]
-
states
[
5
]
/
2
;
double
tru_maxz
=
states
[
2
]
+
states
[
5
]
/
2
;
double
land_minz
=
data
[
2
]
-
data
[
5
]
/
2
;
double
land_maxz
=
data
[
2
]
+
data
[
5
]
/
2
;
if
(
land_maxz
<=
tru_maxz
&&
land_maxz
>=
tru_minz
)
{
double
height_iou
=
(
land_maxz
-
tru_minz
)
/
(
tru_maxz
-
land_minz
);
iou_3d
=
iou_2d
*
height_iou
;
interHeight
=
land_maxz
-
tru_minz
;
}
else
if
(
tru_maxz
<
land_maxz
&&
tru_maxz
>
land_minz
)
{
double
height_iou
=
(
tru_maxz
-
land_minz
)
/
(
land_maxz
-
tru_minz
);
iou_3d
=
iou_2d
*
height_iou
;
interHeight
=
tru_maxz
-
land_minz
;
}
if
(
interHeight
>
0
)
{
double
inter3D
=
area
*
interHeight
;
iou_3d
=
inter3D
/
(
states
[
3
]
*
states
[
4
]
*
states
[
5
]
+
data
[
3
]
*
data
[
4
]
*
data
[
5
]
-
inter3D
);
}
}
//SDK_LOG(SDK_INFO, "CuboidIoU time = %llu", GetCurTime() - begin);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment