Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
D
deepinfer
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
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
yangxue
deepinfer
Commits
d72c8f44
Commit
d72c8f44
authored
Jul 25, 2023
by
xin.wang.waytous
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
unique-unit-map-for-model
parent
8da6ff45
Show whitespace changes
Inline
Side-by-side
Showing
36 changed files
with
122 additions
and
92 deletions
+122
-92
fusion_model.yaml
configs/tasks/fusion/fusion_model.yaml
+1
-1
rgb_intrinsic.yaml
configs/tasks/fusion/rgb_intrinsic.yaml
+9
-0
base_io.h
include/interfaces/base_io.h
+16
-4
base_model.h
include/interfaces/base_model.h
+1
-0
base_unit.h
include/interfaces/base_unit.h
+3
-1
main.cpp
main.cpp
+1
-1
base_io.cpp
src/interfaces/base_io.cpp
+9
-11
base_unit.cpp
src/interfaces/base_unit.cpp
+2
-1
bayesian_fusioner.cpp
src/libs/fusioner/bayesian_fusioner.cpp
+4
-4
bayesian_fusioner.h
src/libs/fusioner/bayesian_fusioner.h
+1
-1
trt_infer.cpp
src/libs/inferences/tensorrt/trt_infer.cpp
+4
-4
trt_infer.h
src/libs/inferences/tensorrt/trt_infer.h
+1
-1
homo_project.cpp
src/libs/postprocessors/homo_project.cpp
+4
-4
homo_project.h
src/libs/postprocessors/homo_project.h
+1
-1
mobilefacenet_post.cpp
src/libs/postprocessors/mobilefacenet_post.cpp
+5
-5
mobilefacenet_post.h
src/libs/postprocessors/mobilefacenet_post.h
+1
-1
multi_post.cpp
src/libs/postprocessors/multi_post.cpp
+10
-10
multi_post.h
src/libs/postprocessors/multi_post.h
+1
-1
trades_post.cpp
src/libs/postprocessors/trades_post.cpp
+5
-5
trades_post.h
src/libs/postprocessors/trades_post.h
+1
-1
whenet_post.cpp
src/libs/postprocessors/whenet_post.cpp
+4
-4
whenet_post.h
src/libs/postprocessors/whenet_post.h
+1
-1
yolov5_post.cpp
src/libs/postprocessors/yolov5_post.cpp
+5
-5
yolov5_post.h
src/libs/postprocessors/yolov5_post.h
+1
-1
resize_norm.cpp
src/libs/preprocessors/resize_norm.cpp
+4
-4
resize_norm.h
src/libs/preprocessors/resize_norm.h
+1
-1
undistort.cpp
src/libs/preprocessors/undistort.cpp
+4
-4
undistort.h
src/libs/preprocessors/undistort.h
+1
-1
camera_src.cpp
src/libs/sources/camera_src.cpp
+2
-2
byte_tracker.cpp
src/libs/trackers/byte_tracker.cpp
+4
-4
byte_tracker.h
src/libs/trackers/byte_tracker.h
+1
-1
camera_model.cpp
src/models/camera_model.cpp
+7
-5
task_fusion.cpp
src/tasks/task_fusion.cpp
+6
-2
task_fusion.h
src/tasks/task_fusion.h
+1
-0
t_b1_res.jpg
test/t_b1_res.jpg
+0
-0
t_b2_res.jpg
test/t_b2_res.jpg
+0
-0
No files found.
configs/tasks/fusion/fusion_model.yaml
View file @
d72c8f44
...
...
@@ -3,7 +3,7 @@
name
:
CameraModel
inputNames
:
[
cvVisImage
,
cvThermalImage
]
# outputNames: [fusionedDetections]
outputNames
:
[
trackedDetections
]
outputNames
:
[
trackedDetections
,
undistortVisImage
]
units
:
# camera rgb, using TraDes segmentor
...
...
configs/tasks/fusion/rgb_intrinsic.yaml
View file @
d72c8f44
...
...
@@ -12,6 +12,15 @@ distortion_coefficients:
rows
:
1
cols
:
5
data
:
[
-0.308855
,
0.080618
,
-0.000948
,
-0.000307
,
0.000000
]
new_image_width
:
1920
new_image_height
:
1080
new_camera_matrix
:
rows
:
3
cols
:
3
dt
:
d
data
:
[
954.94556
,
0.
,
959.48891
,
0.
,
955.72757
,
550.42017
,
0.
,
0.
,
1.
]
rectification_matrix
:
rows
:
3
cols
:
3
...
...
include/interfaces/base_io.h
View file @
d72c8f44
...
...
@@ -22,12 +22,24 @@ public:
using
BaseIOPtr
=
std
::
shared_ptr
<
BaseIO
>
;
typedef
std
::
map
<
std
::
string
,
BaseIOPtr
>
BaseIOMap
;
BaseIOMap
&
GlobalBaseIOMap
();
BaseIOPtr
GetIOPtr
(
std
::
string
&
ioName
);
void
SetIOPtr
(
std
::
string
&
ioName
,
BaseIOPtr
src
);
class
BaseIOMap
{
public
:
BaseIOMap
()
=
default
;
BaseIOPtr
GetIOPtr
(
std
::
string
&
ioName
);
void
SetIOPtr
(
std
::
string
&
ioName
,
BaseIOPtr
src
);
private
:
std
::
map
<
std
::
string
,
BaseIOPtr
>
map
;
};
using
BaseIOMapPtr
=
std
::
shared_ptr
<
BaseIOMap
>
;
}
// namespace interfaces
...
...
include/interfaces/base_model.h
View file @
d72c8f44
...
...
@@ -36,6 +36,7 @@ public:
public
:
std
::
vector
<
BaseUnitPtr
>
units_
;
BaseIOMapPtr
modelUnitMap
;
std
::
vector
<
std
::
string
>
inputNames
;
std
::
vector
<
std
::
string
>
outputNames
;
...
...
include/interfaces/base_unit.h
View file @
d72c8f44
...
...
@@ -10,6 +10,7 @@
#include "base/blob.h"
#include "common/log.h"
#include "common/register.h"
#include "interfaces/base_io.h"
namespace
waytous
{
namespace
deepinfer
{
...
...
@@ -22,7 +23,7 @@ public:
BaseUnit
()
=
default
;
virtual
~
BaseUnit
()
=
default
;
virtual
bool
Init
(
YAML
::
Node
&
node
);
virtual
bool
Init
(
YAML
::
Node
&
node
,
BaseIOMapPtr
pmap
);
virtual
bool
Exec
()
=
0
;
...
...
@@ -33,6 +34,7 @@ public:
public
:
std
::
vector
<
std
::
string
>
inputNames
;
std
::
vector
<
std
::
string
>
outputNames
;
BaseIOMapPtr
pMap
;
};
using
BaseUnitPtr
=
std
::
shared_ptr
<
BaseUnit
>
;
...
...
main.cpp
View file @
d72c8f44
...
...
@@ -128,7 +128,7 @@ int main(int argc, char** argv){
./main TaskBSW image ../configs/tasks/bsw/bsw.yaml ../test/bsw.jpg ../test/bsw_res.jpg
./main TaskMulti image ../configs/tasks/multi/multi_task.yaml ../test/
bsw
.jpg ../test/multi_res.jpg
./main TaskMulti image ../configs/tasks/multi/multi_task.yaml ../test/
multi_test
.jpg ../test/multi_res.jpg
*/
...
...
src/interfaces/base_io.cpp
View file @
d72c8f44
...
...
@@ -6,25 +6,23 @@ namespace deepinfer {
namespace
interfaces
{
// cudafree global variable -> cuda_error 29
BaseIOMap
&
GlobalBaseIOMap
(){
static
BaseIOMap
GlobalIOMap
;
return
GlobalIOMap
;
}
//
BaseIOMap &GlobalBaseIOMap(){
//
static BaseIOMap GlobalIOMap;
//
return GlobalIOMap;
//
}
BaseIOPtr
GetIOPtr
(
std
::
string
&
ioName
){
auto
&
gmap
=
GlobalBaseIOMap
();
auto
iter
=
gmap
.
find
(
ioName
);
if
(
iter
==
gmap
.
end
())
{
BaseIOPtr
BaseIOMap
::
GetIOPtr
(
std
::
string
&
ioName
){
auto
iter
=
map
.
find
(
ioName
);
if
(
iter
==
map
.
end
())
{
return
nullptr
;
}
return
iter
->
second
;
}
void
SetIOPtr
(
std
::
string
&
ioName
,
BaseIOPtr
src
){
auto
&
gmap
=
GlobalBaseIOMap
();
gmap
[
ioName
]
=
src
;
void
BaseIOMap
::
SetIOPtr
(
std
::
string
&
ioName
,
BaseIOPtr
src
){
map
[
ioName
]
=
src
;
}
...
...
src/interfaces/base_unit.cpp
View file @
d72c8f44
...
...
@@ -4,9 +4,10 @@ namespace waytous {
namespace
deepinfer
{
namespace
interfaces
{
bool
BaseUnit
::
Init
(
YAML
::
Node
&
node
){
bool
BaseUnit
::
Init
(
YAML
::
Node
&
node
,
BaseIOMapPtr
pmap
){
inputNames
=
node
[
"inputNames"
].
as
<
std
::
vector
<
std
::
string
>>
();
outputNames
=
node
[
"outputNames"
].
as
<
std
::
vector
<
std
::
string
>>
();
pMap
=
pmap
;
return
true
;
};
...
...
src/libs/fusioner/bayesian_fusioner.cpp
View file @
d72c8f44
...
...
@@ -5,8 +5,8 @@ namespace deepinfer {
namespace
fusioner
{
bool
BayesianFusioner
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
bool
BayesianFusioner
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
{
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init BayesianFusioner error"
;
return
false
;
};
...
...
@@ -26,7 +26,7 @@ bool BayesianFusioner::Exec(){
std
::
vector
<
ios
::
Det2DPtr
>
all_objects
;
for
(
int
i
=
0
;
i
<
inputNames
.
size
();
i
++
){
auto
inputName
=
inputNames
[
i
];
auto
ptr
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
interfaces
::
GetIOPtr
(
inputName
));
auto
ptr
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
pMap
->
GetIOPtr
(
inputName
));
if
(
ptr
==
nullptr
){
LOG_ERROR
<<
"BayesianFusioner input "
<<
inputName
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -47,7 +47,7 @@ bool BayesianFusioner::Exec(){
);
auto
fusioned_objects
=
std
::
make_shared
<
ios
::
Detection2Ds
>
();
interfaces
::
SetIOPtr
(
outputNames
[
0
],
fusioned_objects
);
pMap
->
SetIOPtr
(
outputNames
[
0
],
fusioned_objects
);
for
(
size_t
i
=
0
;
i
<
indices
.
size
();
i
++
){
if
(
!
deleted
[
indices
[
i
]]){
std
::
vector
<
ios
::
Det2DPtr
>
matched_objs
;
...
...
src/libs/fusioner/bayesian_fusioner.h
View file @
d72c8f44
...
...
@@ -31,7 +31,7 @@ public:
{
"IOA"
,
BayesianFusionMatchMethod
::
IOA
}
};
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
...
...
src/libs/inferences/tensorrt/trt_infer.cpp
View file @
d72c8f44
...
...
@@ -28,8 +28,8 @@ TRTInference::~TRTInference(){
}
bool
TRTInference
::
Init
(
YAML
::
Node
&
configNode
){
if
(
!
BaseUnit
::
Init
(
configNode
)){
bool
TRTInference
::
Init
(
YAML
::
Node
&
configNode
,
interfaces
::
BaseIOMapPtr
pmap
){
if
(
!
BaseUnit
::
Init
(
configNode
,
pmap
)){
LOG_WARN
<<
"Init trt engine error"
;
return
false
;
};
...
...
@@ -79,7 +79,7 @@ bool TRTInference::Init(YAML::Node& configNode){
}
for
(
auto
inputName
:
inputNames
){
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
inputName
));
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
pMap
->
GetIOPtr
(
inputName
));
if
(
input
==
nullptr
){
LOG_ERROR
<<
"inference engine input "
<<
inputName
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -108,7 +108,7 @@ bool TRTInference::Init(YAML::Node& configNode){
auto
blob
=
std
::
make_shared
<
base
::
Blob
<
float
>>
(
shape
);
blobs_
.
insert
(
std
::
make_pair
(
name
,
blob
));
auto
output
=
std
::
make_shared
<
ios
::
NormalIO
>
(
blob
);
interfaces
::
SetIOPtr
(
name
,
output
);
pMap
->
SetIOPtr
(
name
,
output
);
auto
binding
=
blob
->
mutable_gpu_data
();
mBindings
.
emplace_back
(
static_cast
<
void
*>
(
binding
));
}
...
...
src/libs/inferences/tensorrt/trt_infer.h
View file @
d72c8f44
...
...
@@ -32,7 +32,7 @@ class TRTInference: public interfaces::BaseUnit {
public
:
~
TRTInference
();
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
virtual
bool
BuildEngine
(
YAML
::
Node
&
node
);
bool
Exec
()
override
;
virtual
std
::
string
Name
()
override
;
...
...
src/libs/postprocessors/homo_project.cpp
View file @
d72c8f44
...
...
@@ -5,8 +5,8 @@ namespace deepinfer {
namespace
postprocess
{
bool
HomoProject
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
bool
HomoProject
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
{
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init homo project error"
;
return
false
;
};
...
...
@@ -34,7 +34,7 @@ bool HomoProject::Init(YAML::Node& node) {
bool
HomoProject
::
Exec
(){
auto
ptr
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
interfaces
::
GetIOPtr
(
inputNames
[
0
]));
auto
ptr
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
pMap
->
GetIOPtr
(
inputNames
[
0
]));
if
(
ptr
==
nullptr
){
LOG_ERROR
<<
"HomoProject input "
<<
inputNames
[
0
]
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -68,7 +68,7 @@ bool HomoProject::Exec(){
projected_dets
->
detections
.
push_back
(
projected_obj
);
}
interfaces
::
SetIOPtr
(
outputNames
[
0
],
projected_dets
);
pMap
->
SetIOPtr
(
outputNames
[
0
],
projected_dets
);
return
true
;
}
...
...
src/libs/postprocessors/homo_project.h
View file @
d72c8f44
...
...
@@ -17,7 +17,7 @@ namespace postprocess {
class
HomoProject
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
...
...
src/libs/postprocessors/mobilefacenet_post.cpp
View file @
d72c8f44
...
...
@@ -5,8 +5,8 @@ namespace deepinfer {
namespace
postprocess
{
bool
MobileFaceNetPostProcess
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
bool
MobileFaceNetPostProcess
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
{
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init mobilefacenet postprocess error"
;
return
false
;
};
...
...
@@ -24,7 +24,7 @@ bool MobileFaceNetPostProcess::Exec(){
return
false
;
}
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
inputNames
[
0
]));
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
pMap
->
GetIOPtr
(
inputNames
[
0
]));
if
(
input
==
nullptr
){
LOG_ERROR
<<
"mobilefacenet postprocess input "
<<
inputNames
[
0
]
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -33,7 +33,7 @@ bool MobileFaceNetPostProcess::Exec(){
std
::
vector
<
base
::
Image8UPtr
>
inputImages
;
for
(
int
j
=
1
;
j
<
inputNames
.
size
();
j
++
){
auto
iName
=
inputNames
[
j
];
auto
iptr
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
interfaces
::
GetIOPtr
(
iName
));
auto
iptr
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
pMap
->
GetIOPtr
(
iName
));
if
(
iptr
==
nullptr
){
LOG_ERROR
<<
"mobilefacenet postprocess input "
<<
iName
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -58,7 +58,7 @@ bool MobileFaceNetPostProcess::Exec(){
lptr
->
y
=
points
[
l
*
2
+
1
]
*
inputHeight
/
scaley
;
face_landmarks
->
landmarks
.
push_back
(
lptr
);
}
interfaces
::
SetIOPtr
(
outputNames
[
b
],
face_landmarks
);
pMap
->
SetIOPtr
(
outputNames
[
b
],
face_landmarks
);
}
return
true
;
...
...
src/libs/postprocessors/mobilefacenet_post.h
View file @
d72c8f44
...
...
@@ -17,7 +17,7 @@ namespace postprocess {
class
MobileFaceNetPostProcess
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
...
...
src/libs/postprocessors/multi_post.cpp
View file @
d72c8f44
...
...
@@ -5,8 +5,8 @@ namespace deepinfer {
namespace
postprocess
{
bool
MultiPostProcess
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
bool
MultiPostProcess
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
{
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init multitask postprocess error"
;
return
false
;
};
...
...
@@ -44,27 +44,27 @@ bool MultiPostProcess::Init(YAML::Node& node) {
bool
MultiPostProcess
::
Exec
()
{
auto
rawDetections
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
inputNames
[
0
]));
auto
rawDetections
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
pMap
->
GetIOPtr
(
inputNames
[
0
]));
if
(
rawDetections
==
nullptr
){
LOG_ERROR
<<
"multitask postprocess input "
<<
inputNames
[
0
]
<<
" haven't been init or doesn't exist."
;
return
false
;
}
auto
segProtos
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
inputNames
[
1
]));
auto
segProtos
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
pMap
->
GetIOPtr
(
inputNames
[
1
]));
if
(
segProtos
==
nullptr
){
LOG_ERROR
<<
"multitask postprocess input "
<<
inputNames
[
1
]
<<
" haven't been init or doesn't exist."
;
return
false
;
}
auto
rawDepths
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
inputNames
[
2
]));
auto
rawDepths
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
pMap
->
GetIOPtr
(
inputNames
[
2
]));
if
(
rawDepths
==
nullptr
){
LOG_ERROR
<<
"multitask postprocess input "
<<
inputNames
[
2
]
<<
" haven't been init or doesn't exist."
;
return
false
;
}
auto
rawSemantics
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
inputNames
[
3
]));
auto
rawSemantics
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
pMap
->
GetIOPtr
(
inputNames
[
3
]));
if
(
rawSemantics
==
nullptr
){
LOG_ERROR
<<
"multitask postprocess input "
<<
inputNames
[
3
]
<<
" haven't been init or doesn't exist."
;
return
false
;
}
auto
inputImage
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
interfaces
::
GetIOPtr
(
inputNames
[
4
]));
auto
inputImage
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
pMap
->
GetIOPtr
(
inputNames
[
4
]));
if
(
inputImage
==
nullptr
){
LOG_ERROR
<<
"multitask postprocess input "
<<
inputNames
[
4
]
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -168,7 +168,7 @@ bool MultiPostProcess::Exec() {
);
// LOG_INFO << x1 << " " << x2 << " " << y1 << " " << y2 <<", " << det->mask_ptr->rle_string;
}
interfaces
::
SetIOPtr
(
outputNames
[
0
],
dets
);
pMap
->
SetIOPtr
(
outputNames
[
0
],
dets
);
// Semantic Mask
auto
semantics
=
std
::
make_shared
<
ios
::
Semantics
>
();
...
...
@@ -200,7 +200,7 @@ bool MultiPostProcess::Exec() {
// LOG_INFO << seg->mask_ptr->rle_string;
semantics
->
semantic_segs
.
push_back
(
seg
);
}
interfaces
::
SetIOPtr
(
outputNames
[
1
],
semantics
);
pMap
->
SetIOPtr
(
outputNames
[
1
],
semantics
);
// Depth
auto
depth
=
std
::
make_shared
<
ios
::
Depth
>
();
...
...
@@ -223,7 +223,7 @@ bool MultiPostProcess::Exec() {
// cv::resize(mask_mat, mask_res, cv::Size(img_width, img_height));
// }
depth
->
depth
=
mask_mat
;
interfaces
::
SetIOPtr
(
outputNames
[
2
],
depth
);
pMap
->
SetIOPtr
(
outputNames
[
2
],
depth
);
return
true
;
...
...
src/libs/postprocessors/multi_post.h
View file @
d72c8f44
...
...
@@ -21,7 +21,7 @@ namespace postprocess {
class
MultiPostProcess
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
...
...
src/libs/postprocessors/trades_post.cpp
View file @
d72c8f44
...
...
@@ -5,8 +5,8 @@ namespace deepinfer {
namespace
postprocess
{
bool
TraDesPostProcess
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
bool
TraDesPostProcess
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
{
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init trades postprocess error"
;
return
false
;
};
...
...
@@ -45,7 +45,7 @@ bool TraDesPostProcess::Exec() {
std
::
vector
<
base
::
BlobPtr
<
float
>>
inputs
;
for
(
int
i
=
0
;
i
<
5
;
i
++
){
auto
iName
=
inputNames
[
i
];
auto
p
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
iName
));
auto
p
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
pMap
->
GetIOPtr
(
iName
));
if
(
p
==
nullptr
){
LOG_ERROR
<<
"TraDeS postprocess input "
<<
iName
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -56,7 +56,7 @@ bool TraDesPostProcess::Exec() {
std
::
vector
<
base
::
Image8UPtr
>
inputImages
;
for
(
int
j
=
5
;
j
<
inputNames
.
size
();
j
++
){
auto
iName
=
inputNames
[
j
];
auto
iptr
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
interfaces
::
GetIOPtr
(
iName
));
auto
iptr
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
pMap
->
GetIOPtr
(
iName
));
if
(
iptr
==
nullptr
){
LOG_ERROR
<<
"TraDeS postprocess input image "
<<
iName
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -123,7 +123,7 @@ bool TraDesPostProcess::Exec() {
));
dets
->
detections
.
push_back
(
obj
);
}
interfaces
::
SetIOPtr
(
outName
,
dets
);
pMap
->
SetIOPtr
(
outName
,
dets
);
}
return
true
;
...
...
src/libs/postprocessors/trades_post.h
View file @
d72c8f44
...
...
@@ -18,7 +18,7 @@ namespace postprocess {
class
TraDesPostProcess
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
...
...
src/libs/postprocessors/whenet_post.cpp
View file @
d72c8f44
...
...
@@ -5,8 +5,8 @@ namespace deepinfer {
namespace
postprocess
{
bool
WHENetPostProcess
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
bool
WHENetPostProcess
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
{
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init WHENet postprocess error"
;
return
false
;
};
...
...
@@ -21,7 +21,7 @@ bool WHENetPostProcess::Exec(){
std
::
vector
<
base
::
BlobPtr
<
float
>>
inputs
;
// model outputs
for
(
int
i
=
0
;
i
<
inputNames
.
size
();
i
++
){
auto
inputName
=
inputNames
[
i
];
auto
ptr
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
inputName
));
auto
ptr
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
pMap
->
GetIOPtr
(
inputName
));
if
(
ptr
==
nullptr
){
LOG_ERROR
<<
"WHENet postprocess input "
<<
inputName
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -36,7 +36,7 @@ bool WHENetPostProcess::Exec(){
for
(
int
b
=
0
;
b
<
outputNames
.
size
();
b
++
){
auto
headpose
=
std
::
make_shared
<
ios
::
HeadPose
>
();
interfaces
::
SetIOPtr
(
outputNames
[
b
],
headpose
);
pMap
->
SetIOPtr
(
outputNames
[
b
],
headpose
);
float
yawSum
=
0
,
pitchSum
=
0
,
rollSum
=
0
;
// yaw
...
...
src/libs/postprocessors/whenet_post.h
View file @
d72c8f44
...
...
@@ -17,7 +17,7 @@ namespace postprocess {
class
WHENetPostProcess
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
...
...
src/libs/postprocessors/yolov5_post.cpp
View file @
d72c8f44
...
...
@@ -5,8 +5,8 @@ namespace deepinfer {
namespace
postprocess
{
bool
YoloV5PostProcess
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
bool
YoloV5PostProcess
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
{
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init yolov5 postprocess error"
;
return
false
;
};
...
...
@@ -29,7 +29,7 @@ bool YoloV5PostProcess::Exec(){
std
::
vector
<
base
::
BlobPtr
<
float
>>
inputs
;
// model outputs
for
(
int
i
=
0
;
i
<
4
;
i
++
){
auto
inputName
=
inputNames
[
i
];
auto
ptr
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
inputName
));
auto
ptr
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
pMap
->
GetIOPtr
(
inputName
));
if
(
ptr
==
nullptr
){
LOG_ERROR
<<
"YoloV5 postprocess input "
<<
inputName
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -40,7 +40,7 @@ bool YoloV5PostProcess::Exec(){
std
::
vector
<
base
::
Image8UPtr
>
inputImages
;
for
(
int
j
=
4
;
j
<
inputNames
.
size
();
j
++
){
auto
iName
=
inputNames
[
j
];
auto
iptr
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
interfaces
::
GetIOPtr
(
iName
));
auto
iptr
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
pMap
->
GetIOPtr
(
iName
));
if
(
iptr
==
nullptr
){
LOG_ERROR
<<
"YoloV5 postprocess input "
<<
iName
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
@@ -86,7 +86,7 @@ bool YoloV5PostProcess::Exec(){
}
dets
->
detections
.
push_back
(
obj
);
}
interfaces
::
SetIOPtr
(
outName
,
dets
);
pMap
->
SetIOPtr
(
outName
,
dets
);
}
return
true
;
}
...
...
src/libs/postprocessors/yolov5_post.h
View file @
d72c8f44
...
...
@@ -17,7 +17,7 @@ namespace postprocess {
class
YoloV5PostProcess
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
...
...
src/libs/preprocessors/resize_norm.cpp
View file @
d72c8f44
...
...
@@ -6,9 +6,9 @@ namespace deepinfer {
namespace
preprocess
{
bool
ResizeNorm
::
Init
(
YAML
::
Node
&
node
){
bool
ResizeNorm
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
){
// CUDA_CHECK(cudaStreamCreate(&stream_));
if
(
!
BaseUnit
::
Init
(
node
)){
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init resize_norm error"
;
return
false
;
};
...
...
@@ -28,7 +28,7 @@ bool ResizeNorm::Init(YAML::Node& node){
dst
.
reset
(
new
base
::
Blob
<
float
>
({
inferBatchSize
,
3
,
inputHeight
,
inputWidth
}));
auto
dst_ptr
=
std
::
make_shared
<
ios
::
NormalIO
>
(
dst
);
interfaces
::
SetIOPtr
(
outputNames
[
0
],
dst_ptr
);
pMap
->
SetIOPtr
(
outputNames
[
0
],
dst_ptr
);
mean
.
reset
(
new
base
::
Blob
<
float
>
({
3
,
1
},
inputMean
.
data
()));
mean
->
mutable_gpu_data
();
...
...
@@ -41,7 +41,7 @@ bool ResizeNorm::Init(YAML::Node& node){
bool
ResizeNorm
::
Exec
(){
for
(
int
b
=
0
;
b
<
inputNames
.
size
();
b
++
){
auto
inputName
=
inputNames
[
b
];
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
interfaces
::
GetIOPtr
(
inputName
));
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
pMap
->
GetIOPtr
(
inputName
));
if
(
input
==
nullptr
){
LOG_ERROR
<<
"resize norm input"
<<
inputName
<<
" haven't init"
;
return
false
;
...
...
src/libs/preprocessors/resize_norm.h
View file @
d72c8f44
...
...
@@ -18,7 +18,7 @@ namespace preprocess {
class
ResizeNorm
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
...
...
src/libs/preprocessors/undistort.cpp
View file @
d72c8f44
...
...
@@ -5,8 +5,8 @@ namespace deepinfer {
namespace
preprocess
{
bool
Undistort
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
bool
Undistort
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
{
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init trades postprocess error"
;
return
false
;
};
...
...
@@ -34,7 +34,7 @@ bool Undistort::Init(YAML::Node& node) {
dst_img
=
std
::
make_shared
<
base
::
Image8U
>
(
dst_height_
,
dst_width_
,
base
::
Color
::
BGR
);
auto
output
=
std
::
make_shared
<
ios
::
CameraSrcOut
>
(
dst_img
);
interfaces
::
SetIOPtr
(
outputNames
[
0
],
output
);
pMap
->
SetIOPtr
(
outputNames
[
0
],
output
);
inited_
=
true
;
return
true
;
}
...
...
@@ -162,7 +162,7 @@ void Undistort::InitUndistortRectifyMap(
bool
Undistort
::
Exec
(){
auto
iptr
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
interfaces
::
GetIOPtr
(
inputNames
[
0
]));
auto
iptr
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
pMap
->
GetIOPtr
(
inputNames
[
0
]));
if
(
iptr
==
nullptr
){
LOG_ERROR
<<
"Undistort input "
<<
inputNames
[
0
]
<<
" haven't been init or doesn't exist."
;
return
false
;
...
...
src/libs/preprocessors/undistort.h
View file @
d72c8f44
...
...
@@ -22,7 +22,7 @@ namespace preprocess {
class
Undistort
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
...
...
src/libs/sources/camera_src.cpp
View file @
d72c8f44
...
...
@@ -8,7 +8,7 @@ namespace sources {
bool
CameraSrc
::
Exec
(){
auto
src_input
=
interfaces
::
GetIOPtr
(
inputNames
[
0
]);
auto
src_input
=
pMap
->
GetIOPtr
(
inputNames
[
0
]);
if
(
src_input
==
nullptr
){
LOG_ERROR
<<
"CameraSrc input"
<<
inputNames
[
0
]
<<
" haven't init"
;
return
false
;
...
...
@@ -16,7 +16,7 @@ bool CameraSrc::Exec(){
auto
src
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcIn
>
(
src_input
);
auto
img
=
std
::
make_shared
<
base
::
Image8U
>
(
src
->
cv_img_
);
auto
dst
=
std
::
make_shared
<
ios
::
CameraSrcOut
>
(
img
);
interfaces
::
SetIOPtr
(
outputNames
[
0
],
dst
);
pMap
->
SetIOPtr
(
outputNames
[
0
],
dst
);
return
true
;
}
...
...
src/libs/trackers/byte_tracker.cpp
View file @
d72c8f44
...
...
@@ -7,9 +7,9 @@ namespace tracker{
bool
ByteTracker
::
Init
(
YAML
::
Node
&
node
)
bool
ByteTracker
::
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
if
(
!
BaseUnit
::
Init
(
node
,
pmap
)){
LOG_WARN
<<
"Init ByteTracker error"
;
return
false
;
};
...
...
@@ -31,7 +31,7 @@ bool ByteTracker::Init(YAML::Node& node)
bool
ByteTracker
::
Exec
()
{
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
interfaces
::
GetIOPtr
(
inputNames
[
0
]));
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
pMap
->
GetIOPtr
(
inputNames
[
0
]));
if
(
input
==
nullptr
){
LOG_ERROR
<<
"ByteTracker input "
<<
inputNames
[
0
]
<<
" haven't init"
;
return
false
;
...
...
@@ -263,7 +263,7 @@ bool ByteTracker::Exec()
}
}
// }
interfaces
::
SetIOPtr
(
outputNames
[
0
],
tracked_bboxes
);
pMap
->
SetIOPtr
(
outputNames
[
0
],
tracked_bboxes
);
LOG_INFO
<<
"Get "
<<
tracked_bboxes
->
detections
.
size
()
<<
" tracked objs. Removed track length: "
<<
this
->
removed_tracks
.
size
();
return
true
;
}
...
...
src/libs/trackers/byte_tracker.h
View file @
d72c8f44
...
...
@@ -18,7 +18,7 @@ class ByteTracker: public interfaces::BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Init
(
YAML
::
Node
&
node
,
interfaces
::
BaseIOMapPtr
pmap
)
override
;
bool
Exec
()
override
;
std
::
string
Name
()
override
;
...
...
src/models/camera_model.cpp
View file @
d72c8f44
...
...
@@ -20,6 +20,8 @@ bool CameraModel::Init(std::string& configPath) {
inputNames
=
modelConfigNode
[
"inputNames"
].
as
<
std
::
vector
<
std
::
string
>>
();
outputNames
=
modelConfigNode
[
"outputNames"
].
as
<
std
::
vector
<
std
::
string
>>
();
modelUnitMap
=
std
::
make_shared
<
interfaces
::
BaseIOMap
>
();
// units
auto
unitNodes
=
modelConfigNode
[
"units"
];
for
(
int
i
=
0
;
i
<
unitNodes
.
size
();
i
++
){
...
...
@@ -28,7 +30,7 @@ bool CameraModel::Init(std::string& configPath) {
LOG_INFO
<<
"Init CameraModel unit: "
<<
unitName
;
interfaces
::
BaseUnitPtr
unitPtr
;
unitPtr
.
reset
(
interfaces
::
BaseUnitRegisterer
::
GetInstanceByName
(
unitName
));
if
(
!
unitPtr
->
Init
(
unitNode
)){
if
(
!
unitPtr
->
Init
(
unitNode
,
modelUnitMap
)){
LOG_WARN
<<
"Init CameraModel unit "
<<
unitName
<<
" failed!"
;
return
false
;
};
...
...
@@ -45,7 +47,7 @@ bool CameraModel::Exec(std::vector<cv::Mat*> inputs, std::vector<interfaces::Bas
auto
inputName
=
inputNames
[
i
];
LOG_INFO
<<
"CameraModel input: "
<<
inputName
;
auto
input
=
std
::
make_shared
<
ios
::
CameraSrcIn
>
(
input_img
);
interfaces
::
SetIOPtr
(
inputName
,
input
);
modelUnitMap
->
SetIOPtr
(
inputName
,
input
);
}
// infer
for
(
auto
&
unit
:
units_
){
...
...
@@ -59,7 +61,7 @@ bool CameraModel::Exec(std::vector<cv::Mat*> inputs, std::vector<interfaces::Bas
// output
for
(
auto
outName
:
outputNames
){
LOG_INFO
<<
"CameraModel output: "
<<
outName
;
outputs
.
push_back
(
interfaces
::
GetIOPtr
(
outName
));
outputs
.
push_back
(
modelUnitMap
->
GetIOPtr
(
outName
));
}
return
true
;
...
...
@@ -72,7 +74,7 @@ bool CameraModel::Exec(std::vector<base::Image8UPtr> inputs, std::vector<interfa
auto
input_img
=
inputs
[
i
];
auto
inputName
=
inputNames
[
i
];
auto
input
=
std
::
make_shared
<
ios
::
CameraSrcOut
>
(
input_img
);
interfaces
::
SetIOPtr
(
inputName
,
input
);
modelUnitMap
->
SetIOPtr
(
inputName
,
input
);
}
// infer
...
...
@@ -86,7 +88,7 @@ bool CameraModel::Exec(std::vector<base::Image8UPtr> inputs, std::vector<interfa
// output
for
(
auto
outName
:
outputNames
){
outputs
.
push_back
(
interfaces
::
GetIOPtr
(
outName
));
outputs
.
push_back
(
modelUnitMap
->
GetIOPtr
(
outName
));
}
return
true
;
}
...
...
src/tasks/task_fusion.cpp
View file @
d72c8f44
...
...
@@ -34,9 +34,13 @@ bool TaskFusion::Exec(std::vector<cv::Mat*> inputs, std::vector<interfaces::Base
void
TaskFusion
::
Visualize
(
cv
::
Mat
*
image
,
interfaces
::
BaseIOPtr
outs
){
auto
mainSrc
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
interfaces
::
GetIOPtr
(
mainSrcName
));
}
void
TaskFusion
::
Visualize
(
cv
::
Mat
*
image
,
std
::
vector
<
interfaces
::
BaseIOPtr
>&
outputs
){
auto
mainSrc
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
outputs
[
outputs
.
size
()
-
1
]);;
auto
mainImage
=
mainSrc
->
img_ptr_
->
toCVMat
();
auto
detections
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
out
s
)
->
detections
;
auto
detections
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
out
puts
[
0
]
)
->
detections
;
cv
::
Mat
realInstanceMask
,
colorInstance
;
for
(
auto
&
obj
:
detections
){
cv
::
Scalar
color
=
get_color
(
obj
->
class_label
*
100
+
obj
->
track_id
);
...
...
src/tasks/task_fusion.h
View file @
d72c8f44
...
...
@@ -21,6 +21,7 @@ public:
bool
Exec
(
std
::
vector
<
cv
::
Mat
*>
inputs
,
std
::
vector
<
interfaces
::
BaseIOPtr
>&
outputs
)
override
;
void
Visualize
(
cv
::
Mat
*
image
,
interfaces
::
BaseIOPtr
outs
)
override
;
void
Visualize
(
cv
::
Mat
*
image
,
std
::
vector
<
interfaces
::
BaseIOPtr
>&
outputs
);
std
::
string
Name
()
override
;
public
:
...
...
test/t_b1_res.jpg
View replaced file @
8da6ff45
View file @
d72c8f44
27.8 KB
|
W:
|
H:
27.8 KB
|
W:
|
H:
2-up
Swipe
Onion skin
test/t_b2_res.jpg
View replaced file @
8da6ff45
View file @
d72c8f44
27.8 KB
|
W:
|
H:
27.8 KB
|
W:
|
H:
2-up
Swipe
Onion skin
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