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
6e14a134
Commit
6e14a134
authored
Mar 21, 2022
by
oscar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
提交测试代码和编译
parent
bfb0607f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
153 additions
and
10 deletions
+153
-10
Track2D.cpp
BaseTracker/Track2D.cpp
+7
-1
Track2D.h
BaseTracker/Track2D.h
+5
-0
CMakeLists.txt
test/CMakeLists.txt
+26
-6
main.cpp
test/main.cpp
+115
-3
No files found.
BaseTracker/Track2D.cpp
View file @
6e14a134
...
...
@@ -65,5 +65,11 @@ double Track2D::CalculateIou(const std::vector<float>& data)
//float union_area = det_area + trk_area - intersection_area;
//auto iou = intersection_area / union_area;
return
0.0
f
;
auto
w
=
std
::
max
(
std
::
min
((
states
[
0
]
+
states
[
2
]),
(
data
[
0
]
+
data
[
2
]))
-
std
::
max
(
states
[
0
],
data
[
0
]),
0.0
f
);
auto
h
=
std
::
max
(
std
::
min
((
states
[
1
]
+
states
[
3
]),
(
data
[
1
]
+
data
[
3
]))
-
std
::
max
(
states
[
1
],
data
[
1
]),
0.0
f
);
auto
intersection_area
=
w
*
h
;
float
union_area
=
states
[
2
]
*
states
[
3
]
+
data
[
2
]
*
data
[
3
]
-
intersection_area
;
auto
iou
=
intersection_area
/
union_area
;
return
iou
;
}
BaseTracker/Track2D.h
View file @
6e14a134
...
...
@@ -11,5 +11,10 @@ public:
Track2D
();
~
Track2D
()
{}
virtual
int
GetIouDataOrder
(
std
::
vector
<
int
>&
order
)
{
return
0
;
};
virtual
int
GetKFDataOrder
(
std
::
vector
<
int
>&
order
)
{
return
0
;
};
virtual
double
CalculateIou
(
const
std
::
vector
<
float
>&
data
);
static
void
MeasureIouData
(
const
std
::
vector
<
float
>&
input
,
std
::
vector
<
float
>&
out
,
int
&
obj_type
)
{}
};
test/CMakeLists.txt
View file @
6e14a134
cmake_minimum_required
(
VERSION 3.0.2
)
project
(
test
)
project
(
kf_
test
)
SET
(
CMAKE_BUILD_TYPE
"Debug"
)
#SET(CMAKE_BUILD_TYPE "Release")
...
...
@@ -8,14 +8,34 @@ SET(CMAKE_BUILD_TYPE "Debug")
SET
(
CMAKE_CXX_FLAGS_DEBUG
"$ENV{CXXFLAGS} -O0 -Wall -g -ggdb"
)
SET
(
CMAKE_CXX_FLAGS_RELEASE
"$ENV{CXXFLAGS} -O3 -Wall"
)
find_package
(
OpenCV REQUIRED
)
include_directories
(
OpenCV_INCLUDE_DIRS
)
include_directories
(
${
PROJECT_SOURCE_DIR
}
/
${
PROJECT_SOURCE_DIR
}
/../
${
PROJECT_SOURCE_DIR
}
/../BaseTracker
${
PROJECT_SOURCE_DIR
}
/../tracker
${
PROJECT_SOURCE_DIR
}
/../log
${
PROJECT_SOURCE_DIR
}
/../common
)
file
(
GLOB_RECURSE SRC_FILES
${
PROJECT_SOURCE_DIR
}
/../tracker/kalman_filter.cpp
${
PROJECT_SOURCE_DIR
}
/../tracker/munkres.cpp
${
PROJECT_SOURCE_DIR
}
/../common/Component.cpp
# ${PROJECT_SOURCE_DIR}/../coordinate/*.cpp
)
add_executable
(
${
PROJECT_NAME
}
main.cpp
./main.cpp
./../BaseTracker/Track2D.cpp
./../BaseTracker/BaseTrack.cpp
./../BaseTracker/Iou.cpp
${
SRC_FILES
}
)
target_link_libraries
(
${
PROJECT_NAME
}
)
\ No newline at end of file
${
OpenCV_LIBS
}
)
\ No newline at end of file
test/main.cpp
View file @
6e14a134
#
include
<
string
>
#include "BaseTracker.h"
#include "Track2D.h"
#include <fstream>
#include <iostream>
void
Split
(
std
::
string
&
input
,
std
::
string
separator
,
std
::
vector
<
std
::
string
>&
out
)
{
int
begin
=
0
;
while
(
begin
<
input
.
size
())
{
auto
idx
=
input
.
find_first_of
(
separator
.
c_str
(),
begin
);
if
(
idx
==
std
::
string
::
npos
)
idx
=
input
.
size
();
std
::
string
value
=
input
.
substr
(
begin
,
idx
-
begin
);
out
.
emplace_back
(
value
);
begin
=
idx
+
1
;
}
}
SDKLogBase
*
g_logHandle
;
int
g_logFileIdx
[
IDX_NUM
];
char
*
g_moduleName
;
int
main
(
int
argc
,
char
*
argv
[])
{
printf
(
"hello world
\n
"
);
return
0
;
printf
(
"hello world
\n
"
);
BaseTracker
<
Track2D
>
tracker
;
tracker
.
SetGPU
(
0
);
tracker
.
SetIouThreshold
(
0.1
);
tracker
.
SetMaxCoastCycles
(
50
);
tracker
.
SetValidUpdateCount
(
0
);
std
::
ifstream
fp
(
"../train/MOT16-02/det/det.txt"
);
if
(
fp
.
fail
())
{
printf
(
"load file failed
\n
"
);
return
-
1
;
}
else
{
printf
(
"load file success
\n
"
);
}
int
id
=
0
;
std
::
vector
<
std
::
vector
<
float
>>
input
;
std
::
map
<
uint64_t
,
std
::
vector
<
std
::
vector
<
float
>>>
results
;
while
(
fp
)
{
std
::
string
str
;
std
::
getline
(
fp
,
str
,
'\n'
);
printf
(
"load str = %s
\n
"
,
str
.
c_str
());
std
::
vector
<
std
::
string
>
values
;
Split
(
str
,
","
,
values
);
int
_id
=
id
;
if
(
values
.
size
()
==
10
)
_id
=
std
::
stoi
(
values
[
0
].
c_str
());
if
((
id
!=
0
&&
_id
!=
id
)
||
str
.
empty
())
{
//处理input数据
std
::
vector
<
uint64_t
>
detectionsId
;
std
::
map
<
uint64_t
,
int
>
updateId
;
std
::
vector
<
uint64_t
>
lostId
;
tracker
.
Run
(
input
,
4
,
6
,
detectionsId
,
updateId
,
lostId
);
std
::
map
<
uint64_t
,
std
::
shared_ptr
<
Track2D
>
>&
trackers
=
tracker
.
GetStates
();
for
(
auto
&
iter
:
trackers
)
{
std
::
vector
<
float
>
data
;
if
(
iter
.
second
->
IsValid
()
&&
iter
.
second
->
GetStateData
(
data
)
==
0
)
{
if
(
results
.
find
(
iter
.
first
)
==
results
.
end
())
{
std
::
vector
<
std
::
vector
<
float
>>
info
;
results
[
iter
.
first
]
=
info
;
}
std
::
vector
<
float
>
inf
{
(
float
)
id
,
data
[
0
],
data
[
1
],
data
[
2
],
data
[
3
]
};
printf
(
"id = %d,data = [%f,%f,%f,%f,%f]
\n
"
,
id
,
inf
[
0
],
inf
[
1
],
inf
[
2
],
inf
[
3
],
inf
[
4
]);
results
[
iter
.
first
].
push_back
(
inf
);
}
}
input
.
clear
();
}
if
(
values
.
size
()
!=
10
)
{
printf
(
"load values is not 10 str = %s
\n
"
,
str
.
c_str
());
break
;
}
id
=
_id
;
std
::
vector
<
float
>
obj
;
obj
.
push_back
(
std
::
stof
(
values
[
2
]));
obj
.
push_back
(
std
::
stof
(
values
[
3
]));
obj
.
push_back
(
std
::
stof
(
values
[
4
]));
obj
.
push_back
(
std
::
stof
(
values
[
5
]));
input
.
push_back
(
obj
);
// printf("obj value id = %d, x = %f,y = %f,w = %f,h = %f\n",id,obj[0],obj[1],obj[2],obj[3]);
}
printf
(
"results size = %d
\n
"
,
results
.
size
());
std
::
ofstream
fpw
(
"test.txt"
);
if
(
fpw
)
{
for
(
auto
iter
:
results
)
{
for
(
int
i
=
0
;
i
<
iter
.
second
.
size
();
i
++
)
{
fpw
<<
int
(
iter
.
second
[
i
][
0
])
<<
","
<<
iter
.
first
<<
","
<<
iter
.
second
[
i
][
1
]
<<
","
<<
iter
.
second
[
i
][
2
]
<<
","
<<
iter
.
second
[
i
][
3
]
<<
","
<<
iter
.
second
[
i
][
4
]
<<
","
<<
"0.99,-1,-1,-1
\n
"
;
}
}
}
else
{
printf
(
"open file failed
\n
"
);
}
fp
.
close
();
fpw
.
close
();
return
0
;
}
\ No newline at end of file
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