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
9461f84c
Commit
9461f84c
authored
Sep 22, 2022
by
xin.wang.waytous
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
all tasks done
parent
8b083a9d
Hide whitespace changes
Inline
Side-by-side
Showing
49 changed files
with
1238 additions
and
230 deletions
+1238
-230
bsw.yaml
configs/tasks/bsw/bsw.yaml
+14
-0
left_camera_dist_v2.yaml
configs/tasks/bsw/left_camera_dist_v2.yaml
+423
-0
rgb_yolov5.yaml
configs/tasks/bsw/rgb_yolov5.yaml
+72
-0
warning_infos.yaml
configs/tasks/bsw/warning_infos.yaml
+22
-0
dms.yaml
configs/tasks/dms/dms.yaml
+27
-0
face_detect_yolov5.yaml
configs/tasks/dms/face_detect_yolov5.yaml
+67
-0
face_headpose_whenet.yaml
configs/tasks/dms/face_headpose_whenet.yaml
+44
-0
face_landmarks_mobilefacenet.yaml
configs/tasks/dms/face_landmarks_mobilefacenet.yaml
+50
-0
fusion.yaml
configs/tasks/fusion/fusion.yaml
+11
-0
fusion_model.yaml
configs/tasks/fusion/fusion_model.yaml
+152
-0
rgb_intrinsic.yaml
configs/tasks/fusion/rgb_intrinsic.yaml
+26
-0
thermal_homography.yaml
configs/tasks/fusion/thermal_homography.yaml
+10
-0
thermal_intrinsic.yaml
configs/tasks/fusion/thermal_intrinsic.yaml
+31
-0
trades.yaml
configs/tasks/mots/trades.yaml
+14
-7
yolov5.yaml
configs/tasks/thermal/yolov5.yaml
+12
-6
main.cpp
main.cpp
+27
-5
image.h
src/base/image.h
+3
-0
common.h
src/common/common.h
+1
-1
base_model.h
src/interfaces/base_model.h
+1
-0
base_unit.cpp
src/interfaces/base_unit.cpp
+1
-5
base_unit.h
src/interfaces/base_unit.h
+1
-5
bayesian_fusioner.cpp
src/libs/fusioner/bayesian_fusioner.cpp
+11
-4
bayesian_fusioner.h
src/libs/fusioner/bayesian_fusioner.h
+1
-1
trt_infer.cpp
src/libs/inferences/tensorrt/trt_infer.cpp
+5
-2
trt_infer.h
src/libs/inferences/tensorrt/trt_infer.h
+3
-1
homo_project.cpp
src/libs/postprocessors/homo_project.cpp
+19
-7
homo_project.h
src/libs/postprocessors/homo_project.h
+2
-1
mobilefacenet_post.cpp
src/libs/postprocessors/mobilefacenet_post.cpp
+9
-6
mobilefacenet_post.h
src/libs/postprocessors/mobilefacenet_post.h
+3
-1
trades_post.cpp
src/libs/postprocessors/trades_post.cpp
+7
-3
trades_post.h
src/libs/postprocessors/trades_post.h
+4
-1
whenet_post.cpp
src/libs/postprocessors/whenet_post.cpp
+32
-30
whenet_post.h
src/libs/postprocessors/whenet_post.h
+1
-1
yolov5_post.cpp
src/libs/postprocessors/yolov5_post.cpp
+6
-3
yolov5_post.h
src/libs/postprocessors/yolov5_post.h
+3
-1
resize_norm.cpp
src/libs/preprocessors/resize_norm.cpp
+7
-2
resize_norm.h
src/libs/preprocessors/resize_norm.h
+6
-3
undistort.cpp
src/libs/preprocessors/undistort.cpp
+5
-68
undistort.h
src/libs/preprocessors/undistort.h
+2
-6
byte_tracker.cpp
src/libs/trackers/byte_tracker.cpp
+6
-7
byte_tracker.h
src/libs/trackers/byte_tracker.h
+1
-1
camera_model.cpp
src/models/camera_model.cpp
+17
-13
camera_model.h
src/models/camera_model.h
+0
-1
task_bsw.cpp
src/tasks/task_bsw.cpp
+12
-11
task_bsw.h
src/tasks/task_bsw.h
+1
-0
task_dms.cpp
src/tasks/task_dms.cpp
+9
-9
task_fusion.cpp
src/tasks/task_fusion.cpp
+50
-15
task_fusion.h
src/tasks/task_fusion.h
+4
-0
task_mots.cpp
src/tasks/task_mots.cpp
+3
-3
No files found.
configs/tasks/bsw/bsw.yaml
0 → 100644
View file @
9461f84c
configRootPath
:
/home/wangxin/projects/waytous/DeepInfer
device
:
2
detectorName
:
CameraModel
detectorConfigPath
:
configs/tasks/bsw/rgb_yolov5.yaml
imageWidth
:
1920
imageHeight
:
1080
useFullPolygan
:
true
warningDistancePoolsPath
:
configs/tasks/bsw/left_camera_dist_v2.yaml
warningRangeConfigPath
:
configs/tasks/bsw/warning_infos.yaml
configs/tasks/bsw/left_camera_dist_v2.yaml
0 → 100644
View file @
9461f84c
dist_100
:
-
-
7
-
992
-
-
53
-
972
-
-
102
-
959
-
-
152
-
958
-
-
204
-
961
-
-
255
-
967
-
-
305
-
972
-
-
357
-
977
-
-
407
-
982
-
-
459
-
986
-
-
512
-
990
-
-
563
-
992
-
-
615
-
996
-
-
665
-
997
-
-
715
-
999
-
-
765
-
1000
-
-
817
-
1001
-
-
869
-
1001
-
-
920
-
1002
-
-
972
-
1002
-
-
1024
-
1001
-
-
1075
-
1000
-
-
1126
-
999
-
-
1176
-
997
-
-
1227
-
995
-
-
1280
-
992
-
-
1331
-
989
-
-
1382
-
986
-
-
1432
-
982
-
-
1482
-
980
-
-
1533
-
983
-
-
1583
-
994
-
-
1633
-
1015
-
-
1677
-
1041
-
-
1717
-
1080
-
-
0
-
1080
-
-
0
-
992
dist_200
:
-
-
7
-
750
-
-
56
-
734
-
-
108
-
722
-
-
158
-
717
-
-
208
-
717
-
-
260
-
718
-
-
311
-
721
-
-
361
-
723
-
-
413
-
724
-
-
463
-
726
-
-
515
-
728
-
-
565
-
729
-
-
615
-
730
-
-
667
-
731
-
-
719
-
732
-
-
769
-
733
-
-
819
-
732
-
-
869
-
733
-
-
919
-
733
-
-
970
-
733
-
-
1023
-
733
-
-
1076
-
732
-
-
1129
-
731
-
-
1181
-
731
-
-
1233
-
730
-
-
1284
-
728
-
-
1334
-
727
-
-
1384
-
725
-
-
1436
-
726
-
-
1487
-
729
-
-
1538
-
733
-
-
1588
-
742
-
-
1639
-
759
-
-
1689
-
776
-
-
1737
-
798
-
-
1783
-
824
-
-
1827
-
855
-
-
1866
-
888
-
-
1903
-
925
-
-
1920
-
925
-
-
1920
-
1080
-
-
0
-
1080
-
-
0
-
750
dist_300
:
-
-
4
-
556
-
-
53
-
539
-
-
103
-
527
-
-
153
-
518
-
-
205
-
511
-
-
256
-
509
-
-
308
-
507
-
-
358
-
507
-
-
409
-
507
-
-
460
-
507
-
-
510
-
507
-
-
560
-
507
-
-
611
-
507
-
-
663
-
507
-
-
713
-
507
-
-
763
-
507
-
-
814
-
507
-
-
865
-
507
-
-
916
-
507
-
-
967
-
507
-
-
1018
-
507
-
-
1069
-
507
-
-
1120
-
507
-
-
1170
-
507
-
-
1220
-
507
-
-
1272
-
507
-
-
1323
-
507
-
-
1374
-
509
-
-
1424
-
511
-
-
1476
-
514
-
-
1527
-
522
-
-
1579
-
532
-
-
1628
-
543
-
-
1676
-
558
-
-
1726
-
576
-
-
1775
-
597
-
-
1820
-
619
-
-
1863
-
645
-
-
1905
-
673
-
-
1920
-
673
-
-
1920
-
1080
-
-
0
-
1080
-
-
0
-
556
dist_400
:
-
-
5
-
396
-
-
53
-
380
-
-
101
-
366
-
-
152
-
355
-
-
202
-
345
-
-
252
-
338
-
-
303
-
335
-
-
354
-
331
-
-
404
-
330
-
-
454
-
329
-
-
505
-
327
-
-
555
-
326
-
-
606
-
325
-
-
656
-
324
-
-
706
-
324
-
-
756
-
324
-
-
807
-
323
-
-
858
-
323
-
-
910
-
323
-
-
961
-
323
-
-
1012
-
323
-
-
1063
-
323
-
-
1114
-
324
-
-
1164
-
324
-
-
1214
-
325
-
-
1264
-
326
-
-
1315
-
327
-
-
1366
-
329
-
-
1416
-
334
-
-
1466
-
338
-
-
1519
-
348
-
-
1570
-
357
-
-
1619
-
369
-
-
1669
-
385
-
-
1718
-
400
-
-
1766
-
419
-
-
1814
-
440
-
-
1859
-
462
-
-
1904
-
488
-
-
1920
-
488
-
-
1920
-
1080
-
-
0
-
1080
-
-
0
-
396
dist_500
:
-
-
5
-
267
-
-
54
-
251
-
-
103
-
235
-
-
153
-
222
-
-
203
-
211
-
-
254
-
202
-
-
304
-
195
-
-
354
-
190
-
-
405
-
186
-
-
456
-
184
-
-
507
-
181
-
-
557
-
179
-
-
608
-
177
-
-
659
-
177
-
-
709
-
175
-
-
759
-
174
-
-
809
-
173
-
-
860
-
174
-
-
912
-
173
-
-
962
-
173
-
-
1012
-
173
-
-
1062
-
174
-
-
1113
-
175
-
-
1164
-
176
-
-
1216
-
177
-
-
1267
-
179
-
-
1318
-
182
-
-
1368
-
185
-
-
1419
-
191
-
-
1470
-
198
-
-
1521
-
207
-
-
1571
-
218
-
-
1620
-
230
-
-
1670
-
245
-
-
1718
-
261
-
-
1766
-
280
-
-
1814
-
299
-
-
1860
-
322
-
-
1906
-
346
-
-
1920
-
346
-
-
1920
-
1080
-
-
0
-
1080
-
-
0
-
267
configs/tasks/bsw/rgb_yolov5.yaml
0 → 100644
View file @
9461f84c
name
:
CameraModel
inputNames
:
[
cvImage
]
outputNames
:
[
trackedDetections
]
units
:
-
name
:
CameraSrc
inputNames
:
[
cvImage
]
outputNames
:
[
uint8Image
]
-
name
:
ResizeNorm
inputNames
:
[
uint8Image
]
outputNames
:
[
resizeNormImages
]
inputMean
:
[
0
,
0
,
0
]
inputStd
:
[
1
,
1
,
1
]
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
640
fixAspectRatio
:
true
useBGR
:
false
-
name
:
YoloV5TRTInference
inputNames
:
[
resizeNormImages
]
outputNames
:
[
num_detections
,
nmsed_boxes
,
nmsed_scores
,
nmsed_classes
]
runMode
:
1
# 0-fp32 1-fp16 2-int8 (int8 not supported)
weightsPath
:
"
configs/tasks/bsw/yolov5s_rgb.wts"
engineFile
:
"
configs/tasks/bsw/yolov5s_rgb_fp16.engine"
# calibImgPathFile: "configs/tasks/bsw/yolov5s_rgb_calib_imgs.txt"
# calibTableCache: "configs/tasks/bsw/yolov5s_rgb_calib_table.cache"
inferDynamic
:
true
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
640
maxBatchSize
:
4
# used when build engine
classNumber
:
2
numAnchorsPerLevel
:
3
numLevels
:
3
startScale
:
8
maxOutputBBoxCount
:
1000
keepTopK
:
100
# used when build engine, always be smaller than scoreThreshold.
# if you want it to take effect, you should delete the ${engineFile}
engineScoreThreshold
:
0.1
nmsThreshold
:
0.45
# yolov5
# n: 0.33+0.25 s: 0.33+0.5 m: 0.67+0.75 l: 1.0+1.0 x: 1.33+1.25
gd
:
0.33
gw
:
0.5
-
name
:
YoloV5PostProcess
inputNames
:
[
num_detections
,
nmsed_boxes
,
nmsed_scores
,
nmsed_classes
,
uint8Image
]
outputNames
:
[
detections
]
inputWidth
:
640
inputHeight
:
640
fixAspectRatio
:
true
scoreThreshold
:
0.2
# used when inference, can be modified
truncatedThreshold
:
0.05
keepTopK
:
100
classNames
:
[
vehicle
,
person
]
-
name
:
ByteTracker
inputNames
:
[
detections
]
outputNames
:
[
trackedDetections
]
frame_rate
:
20
track_buffer
:
30
track_thresh
:
0.2
high_thresh
:
0.2
match_thresh
:
0.8
init_frames
:
0
configs/tasks/bsw/warning_infos.yaml
0 → 100644
View file @
9461f84c
# 范围按照严重程度依次递增,即距离相机逐渐变近,默认情况为三个等级-green/yellow/red,green为无正常无警告
warningInfos
:
-
name
:
Green
color
:
[
0
,
255
,
0
]
# bgr format - green
warningFrameThreshold
:
0
distance
:
-1
# m, -1 means inf
-
name
:
Yellow
color
:
[
0
,
255
,
255
]
# bgr format - yellow
warningFrameThreshold
:
3
distance
:
2
# m
-
name
:
Red
color
:
[
0
,
0
,
255
]
# bgr format - red
warningFrameThreshold
:
3
distance
:
1
# m
configs/tasks/dms/dms.yaml
0 → 100644
View file @
9461f84c
configRootPath
:
/home/wangxin/projects/waytous/DeepInfer
device
:
2
faceDetectorName
:
CameraModel
faceDetectorConfigPath
:
configs/tasks/dms/face_detect_yolov5.yaml
landmarkDetectorName
:
CameraModel
landmarkDetectorConfigPath
:
configs/tasks/dms/face_landmarks_mobilefacenet.yaml
headposeDetectorName
:
CameraModel
headposeDetectorConfigPath
:
configs/tasks/dms/face_headpose_whenet.yaml
mouthARThreshold
:
0.75
eyeARThreshold
:
0.25
eyeARConsecFrames
:
15
distractionConsecFrames
:
1
unmaskedConsecFrames
:
20
nodriverConsecFrames
:
20
sightYawThresholdLeft
:
-40
sightYawThresholdRight
:
40
sightPitchThresholdLeft
:
-40
sightPitchThresholdRight
:
40
configs/tasks/dms/face_detect_yolov5.yaml
0 → 100644
View file @
9461f84c
name
:
CameraModel
inputNames
:
[
cvImage
]
outputNames
:
[
detections
]
units
:
-
name
:
CameraSrc
inputNames
:
[
cvImage
]
outputNames
:
[
uint8Image
]
-
name
:
ResizeNorm
inputNames
:
[
uint8Image
]
outputNames
:
[
resizeNormImages
]
inputMean
:
[
0
,
0
,
0
]
inputStd
:
[
1
,
1
,
1
]
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
640
fixAspectRatio
:
true
useBGR
:
false
-
name
:
YoloV5TRTInference
inputNames
:
[
resizeNormImages
]
outputNames
:
[
num_detections
,
nmsed_boxes
,
nmsed_scores
,
nmsed_classes
]
runMode
:
1
# 0-fp32 1-fp16 2-int8 (int8 not supported)
weightsPath
:
"
configs/tasks/dms/yolov5s_face.wts"
engineFile
:
"
configs/tasks/dms/yolov5s_face_fp16.engine"
# calibImgPathFile: "configs/tasks/dms/yolov5s_calib_imgs.txt"
# calibTableCache: "configs/tasks/dms/yolov5s_calib_table.cache"
inferDynamic
:
true
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
640
maxBatchSize
:
1
# used when build engine
classNumber
:
2
numAnchorsPerLevel
:
3
numLevels
:
3
startScale
:
8
maxOutputBBoxCount
:
1000
keepTopK
:
100
# used when build engine, always be smaller than scoreThreshold.
# if you want it to take effect, you should delete the ${engineFile}
engineScoreThreshold
:
0.1
nmsThreshold
:
0.45
# yolov5
# n: 0.33+0.25 s: 0.33+0.5 m: 0.67+0.75 l: 1.0+1.0 x: 1.33+1.25
gd
:
0.33
gw
:
0.5
-
name
:
YoloV5PostProcess
inputNames
:
[
num_detections
,
nmsed_boxes
,
nmsed_scores
,
nmsed_classes
,
uint8Image
]
outputNames
:
[
detections
]
inputWidth
:
640
inputHeight
:
640
fixAspectRatio
:
true
scoreThreshold
:
0.2
# used when inference, can be modified
truncatedThreshold
:
0.05
keepTopK
:
100
classNames
:
[
"
unmasked
face"
,
"
masked
face"
]
configs/tasks/dms/face_headpose_whenet.yaml
0 → 100644
View file @
9461f84c
name
:
CameraModel
inputNames
:
[
cvFaceROIImage
]
outputNames
:
[
faceHeadpose
]
units
:
-
name
:
CameraSrc
inputNames
:
[
cvFaceROIImage
]
outputNames
:
[
uint8FaceROIImage
]
-
name
:
ResizeNorm
inputNames
:
[
uint8FaceROIImage
]
outputNames
:
[
resizeFaceROIImage
]
inputMean
:
[
0.485
,
0.456
,
0.406
]
inputStd
:
[
0.229
,
0.224
,
0.225
]
inferBatchSize
:
1
inputWidth
:
224
inputHeight
:
224
fixAspectRatio
:
true
useBGR
:
false
-
name
:
TRTInference
inputNames
:
[
resizeFaceROIImage
]
outputNames
:
[
"
tf.identity"
,
"
tf.identity_1"
,
"
tf.identity_2"
]
runMode
:
1
# 0-fp32 1-fp16 2-int8 (int8 not supported)
weightsPath
:
"
configs/tasks/dms/WHENet.onnx"
engineFile
:
"
configs/tasks/dms/WHENet_fp16.engine"
# calibImgPathFile: "configs/tasks/dms/whenet_calib_imgs.txt"
# calibTableCache: "configs/tasks/dms/whenet_calib_table.cache"
inferDynamic
:
false
inferBatchSize
:
1
inputWidth
:
224
inputHeight
:
224
maxBatchSize
:
1
# used when build engine
-
name
:
WHENetPostProcess
inputNames
:
[
"
tf.identity"
,
"
tf.identity_1"
,
"
tf.identity_2"
]
outputNames
:
[
faceHeadpose
]
outputYawLength
:
120
outputPitchLength
:
66
outputRollLength
:
66
configs/tasks/dms/face_landmarks_mobilefacenet.yaml
0 → 100644
View file @
9461f84c
name
:
CameraModel
inputNames
:
[
cvFaceROIImage2
]
outputNames
:
[
faceLandmarks
]
units
:
-
name
:
CameraSrc
inputNames
:
[
cvFaceROIImage2
]
outputNames
:
[
uint8FaceROIImage2
]
-
name
:
ResizeNorm
inputNames
:
[
uint8FaceROIImage2
]
outputNames
:
[
resizeFaceROIImage2
]
inputMean
:
[
0.0
,
0.0
,
0.0
]
inputStd
:
[
1.0
,
1.0
,
1.0
]
inferBatchSize
:
1
inputWidth
:
112
inputHeight
:
112
fixAspectRatio
:
true
useBGR
:
false
-
name
:
TRTInference
inputNames
:
[
resizeFaceROIImage2
]
outputNames
:
[
"
output.0"
]
runMode
:
1
# 0-fp32 1-fp16 2-int8 (int8 not supported)
weightsPath
:
"
configs/tasks/dms/mobilefacenet_model.onnx"
engineFile
:
"
configs/tasks/dms/mobilefacenet_model_fp16.engine"
# calibImgPathFile: "configs/tasks/dms/mobilefacenet_calib_imgs.txt"
# calibTableCache: "configs/tasks/dms/mobilefacenet_calib_table.cache"
inferDynamic
:
false
inferBatchSize
:
1
inputWidth
:
112
inputHeight
:
112
maxBatchSize
:
1
# used when build engine
-
name
:
MobileFaceNetPostProcess
inputNames
:
[
"
output.0"
,
uint8FaceROIImage2
]
outputNames
:
[
faceLandmarks
]
inputWidth
:
112
inputHeight
:
112
fixAspectRatio
:
true
landmarkNumber
:
68
configs/tasks/fusion/fusion.yaml
0 → 100644
View file @
9461f84c
configRootPath
:
/home/wangxin/projects/waytous/DeepInfer
device
:
2
modelName
:
CameraModel
modelConfigPath
:
configs/tasks/fusion/fusion_model.yaml
# undistort image for vis
mainSrcName
:
undistortVisImage
configs/tasks/fusion/fusion_model.yaml
0 → 100644
View file @
9461f84c
name
:
CameraModel
inputNames
:
[
cvVisImage
,
cvThermalImage
]
# outputNames: [fusionedDetections]
outputNames
:
[
trackedDetections
]
units
:
# camera rgb, using TraDes segmentor
-
name
:
CameraSrc
inputNames
:
[
cvVisImage
]
outputNames
:
[
uint8VisImage
]
-
name
:
Undistort
inputNames
:
[
uint8VisImage
]
outputNames
:
[
undistortVisImage
]
imageWidth
:
1920
imageHeight
:
1080
IntrinsicPath
:
configs/tasks/fusion/rgb_intrinsic.yaml
-
name
:
ResizeNorm
inputNames
:
[
undistortVisImage
]
outputNames
:
[
resizeVisImage
]
inputMean
:
[
0.40789654
,
0.44719302
,
0.47026115
]
inputStd
:
[
0.28863828
,
0.27408164
,
0.27809835
]
useBGR
:
true
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
384
fixAspectRatio
:
false
-
name
:
TRTInference
inputNames
:
[
resizeVisImage
]
outputNames
:
[
hm
,
reg
,
wh
,
conv_weight
,
seg_feat
]
runMode
:
1
# 0-fp32 1-fp16 2-int8 (int8 not supported)
weightsPath
:
"
configs/tasks/mots/trades_segv3.onnx"
engineFile
:
"
configs/tasks/mots/trades_segv3_fp16.engine"
# calibImgPathFile: "configs/tasks/mots/trades_calib_imgs.txt"
# calibTableCache: "configs/tasks/mots/trades_calib_table.cache"
inferDynamic
:
false
maxBatchSize
:
1
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
384
-
name
:
TraDesPostProcess
inputNames
:
[
hm
,
reg
,
wh
,
conv_weight
,
seg_feat
,
uint8VisImage
]
outputNames
:
[
visDetections
]
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
384
fixAspectRatio
:
false
scoreThreshold
:
0.2
truncatedThreshold
:
0.05
classNumber
:
3
classNames
:
[
person
,
vehicle
,
cycle
]
topK
:
100
downScale
:
4
segDims
:
64
maxCntsLength
:
500
# thermal with yolov5
-
name
:
CameraSrc
inputNames
:
[
cvThermalImage
]
outputNames
:
[
uint8ThermalImage
]
-
name
:
Undistort
inputNames
:
[
uint8ThermalImage
]
outputNames
:
[
undistortThermalImage
]
imageWidth
:
640
imageHeight
:
512
IntrinsicPath
:
configs/tasks/fusion/thermal_intrinsic.yaml
-
name
:
ResizeNorm
inputNames
:
[
undistortThermalImage
]
outputNames
:
[
resizeThermalImage
]
inputMean
:
[
0
,
0
,
0
]
inputStd
:
[
1
,
1
,
1
]
useBGR
:
false
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
640
fixAspectRatio
:
true
-
name
:
YoloV5TRTInference
inputNames
:
[
resizeThermalImage
]
outputNames
:
[
num_detections
,
nmsed_boxes
,
nmsed_scores
,
nmsed_classes
]
runMode
:
1
# 0-fp32 1-fp16 2-int8 (int8 not supported)
weightsPath
:
"
configs/tasks/thermal/yolov5s_640x640_thermal.wts"
engineFile
:
"
configs/tasks/thermal/yolov5s_640x640_thermal_fp16.engine"
# calibImgPathFile: "configs/tasks/thermal/yolov5s_calib_imgs.txt"
# calibTableCache: "configs/tasks/thermal/yolov5s_calib_table.cache"
inferDynamic
:
true
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
640
maxBatchSize
:
4
# using when build engine
classNumber
:
2
numAnchorsPerLevel
:
3
numLevels
:
3
startScale
:
8
maxOutputBBoxCount
:
1000
keepTopK
:
100
# used when build engine, always be smaller than scoreThreshold.
# if you want it to take effect, you should delete the ${engineFile}
engineScoreThreshold
:
0.1
nmsThreshold
:
0.45
# yolov5
# n: 0.33+0.25 s: 0.33+0.5 m: 0.67+0.75 l: 1.0+1.0 x: 1.33+1.25
gd
:
0.33
gw
:
0.5
-
name
:
YoloV5PostProcess
inputNames
:
[
num_detections
,
nmsed_boxes
,
nmsed_scores
,
nmsed_classes
,
uint8ThermalImage
]
outputNames
:
[
thermalDetections
]
inputWidth
:
640
inputHeight
:
640
fixAspectRatio
:
true
scoreThreshold
:
0.2
# used when inference, can be modified
truncatedThreshold
:
0.05
keepTopK
:
100
classNames
:
[
vehicle
,
person
]
-
name
:
HomoProject
inputNames
:
[
thermalDetections
]
outputNames
:
[
thermalProjectDetections
]
homoMatrixPath
:
configs/tasks/fusion/thermal_homography.yaml
# fusion
-
name
:
BayesianFusioner
inputNames
:
[
visDetections
,
thermalProjectDetections
]
outputNames
:
[
fusionedDetections
]
NMSThreshold
:
0.5
# supported: IOU IOA GIOU CIOU
matchMethod
:
IOA
# tracker
-
name
:
ByteTracker
inputNames
:
[
fusionedDetections
]
outputNames
:
[
trackedDetections
]
frame_rate
:
20
track_buffer
:
30
track_thresh
:
0.2
high_thresh
:
0.2
match_thresh
:
0.8
init_frames
:
0
configs/tasks/fusion/rgb_intrinsic.yaml
0 → 100644
View file @
9461f84c
image_width
:
1920
image_height
:
1080
camera_name
:
narrow_stereo/left
camera_matrix
:
rows
:
3
cols
:
3
data
:
[
954.94556
,
0.
,
959.48891
,
0.
,
955.72757
,
550.42017
,
0.
,
0.
,
1.
]
camera_model
:
plumb_bob
distortion_coefficients
:
rows
:
1
cols
:
5
data
:
[
-0.308855
,
0.080618
,
-0.000948
,
-0.000307
,
0.000000
]
rectification_matrix
:
rows
:
3
cols
:
3
data
:
[
0.99964588
,
-0.02369215
,
-0.01211637
,
0.02381908
,
0.99966175
,
0.01044166
,
0.01186489
,
-0.01072657
,
0.99987207
]
projection_matrix
:
rows
:
3
cols
:
4
data
:
[
863.43207
,
0.
,
964.79819
,
0.
,
0.
,
863.43207
,
544.12591
,
0.
,
0.
,
0.
,
1.
,
0.
]
configs/tasks/fusion/thermal_homography.yaml
0 → 100644
View file @
9461f84c
dst_height
:
1080
dst_width
:
1920
homography_matrix
:
rows
:
3
cols
:
3
data
:
[
1.43434450e+00
,
-2.82390527e-02
,
4.89822323e+02
,
1.96702059e-02
,
1.29985905e+00
,
1.87569822e+02
,
1.51906922e-04
,
-1.06563084e-04
,
1.00000000e+00
]
configs/tasks/fusion/thermal_intrinsic.yaml
0 → 100644
View file @
9461f84c
image_width
:
640
image_height
:
512
camera_name
:
thermal
camera_matrix
:
rows
:
3
cols
:
3
data
:
[
755.0212
,
2.0979
,
311.1998
,
0.
,
757.7410
,
261.7544
,
0.
,
0.
,
1.
]
camera_model
:
plumb_bob
distortion_coefficients
:
rows
:
1
cols
:
5
data
:
[
-0.4137
,
0.1847
,
-0.0056
,
0.0014
,
0.0186
]
# rectification_matrix:
# rows: 3
# cols: 3
# data:
# projection_matrix:
# rows: 3
# cols: 4
# data:
configs/tasks/mots/trades.yaml
View file @
9461f84c
name
:
TraDeS
name
:
CameraModel
inputNames
:
[
cvImage1
]
outputNames
:
[
trackedDetections1
]
globalParams
:
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
384
fixAspectRatio
:
false
units
:
-
name
:
CameraSrc
...
...
@@ -18,6 +14,10 @@ units:
outputNames
:
[
resizeNormImages
]
inputMean
:
[
0.40789654
,
0.44719302
,
0.47026115
]
inputStd
:
[
0.28863828
,
0.27408164
,
0.27809835
]
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
384
fixAspectRatio
:
false
useBGR
:
true
-
name
:
TRTInference
...
...
@@ -30,14 +30,21 @@ units:
# calibTableCache: "configs/tasks/mots/trades_calib_table.cache"
inferDynamic
:
false
maxBatchSize
:
1
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
384
-
name
:
TraDesPostProcess
inputNames
:
[
hm
,
reg
,
wh
,
conv_weight
,
seg_feat
,
uint8Image1
]
outputNames
:
[
segInstances1
]
inferBatchSize
:
1
inputWidth
:
640
inputHeight
:
384
fixAspectRatio
:
false
scoreThreshold
:
0.2
truncatedThreshold
:
0.05
classNumber
:
3
classNames
:
[
vehicle
,
person
,
cycle
]
classNames
:
[
person
,
vehicle
,
cycle
]
topK
:
100
downScale
:
4
segDims
:
64
...
...
configs/tasks/thermal/yolov5.yaml
View file @
9461f84c
...
...
@@ -2,11 +2,7 @@
name
:
CameraModel
inputNames
:
[
cvImage1
,
cvImage2
]
outputNames
:
[
trackedDetections1
,
trackedDetections2
]
globalParams
:
inferBatchSize
:
2
inputWidth
:
640
inputHeight
:
640
fixAspectRatio
:
true
units
:
-
name
:
CameraSrc
...
...
@@ -22,6 +18,10 @@ units:
outputNames
:
[
resizeNormImages
]
inputMean
:
[
0
,
0
,
0
]
inputStd
:
[
1
,
1
,
1
]
inferBatchSize
:
2
inputWidth
:
640
inputHeight
:
640
fixAspectRatio
:
true
useBGR
:
false
-
name
:
YoloV5TRTInference
...
...
@@ -33,7 +33,10 @@ units:
# calibImgPathFile: "configs/tasks/thermal/yolov5s_calib_imgs.txt"
# calibTableCache: "configs/tasks/thermal/yolov5s_calib_table.cache"
inferDynamic
:
true
maxBatchSize
:
4
inferBatchSize
:
2
inputWidth
:
640
inputHeight
:
640
maxBatchSize
:
4
# used when build engine
classNumber
:
2
numAnchorsPerLevel
:
3
numLevels
:
3
...
...
@@ -52,6 +55,9 @@ units:
name
:
YoloV5PostProcess
inputNames
:
[
num_detections
,
nmsed_boxes
,
nmsed_scores
,
nmsed_classes
,
uint8Image1
,
uint8Image2
]
outputNames
:
[
detections1
,
detections2
]
inputWidth
:
640
inputHeight
:
640
fixAspectRatio
:
true
scoreThreshold
:
0.2
# used when inference, can be modified
truncatedThreshold
:
0.05
keepTopK
:
100
...
...
main.cpp
View file @
9461f84c
...
...
@@ -37,7 +37,10 @@ int main(int argc, char** argv){
std
::
string
srcPath
=
argv
[
4
];
std
::
string
savePath
=
argv
[
5
];
auto
t
=
interfaces
::
BaseTaskRegisterer
::
GetInstanceByName
(
taskName
);
t
->
Init
(
configPath
);
if
(
!
t
->
Init
(
configPath
)){
printf
(
"Init problems!
\n
"
);
return
0
;
};
printf
(
"Init all Done
\n
"
);
auto
paths
=
stringSplit
(
srcPath
,
','
);
...
...
@@ -64,10 +67,16 @@ int main(int argc, char** argv){
auto
e2
=
std
::
chrono
::
system_clock
::
now
();
std
::
cout
<<
"100 times avg infer time: "
<<
std
::
chrono
::
duration_cast
<
std
::
chrono
::
microseconds
>
(
e2
-
e1
).
count
()
/
1000.
/
100.
<<
" ms"
<<
std
::
endl
;
for
(
int
i
=
0
;
i
<
inputs
.
size
();
i
++
){
cv
::
Mat
vis
=
images
[
i
];
t
->
Visualize
(
&
vis
,
outputs
[
i
]);
cv
::
imwrite
(
savePaths
[
i
],
vis
);
if
(
inputs
.
size
()
!=
outputs
.
size
()){
cv
::
Mat
vis
=
images
[
0
];
t
->
Visualize
(
&
vis
,
outputs
[
0
]);
cv
::
imwrite
(
savePaths
[
0
],
vis
);
}
else
{
for
(
int
i
=
0
;
i
<
inputs
.
size
();
i
++
){
cv
::
Mat
vis
=
images
[
i
];
t
->
Visualize
(
&
vis
,
outputs
[
i
]);
cv
::
imwrite
(
savePaths
[
i
],
vis
);
}
}
}
else
if
(
videoOrImage
==
"video"
){
...
...
@@ -98,7 +107,20 @@ int main(int argc, char** argv){
/*
./main TaskMOTS image ../configs/tasks/mots/mots.yaml ../test/bsw.jpg ../test/mots_res.jpg
./main TaskDetect image ../configs/tasks/thermal/thermal.yaml ../test/thermal2.jpg,../test/thermal2.jpg ../test/t_b1_res.jpg,../test/t_b2_res.jpg
./main TaskFusion image ../configs/tasks/fusion/fusion.yaml ../test/fusion_rgb.png,../test/fusion_thermal.png ../test/fusion_res.jpg
./main TaskDMS image ../configs/tasks/dms/dms.yaml ../test/dms.jpg ../test/dms_res.jpg
./main TaskBSW image ../configs/tasks/bsw/bsw.yaml ../test/bsw.jpg ../test/bsw_res.jpg
*/
...
...
src/base/image.h
View file @
9461f84c
...
...
@@ -74,6 +74,9 @@ public:
offset_
=
0
;
channels_
=
image
->
channels
();
blob_
.
reset
(
new
Blob
<
uint8_t
>
({
rows_
,
cols_
,
channels_
}));
if
(
image
->
data
==
nullptr
){
LOG_ERROR
<<
"image data null"
;
}
blob_
->
set_cpu_data
(
image
->
data
);
width_step_
=
blob_
->
offset
({
1
,
0
,
0
})
*
static_cast
<
int
>
(
sizeof
(
uint8_t
));
}
...
...
src/common/common.h
View file @
9461f84c
...
...
@@ -60,7 +60,7 @@ inline float euclidean(float x1, float y1, float x2, float y2){
}
void
softmax
(
float
*
x
,
int
length
){
inline
void
softmax
(
float
*
x
,
int
length
){
float
max
=
x
[
0
];
float
sum
=
0
.
0
;
for
(
int
i
=
0
;
i
<
length
;
i
++
){
...
...
src/interfaces/base_model.h
View file @
9461f84c
...
...
@@ -35,6 +35,7 @@ public:
}
public
:
std
::
vector
<
BaseUnitPtr
>
units_
;
std
::
vector
<
std
::
string
>
inputNames
;
std
::
vector
<
std
::
string
>
outputNames
;
...
...
src/interfaces/base_unit.cpp
View file @
9461f84c
...
...
@@ -4,13 +4,9 @@ namespace waytous {
namespace
deepinfer
{
namespace
interfaces
{
bool
BaseUnit
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
){
bool
BaseUnit
::
Init
(
YAML
::
Node
&
node
){
inputNames
=
node
[
"inputNames"
].
as
<
std
::
vector
<
std
::
string
>>
();
outputNames
=
node
[
"outputNames"
].
as
<
std
::
vector
<
std
::
string
>>
();
inferBatchSize
=
globalParamNode
[
"inferBatchSize"
].
as
<
int
>
();
// default=1
inputHeight
=
globalParamNode
[
"inputHeight"
].
as
<
int
>
();
inputWidth
=
globalParamNode
[
"inputWidth"
].
as
<
int
>
();
fixAspectRatio
=
globalParamNode
[
"fixAspectRatio"
].
as
<
bool
>
();
return
true
;
};
...
...
src/interfaces/base_unit.h
View file @
9461f84c
...
...
@@ -22,7 +22,7 @@ public:
BaseUnit
()
=
default
;
virtual
~
BaseUnit
()
=
default
;
virtual
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
);
virtual
bool
Init
(
YAML
::
Node
&
node
);
virtual
bool
Exec
()
=
0
;
...
...
@@ -34,10 +34,6 @@ public:
std
::
vector
<
std
::
string
>
inputNames
;
std
::
vector
<
std
::
string
>
outputNames
;
//global params
int
inferBatchSize
=
1
;
int
inputWidth
,
inputHeight
;
bool
fixAspectRatio
=
true
;
};
using
BaseUnitPtr
=
std
::
shared_ptr
<
BaseUnit
>
;
...
...
src/libs/fusioner/bayesian_fusioner.cpp
View file @
9461f84c
...
...
@@ -5,16 +5,16 @@ namespace deepinfer {
namespace
fusioner
{
bool
BayesianFusioner
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
{
if
(
!
BaseUnit
::
Init
(
node
,
globalParamNode
)){
LOG_WARN
<<
"Init
trades postprocess
error"
;
bool
BayesianFusioner
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
LOG_WARN
<<
"Init
BayesianFusioner
error"
;
return
false
;
};
NMSThreshold
=
node
[
"NMSThreshold"
].
as
<
float
>
();
std
::
string
methodStr
=
node
[
"matchMethod"
].
as
<
std
::
string
>
();
auto
method
=
MethodName2Type
.
find
(
methodStr
);
if
(
method
==
MethodName2Type
.
end
()){
LOG_WARN
<<
"
N
ot supported match method "
<<
methodStr
;
LOG_WARN
<<
"
BayesianFusioner n
ot supported match method "
<<
methodStr
;
return
false
;
}
matchMethod
=
method
->
second
;
...
...
@@ -47,6 +47,7 @@ bool BayesianFusioner::Exec(){
);
auto
fusioned_objects
=
std
::
make_shared
<
ios
::
Detection2Ds
>
(
ios
::
Detection2Ds
());
interfaces
::
SetIOPtr
(
outputNames
[
0
],
fusioned_objects
);
for
(
size_t
i
=
0
;
i
<
indices
.
size
();
i
++
){
if
(
!
deleted
[
indices
[
i
]]){
std
::
vector
<
ios
::
Det2DPtr
>
matched_objs
;
...
...
@@ -60,15 +61,21 @@ bool BayesianFusioner::Exec(){
matched_objs
.
push_back
(
all_objects
[
indices
[
j
]]);
}
}
/* merge score, useless
float pos_sum = 0;
float neg_sum = 0;
for(auto& obj : matched_objs){
// merge matched mask
if(main_obj->mask_ptr == nullptr){
main_obj->mask_ptr = obj->mask_ptr;
}
pos_sum += std::log(obj->confidence);
neg_sum += std::log(1 - obj->confidence);
}
pos_sum = std::exp(pos_sum);
neg_sum = std::exp(neg_sum);
main_obj->confidence = pos_sum / (pos_sum + neg_sum);
*/
// if()
fusioned_objects
->
detections
.
push_back
(
main_obj
);
}
...
...
src/libs/fusioner/bayesian_fusioner.h
View file @
9461f84c
...
...
@@ -31,7 +31,7 @@ public:
{
"IOA"
,
BayesianFusionMatchMethod
::
IOA
}
};
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Exec
()
override
;
...
...
src/libs/inferences/tensorrt/trt_infer.cpp
View file @
9461f84c
...
...
@@ -22,12 +22,15 @@ TRTInference::~TRTInference(){
}
bool
TRTInference
::
Init
(
YAML
::
Node
&
configNode
,
YAML
::
Node
&
globalParamNode
){
if
(
!
BaseUnit
::
Init
(
configNode
,
globalParamNode
)){
bool
TRTInference
::
Init
(
YAML
::
Node
&
configNode
){
if
(
!
BaseUnit
::
Init
(
configNode
)){
LOG_WARN
<<
"Init trt engine error"
;
return
false
;
};
inputHeight
=
configNode
[
"inputHeight"
].
as
<
int
>
();
inputWidth
=
configNode
[
"inputWidth"
].
as
<
int
>
();
inferBatchSize
=
configNode
[
"inferBatchSize"
].
as
<
int
>
();
engineFile
=
configNode
[
"engineFile"
].
as
<
std
::
string
>
();
inferDynamic
=
configNode
[
"inferDynamic"
].
as
<
bool
>
();
engineFile
=
common
::
GetAbsolutePath
(
common
::
ConfigRoot
::
GetRootPath
(),
engineFile
);
...
...
src/libs/inferences/tensorrt/trt_infer.h
View file @
9461f84c
...
...
@@ -32,7 +32,7 @@ class TRTInference: public interfaces::BaseUnit {
public
:
~
TRTInference
();
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
virtual
bool
BuildEngine
(
YAML
::
Node
&
node
);
bool
Exec
()
override
;
virtual
std
::
string
Name
()
override
;
...
...
@@ -51,6 +51,8 @@ public:
std
::
string
engineFile
;
bool
inferDynamic
=
false
;
int
inferBatchSize
=
1
;
int
inputWidth
,
inputHeight
;
};
// class TRTInferenceEngine
DEEPINFER_REGISTER_UNIT
(
TRTInference
);
...
...
src/libs/postprocessors/homo_project.cpp
View file @
9461f84c
...
...
@@ -5,26 +5,29 @@ namespace deepinfer {
namespace
postprocess
{
bool
HomoProject
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
{
if
(
!
BaseUnit
::
Init
(
node
,
globalParamNode
)){
bool
HomoProject
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
LOG_WARN
<<
"Init homo project error"
;
return
false
;
};
auto
homoMatrixPath
=
node
[
"homoMatrixPath"
].
as
<
std
::
string
>
();
std
::
string
yaml_path
=
common
::
GetAbsolutePath
(
common
::
ConfigRoot
::
GetRootPath
(),
homoMatrixPath
);
if
(
!
common
::
PathExists
(
yaml_path
))
{
LOG_INFO
<<
yaml_path
<<
" does not exist!"
;
LOG_INFO
<<
"Load homo project matrix "
<<
yaml_path
<<
" does not exist!"
;
return
false
;
}
YAML
::
Node
n
ode
=
YAML
::
LoadFile
(
yaml_path
);
if
(
n
ode
.
IsNull
())
{
LOG_INFO
<<
"Load "
<<
yaml_path
<<
" failed! please check!"
;
YAML
::
Node
homoN
ode
=
YAML
::
LoadFile
(
yaml_path
);
if
(
homoN
ode
.
IsNull
())
{
LOG_INFO
<<
"Load
homo project matrix
"
<<
yaml_path
<<
" failed! please check!"
;
return
false
;
}
dst_width
=
homoNode
[
"dst_width"
].
as
<
int
>
();
dst_height
=
homoNode
[
"dst_height"
].
as
<
int
>
();
for
(
int
i
=
0
;
i
<
9
;
i
++
){
camera_homo_to_main
(
i
)
=
n
ode
[
"homography_matrix"
][
"data"
][
i
].
as
<
float
>
();
camera_homo_to_main
(
i
)
=
homoN
ode
[
"homography_matrix"
][
"data"
][
i
].
as
<
float
>
();
}
return
true
;
}
...
...
@@ -54,6 +57,15 @@ bool HomoProject::Exec(){
projected_obj
->
y1
=
pbox
(
2
);
projected_obj
->
y2
=
pbox
(
3
);
projected_obj
->
image_height
=
dst_height
;
projected_obj
->
image_width
=
dst_width
;
projected_obj
->
validCoordinate
();
// todo mask_project
if
(
projected_obj
->
mask_ptr
!=
nullptr
){
}
projected_dets
->
detections
.
push_back
(
projected_obj
);
}
interfaces
::
SetIOPtr
(
outputNames
[
0
],
projected_dets
);
...
...
src/libs/postprocessors/homo_project.h
View file @
9461f84c
...
...
@@ -17,13 +17,14 @@ namespace postprocess {
class
HomoProject
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Exec
()
override
;
std
::
string
Name
()
override
;
public
:
int
dst_height
,
dst_width
;
Eigen
::
Matrix
<
float
,
3
,
3
,
Eigen
::
RowMajor
>
camera_homo_to_main
;
};
...
...
src/libs/postprocessors/mobilefacenet_post.cpp
View file @
9461f84c
...
...
@@ -5,11 +5,14 @@ namespace deepinfer {
namespace
postprocess
{
bool
MobileFaceNetPostProcess
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
{
if
(
!
BaseUnit
::
Init
(
node
,
globalParamNode
)){
LOG_WARN
<<
"Init
trades
postprocess error"
;
bool
MobileFaceNetPostProcess
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
LOG_WARN
<<
"Init
mobilefacenet
postprocess error"
;
return
false
;
};
inputHeight
=
node
[
"inputHeight"
].
as
<
int
>
();
inputWidth
=
node
[
"inputWidth"
].
as
<
int
>
();
fixAspectRatio
=
node
[
"fixAspectRatio"
].
as
<
bool
>
();
landmarkNumber
=
node
[
"landmarkNumber"
].
as
<
int
>
();
return
true
;
}
...
...
@@ -17,13 +20,13 @@ bool MobileFaceNetPostProcess::Init(YAML::Node& node, YAML::Node& globalParamNod
bool
MobileFaceNetPostProcess
::
Exec
(){
if
(
inputNames
.
size
()
!=
1
+
outputNames
.
size
()){
LOG_ERROR
<<
"
yolov5 postprocess, inputsize != 4
+ ouputsize."
;
LOG_ERROR
<<
"
mobilefacenet postprocess, inputsize != 1
+ ouputsize."
;
return
false
;
}
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
NormalIO
>
(
interfaces
::
GetIOPtr
(
inputNames
[
0
]));
if
(
input
==
nullptr
){
LOG_ERROR
<<
"
WHEN
et postprocess input "
<<
inputNames
[
0
]
<<
" haven't been init or doesn't exist."
;
LOG_ERROR
<<
"
mobilefacen
et postprocess input "
<<
inputNames
[
0
]
<<
" haven't been init or doesn't exist."
;
return
false
;
}
...
...
@@ -32,7 +35,7 @@ bool MobileFaceNetPostProcess::Exec(){
auto
iName
=
inputNames
[
j
];
auto
iptr
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
interfaces
::
GetIOPtr
(
iName
));
if
(
iptr
==
nullptr
){
LOG_ERROR
<<
"
YoloV5
postprocess input "
<<
iName
<<
" haven't been init or doesn't exist."
;
LOG_ERROR
<<
"
mobilefacenet
postprocess input "
<<
iName
<<
" haven't been init or doesn't exist."
;
return
false
;
}
inputImages
.
push_back
(
iptr
->
img_ptr_
);
...
...
src/libs/postprocessors/mobilefacenet_post.h
View file @
9461f84c
...
...
@@ -20,13 +20,15 @@ namespace postprocess {
class
MobileFaceNetPostProcess
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Exec
()
override
;
std
::
string
Name
()
override
;
public
:
int
inputHeight
,
inputWidth
;
bool
fixAspectRatio
=
true
;
int
landmarkNumber
;
};
...
...
src/libs/postprocessors/trades_post.cpp
View file @
9461f84c
...
...
@@ -5,12 +5,16 @@ namespace deepinfer {
namespace
postprocess
{
bool
TraDesPostProcess
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
{
if
(
!
BaseUnit
::
Init
(
node
,
globalParamNode
)){
bool
TraDesPostProcess
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
LOG_WARN
<<
"Init trades postprocess error"
;
return
false
;
};
inputHeight
=
node
[
"inputHeight"
].
as
<
int
>
();
inputWidth
=
node
[
"inputWidth"
].
as
<
int
>
();
inferBatchSize
=
node
[
"inferBatchSize"
].
as
<
int
>
();
fixAspectRatio
=
node
[
"fixAspectRatio"
].
as
<
bool
>
();
scoreThreshold
=
node
[
"scoreThreshold"
].
as
<
float
>
();
truncatedThreshold
=
node
[
"truncatedThreshold"
].
as
<
float
>
();
classNumber
=
node
[
"classNumber"
].
as
<
int
>
();
...
...
src/libs/postprocessors/trades_post.h
View file @
9461f84c
...
...
@@ -21,7 +21,7 @@ namespace postprocess {
class
TraDesPostProcess
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Exec
()
override
;
...
...
@@ -34,6 +34,9 @@ public:
base
::
BlobPtr
<
int
>
maskCnts_lengths_ptr
;
base
::
BlobPtr
<
int
>
maskCnts_ptr
;
int
inputHeight
,
inputWidth
;
int
inferBatchSize
=
1
;
bool
fixAspectRatio
=
true
;
float
scoreThreshold
,
truncatedThreshold
;
int
classNumber
;
std
::
vector
<
std
::
string
>
classNames
;
...
...
src/libs/postprocessors/whenet_post.cpp
View file @
9461f84c
...
...
@@ -5,9 +5,9 @@ namespace deepinfer {
namespace
postprocess
{
bool
WHENetPostProcess
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
{
if
(
!
BaseUnit
::
Init
(
node
,
globalParamNode
)){
LOG_WARN
<<
"Init
trades
postprocess error"
;
bool
WHENetPostProcess
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
LOG_WARN
<<
"Init
WHENet
postprocess error"
;
return
false
;
};
outputYawLength
=
node
[
"outputYawLength"
].
as
<
int
>
();
...
...
@@ -34,36 +34,38 @@ bool WHENetPostProcess::Exec(){
float
*
roll
=
inputs
[
1
]
->
mutable_cpu_data
();
float
*
pitch
=
inputs
[
2
]
->
mutable_cpu_data
();
auto
headpose
=
std
::
make_shared
<
ios
::
HeadPose
>
(
ios
::
HeadPose
());
interfaces
::
SetIOPtr
(
outputNames
[
0
],
headpose
);
float
yawSum
=
0
,
pitchSum
=
0
,
rollSum
=
0
;
// yaw
common
::
softmax
(
yaw
,
outputYawLength
);
for
(
int
i
=
0
;
i
<
outputYawLength
;
i
++
){
yawSum
+=
yaw
[
i
]
*
i
;
}
yawSum
*=
3.0
;
yawSum
-=
180
;
headpose
->
yaw
=
yawSum
;
for
(
int
b
=
0
;
b
<
outputNames
.
size
();
b
++
){
auto
headpose
=
std
::
make_shared
<
ios
::
HeadPose
>
(
ios
::
HeadPose
());
interfaces
::
SetIOPtr
(
outputNames
[
b
],
headpose
);
float
yawSum
=
0
,
pitchSum
=
0
,
rollSum
=
0
;
// yaw
common
::
softmax
(
yaw
+
b
*
outputYawLength
,
outputYawLength
);
for
(
int
i
=
0
;
i
<
outputYawLength
;
i
++
){
yawSum
+=
yaw
[
i
+
b
*
outputYawLength
]
*
i
;
}
yawSum
*=
3.0
;
yawSum
-=
180
;
headpose
->
yaw
=
yawSum
;
// roll
common
::
softmax
(
roll
,
outputRollLength
);
for
(
int
i
=
0
;
i
<
outputRollLength
;
i
++
){
rollSum
+=
roll
[
i
]
*
i
;
}
rollSum
*=
3.0
;
rollSum
-=
99
;
headpose
->
roll
=
rollSum
;
// roll
common
::
softmax
(
roll
+
b
*
outputRollLength
,
outputRollLength
);
for
(
int
i
=
0
;
i
<
outputRollLength
;
i
++
){
rollSum
+=
roll
[
i
+
b
*
outputRollLength
]
*
i
;
}
rollSum
*=
3.0
;
rollSum
-=
99
;
headpose
->
roll
=
rollSum
;
// pitch
common
::
softmax
(
pitch
,
outputPitchLength
);
for
(
int
i
=
0
;
i
<
outputPitchLength
;
i
++
){
pitchSum
+=
pitch
[
i
]
*
i
;
// pitch
common
::
softmax
(
pitch
+
b
*
outputPitchLength
,
outputPitchLength
);
for
(
int
i
=
0
;
i
<
outputPitchLength
;
i
++
){
pitchSum
+=
pitch
[
i
+
b
*
outputPitchLength
]
*
i
;
}
pitchSum
*=
3.0
;
pitchSum
-=
99
;
headpose
->
pitch
=
pitchSum
;
}
pitchSum
*=
3.0
;
pitchSum
-=
99
;
headpose
->
pitch
=
pitchSum
;
return
true
;
}
...
...
src/libs/postprocessors/whenet_post.h
View file @
9461f84c
...
...
@@ -20,7 +20,7 @@ namespace postprocess {
class
WHENetPostProcess
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Exec
()
override
;
...
...
src/libs/postprocessors/yolov5_post.cpp
View file @
9461f84c
...
...
@@ -5,11 +5,14 @@ namespace deepinfer {
namespace
postprocess
{
bool
YoloV5PostProcess
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
{
if
(
!
BaseUnit
::
Init
(
node
,
globalParamNode
)){
LOG_WARN
<<
"Init
trades
postprocess error"
;
bool
YoloV5PostProcess
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
LOG_WARN
<<
"Init
yolov5
postprocess error"
;
return
false
;
};
inputHeight
=
node
[
"inputHeight"
].
as
<
int
>
();
inputWidth
=
node
[
"inputWidth"
].
as
<
int
>
();
fixAspectRatio
=
node
[
"fixAspectRatio"
].
as
<
bool
>
();
classNames
=
node
[
"classNames"
].
as
<
std
::
vector
<
std
::
string
>>
();
truncatedThreshold
=
node
[
"truncatedThreshold"
].
as
<
float
>
();
// default 5%
scoreThreshold
=
node
[
"scoreThreshold"
].
as
<
float
>
();
...
...
src/libs/postprocessors/yolov5_post.h
View file @
9461f84c
...
...
@@ -20,13 +20,15 @@ namespace postprocess {
class
YoloV5PostProcess
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Exec
()
override
;
std
::
string
Name
()
override
;
public
:
int
inputHeight
,
inputWidth
;
bool
fixAspectRatio
=
true
;
int
keepTopK
=
100
;
float
scoreThreshold
,
truncatedThreshold
;
std
::
vector
<
std
::
string
>
classNames
;
...
...
src/libs/preprocessors/resize_norm.cpp
View file @
9461f84c
...
...
@@ -6,11 +6,16 @@ namespace deepinfer {
namespace
preprocess
{
bool
ResizeNorm
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
){
if
(
!
BaseUnit
::
Init
(
node
,
globalParamNode
)){
bool
ResizeNorm
::
Init
(
YAML
::
Node
&
node
){
CUDA_CHECK
(
cudaStreamCreate
(
&
stream_
));
if
(
!
BaseUnit
::
Init
(
node
)){
LOG_WARN
<<
"Init resize_norm error"
;
return
false
;
};
inputHeight
=
node
[
"inputHeight"
].
as
<
int
>
();
inputWidth
=
node
[
"inputWidth"
].
as
<
int
>
();
inferBatchSize
=
node
[
"inferBatchSize"
].
as
<
int
>
();
fixAspectRatio
=
node
[
"fixAspectRatio"
].
as
<
bool
>
();
if
(
inputNames
.
size
()
!=
inferBatchSize
){
LOG_ERROR
<<
"Resize norm got wrong inputs number: "
<<
inputNames
.
size
()
<<
" with infer batchsize: "
<<
inferBatchSize
;
...
...
src/libs/preprocessors/resize_norm.h
View file @
9461f84c
...
...
@@ -21,16 +21,19 @@ namespace preprocess {
class
ResizeNorm
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Exec
()
override
;
std
::
string
Name
()
override
;
public
:
cudaStream_t
stream_
;
base
::
BlobPtr
<
float
>
dst
,
mean
,
std
;
int
inputHeight
,
inputWidth
;
int
inferBatchSize
=
1
;
bool
fixAspectRatio
=
true
;
bool
useBGR
=
false
;
base
::
BlobPtr
<
float
>
dst
,
mean
,
std
;
cudaStream_t
stream_
;
};
...
...
src/libs/preprocessors/undistort.cpp
View file @
9461f84c
...
...
@@ -5,8 +5,8 @@ namespace deepinfer {
namespace
preprocess
{
bool
Undistort
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
{
if
(
!
BaseUnit
::
Init
(
node
,
globalParamNode
)){
bool
Undistort
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
)){
LOG_WARN
<<
"Init trades postprocess error"
;
return
false
;
};
...
...
@@ -16,18 +16,10 @@ bool Undistort::Init(YAML::Node& node, YAML::Node& globalParamNode) {
std
::
string
IntrinsicPath
,
ExtrinsicPath
=
""
;
IntrinsicPath
=
node
[
"IntrinsicPath"
].
as
<
std
::
string
>
();
if
(
node
[
"ExtrinsicPath"
].
IsDefined
()
&&
!
node
[
"ExtrinsicPath"
].
IsNull
()){
ExtrinsicPath
=
node
[
"ExtrinsicPath"
].
as
<
std
::
string
>
();
}
if
(
!
loadIntrinsic
(
IntrinsicPath
)){
LOG_WARN
<<
"Load intrinsic error: "
<<
IntrinsicPath
;
return
false
;
}
if
(
ExtrinsicPath
!=
""
&&
!
loadExtrinsics
(
ExtrinsicPath
)){
LOG_WARN
<<
"Load Extrinsic error: "
<<
ExtrinsicPath
;
return
false
;
}
d_mapx_
.
Reshape
({
height_
,
width_
});
d_mapy_
.
Reshape
({
height_
,
width_
});
...
...
@@ -40,66 +32,14 @@ bool Undistort::Init(YAML::Node& node, YAML::Node& globalParamNode) {
camera_intrinsic
,
width_
,
height_
,
&
d_mapx_
,
&
d_mapy_
);
dst_img
=
std
::
make_shared
<
base
::
Image8U
>
(
base
::
Image8U
(
height_
,
width_
,
base
::
Color
::
BGR
));
auto
output
=
std
::
make_shared
<
ios
::
CameraSrcOut
>
(
ios
::
CameraSrcOut
(
dst_img
));
interfaces
::
SetIOPtr
(
outputNames
[
0
],
output
);
inited_
=
true
;
return
true
;
}
bool
Undistort
::
loadExtrinsics
(
std
::
string
&
yaml_file
){
std
::
string
yaml_path
=
common
::
GetAbsolutePath
(
common
::
ConfigRoot
::
GetRootPath
(),
yaml_file
);
if
(
!
common
::
PathExists
(
yaml_path
))
{
LOG_INFO
<<
yaml_path
<<
" does not exist!"
;
return
false
;
}
YAML
::
Node
node
=
YAML
::
LoadFile
(
yaml_path
);
double
qw
=
0.0
;
double
qx
=
0.0
;
double
qy
=
0.0
;
double
qz
=
0.0
;
double
tx
=
0.0
;
double
ty
=
0.0
;
double
tz
=
0.0
;
try
{
if
(
node
.
IsNull
())
{
LOG_INFO
<<
"Load "
<<
yaml_path
<<
" failed! please check!"
;
return
false
;
}
qw
=
node
[
"transform"
][
"rotation"
][
"w"
].
as
<
double
>
();
qx
=
node
[
"transform"
][
"rotation"
][
"x"
].
as
<
double
>
();
qy
=
node
[
"transform"
][
"rotation"
][
"y"
].
as
<
double
>
();
qz
=
node
[
"transform"
][
"rotation"
][
"z"
].
as
<
double
>
();
tx
=
node
[
"transform"
][
"translation"
][
"x"
].
as
<
double
>
();
ty
=
node
[
"transform"
][
"translation"
][
"y"
].
as
<
double
>
();
tz
=
node
[
"transform"
][
"translation"
][
"z"
].
as
<
double
>
();
}
catch
(
YAML
::
InvalidNode
&
in
)
{
LOG_ERROR
<<
"load camera extrisic file "
<<
yaml_path
<<
" with error, YAML::InvalidNode exception"
;
return
false
;
}
catch
(
YAML
::
TypedBadConversion
<
double
>
&
bc
)
{
LOG_ERROR
<<
"load camera extrisic file "
<<
yaml_path
<<
" with error, YAML::TypedBadConversion exception"
;
return
false
;
}
catch
(
YAML
::
Exception
&
e
)
{
LOG_ERROR
<<
"load camera extrisic file "
<<
yaml_path
<<
" with error, YAML exception:"
<<
e
.
what
();
return
false
;
}
camera_extrinsic
.
setConstant
(
0
);
Eigen
::
Quaterniond
q
;
q
.
x
()
=
qx
;
q
.
y
()
=
qy
;
q
.
z
()
=
qz
;
q
.
w
()
=
qw
;
camera_extrinsic
.
block
<
3
,
3
>
(
0
,
0
)
=
q
.
normalized
().
toRotationMatrix
();
camera_extrinsic
(
0
,
3
)
=
tx
;
camera_extrinsic
(
1
,
3
)
=
ty
;
camera_extrinsic
(
2
,
3
)
=
tz
;
camera_extrinsic
(
3
,
3
)
=
1
;
return
true
;
}
bool
Undistort
::
loadIntrinsic
(
std
::
string
&
yaml_file
){
std
::
string
yaml_path
=
common
::
GetAbsolutePath
(
common
::
ConfigRoot
::
GetRootPath
(),
yaml_file
);
if
(
!
common
::
PathExists
(
yaml_path
))
{
...
...
@@ -211,8 +151,6 @@ bool Undistort::Exec(){
}
auto
src_img
=
iptr
->
img_ptr_
;
auto
dst_img
=
std
::
make_shared
<
base
::
Image8U
>
(
base
::
Image8U
(
src_img
->
rows
(),
src_img
->
cols
(),
src_img
->
type
()));
auto
output
=
std
::
make_shared
<
ios
::
CameraSrcOut
>
(
ios
::
CameraSrcOut
(
dst_img
));
NppiInterpolationMode
remap_mode
=
NPPI_INTER_LINEAR
;
NppiSize
image_size
;
...
...
@@ -247,7 +185,6 @@ bool Undistort::Exec(){
return
false
;
}
interfaces
::
SetIOPtr
(
outputNames
[
0
],
output
);
return
true
;
}
...
...
src/libs/preprocessors/undistort.h
View file @
9461f84c
...
...
@@ -22,14 +22,13 @@ namespace preprocess {
class
Undistort
:
public
interfaces
::
BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Exec
()
override
;
std
::
string
Name
()
override
;
bool
loadIntrinsic
(
std
::
string
&
yaml_file
);
bool
loadExtrinsics
(
std
::
string
&
yaml_file
);
void
InitUndistortRectifyMap
(
const
Eigen
::
Matrix3f
&
camera_model
,
const
Eigen
::
Matrix
<
float
,
1
,
5
>
&
distortion
,
const
Eigen
::
Matrix3f
&
R
,
...
...
@@ -40,7 +39,7 @@ public:
public
:
base
::
Blob
<
float
>
d_mapx_
;
base
::
Blob
<
float
>
d_mapy_
;
Eigen
::
Matrix
<
double
,
4
,
4
,
Eigen
::
RowMajor
>
camera_extrinsic
;
// load by another yaml file
base
::
Image8UPtr
dst_img
;
Eigen
::
Matrix
<
float
,
3
,
3
,
Eigen
::
RowMajor
>
camera_intrinsic
;
Eigen
::
Matrix
<
float
,
3
,
3
,
Eigen
::
RowMajor
>
camera_rectification
;
Eigen
::
Matrix
<
float
,
3
,
4
,
Eigen
::
RowMajor
>
camera_projection
;
...
...
@@ -48,9 +47,6 @@ public:
int
width_
=
0
;
// image cols
int
height_
=
0
;
// image rows
int
in_size_
=
0
;
// size of the input image in byte
int
out_size_
=
0
;
// size of the output image in byte
int
device_
=
0
;
// device number for gpu
bool
inited_
=
0
;
};
...
...
src/libs/trackers/byte_tracker.cpp
View file @
9461f84c
...
...
@@ -7,10 +7,10 @@ namespace tracker{
bool
ByteTracker
::
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
bool
ByteTracker
::
Init
(
YAML
::
Node
&
node
)
{
if
(
!
BaseUnit
::
Init
(
node
,
globalParamNode
)){
LOG_WARN
<<
"Init
resize_norm
error"
;
if
(
!
BaseUnit
::
Init
(
node
)){
LOG_WARN
<<
"Init
ByteTracker
error"
;
return
false
;
};
int
frame_rate
=
node
[
"frame_rate"
].
as
<
int
>
();
...
...
@@ -22,18 +22,17 @@ bool ByteTracker::Init(YAML::Node& node, YAML::Node& globalParamNode)
frame_id
=
0
;
max_time_lost
=
int
(
frame_rate
/
30.0
*
track_buffer
);
LOG_INFO
<<
"Init ByteTracker!"
;
return
true
;
}
bool
ByteTracker
::
Exec
()
{
if
(
interfaces
::
GetIOPtr
(
inputNames
[
0
])
==
nullptr
){
LOG_ERROR
<<
"ByteTracker input"
<<
inputNames
[
0
]
<<
" haven't init"
;
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
interfaces
::
GetIOPtr
(
inputNames
[
0
]));
if
(
input
==
nullptr
){
LOG_ERROR
<<
"ByteTracker input "
<<
inputNames
[
0
]
<<
" haven't init"
;
return
false
;
}
auto
input
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
interfaces
::
GetIOPtr
(
inputNames
[
0
]));
auto
objects
=
input
->
detections
;
////////////////// Step 1: Get detections //////////////////
...
...
src/libs/trackers/byte_tracker.h
View file @
9461f84c
...
...
@@ -18,7 +18,7 @@ class ByteTracker: public interfaces::BaseUnit
{
public
:
bool
Init
(
YAML
::
Node
&
node
,
YAML
::
Node
&
globalParamNode
)
override
;
bool
Init
(
YAML
::
Node
&
node
)
override
;
bool
Exec
()
override
;
std
::
string
Name
()
override
;
...
...
src/models/camera_model.cpp
View file @
9461f84c
...
...
@@ -9,28 +9,27 @@ bool CameraModel::Init(std::string& configPath) {
// CUDA_CHECK(cudaStreamCreate(&stream_));
std
::
string
cfgPath
=
common
::
GetAbsolutePath
(
common
::
ConfigRoot
::
GetRootPath
(),
configPath
);
if
(
!
common
::
PathExists
(
cfgPath
)){
LOG_WARN
<<
"config_file "
<<
common
::
ConfigRoot
::
GetRootPath
()
<<
" "
<<
cfgPath
<<
" not exist."
;
LOG_WARN
<<
"
Init CameraModel
config_file "
<<
common
::
ConfigRoot
::
GetRootPath
()
<<
" "
<<
cfgPath
<<
" not exist."
;
return
false
;
}
modelConfigNode
=
YAML
::
LoadFile
(
cfgPath
);
if
(
modelConfigNode
.
IsNull
())
{
LOG_WARN
<<
"Load "
<<
configPath
<<
" failed! please check!"
;
LOG_WARN
<<
"
Init CameraModel,
Load "
<<
configPath
<<
" failed! please check!"
;
return
false
;
}
inputNames
=
modelConfigNode
[
"inputNames"
].
as
<
std
::
vector
<
std
::
string
>>
();
outputNames
=
modelConfigNode
[
"outputNames"
].
as
<
std
::
vector
<
std
::
string
>>
();
auto
globalParamNode
=
modelConfigNode
[
"globalParams"
];
// units
auto
unitNodes
=
modelConfigNode
[
"units"
];
for
(
int
i
=
0
;
i
<
unitNodes
.
size
();
i
++
){
auto
unitNode
=
unitNodes
[
i
];
std
::
string
unitName
=
unitNode
[
"name"
].
as
<
std
::
string
>
();
LOG_INFO
<<
"Init unit: "
<<
unitName
;
LOG_INFO
<<
"Init
CameraModel
unit: "
<<
unitName
;
interfaces
::
BaseUnitPtr
unitPtr
;
unitPtr
.
reset
(
interfaces
::
BaseUnitRegisterer
::
GetInstanceByName
(
unitName
));
if
(
!
unitPtr
->
Init
(
unitNode
,
globalParamNode
)){
LOG_WARN
<<
"Init unit "
<<
unitName
<<
" failed!"
;
if
(
!
unitPtr
->
Init
(
unitNode
)){
LOG_WARN
<<
"Init
CameraModel
unit "
<<
unitName
<<
" failed!"
;
return
false
;
};
units_
.
push_back
(
unitPtr
);
...
...
@@ -44,22 +43,22 @@ bool CameraModel::Exec(std::vector<cv::Mat*> inputs, std::vector<interfaces::Bas
for
(
int
i
=
0
;
i
<
inputs
.
size
();
i
++
){
auto
input_img
=
inputs
[
i
];
auto
inputName
=
inputNames
[
i
];
LOG_INFO
<<
"input: "
<<
inputName
;
LOG_INFO
<<
"
CameraModel
input: "
<<
inputName
;
auto
input
=
std
::
make_shared
<
ios
::
CameraSrcIn
>
(
ios
::
CameraSrcIn
(
input_img
));
interfaces
::
SetIOPtr
(
inputName
,
input
);
}
// infer
for
(
auto
unit
:
units_
){
LOG_INFO
<<
"exec unit
:
"
<<
unit
->
Name
();
for
(
auto
&
unit
:
units_
){
LOG_INFO
<<
"exec unit "
<<
unit
->
Name
();
if
(
!
unit
->
Exec
()){
LOG_ERROR
<<
unit
->
Name
()
<<
" unit
exec error"
;
LOG_ERROR
<<
"exec CameraModel unit "
<<
unit
->
Name
()
<<
"
exec error"
;
return
false
;
};
}
// output
for
(
auto
outName
:
outputNames
){
LOG_INFO
<<
"output: "
<<
outName
;
LOG_INFO
<<
"
CameraModel
output: "
<<
outName
;
outputs
.
push_back
(
interfaces
::
GetIOPtr
(
outName
));
}
...
...
@@ -75,9 +74,14 @@ bool CameraModel::Exec(std::vector<base::Image8UPtr> inputs, std::vector<interfa
auto
input
=
std
::
make_shared
<
ios
::
CameraSrcOut
>
(
ios
::
CameraSrcOut
(
input_img
));
interfaces
::
SetIOPtr
(
inputName
,
input
);
}
// infer
for
(
auto
unit
:
units_
){
unit
->
Exec
();
for
(
auto
&
unit
:
units_
){
LOG_INFO
<<
"exec unit"
<<
unit
->
Name
();
if
(
!
unit
->
Exec
()){
LOG_ERROR
<<
"exec CameraModel unit "
<<
unit
->
Name
()
<<
" exec error"
;
return
false
;
};
}
// output
...
...
src/models/camera_model.h
View file @
9461f84c
...
...
@@ -25,7 +25,6 @@ public:
public
:
YAML
::
Node
modelConfigNode
;
std
::
vector
<
interfaces
::
BaseUnitPtr
>
units_
;
};
DEEPINFER_REGISTER_MODELS
(
CameraModel
);
...
...
src/tasks/task_bsw.cpp
View file @
9461f84c
...
...
@@ -8,7 +8,7 @@ namespace task{
bool
TaskBSW
::
Init
(
std
::
string
&
taskConfigPath
){
if
(
!
interfaces
::
BaseTask
::
Init
(
taskConfigPath
)){
LOG_ERROR
<<
"Init task
detect
error"
;
LOG_ERROR
<<
"Init task
BSW
error"
;
return
false
;
};
std
::
string
detectorName
=
taskNode
[
"detectorName"
].
as
<
std
::
string
>
();
...
...
@@ -16,7 +16,7 @@ bool TaskBSW::Init(std::string& taskConfigPath){
detector
.
reset
(
interfaces
::
BaseModelRegisterer
::
GetInstanceByName
(
detectorName
));
if
(
!
detector
->
Init
(
detectorConfigPath
)){
LOG_ERROR
<<
detectorName
<<
" detector init problem"
;
LOG_ERROR
<<
"Init BSW "
<<
detectorName
<<
" detector init problem"
;
return
false
;
};
...
...
@@ -26,14 +26,15 @@ bool TaskBSW::Init(std::string& taskConfigPath){
// init distance pools
std
::
string
warningDistancePoolsPath
=
taskNode
[
"warningDistancePoolsPath"
].
as
<
std
::
string
>
();
useFullPolygan
=
taskNode
[
"useFullPolygan"
].
as
<
bool
>
();
std
::
string
distanceConfigPath
=
common
::
GetAbsolutePath
(
common
::
ConfigRoot
::
GetRootPath
(),
warningDistancePoolsPath
);
if
(
!
common
::
PathExists
(
distanceConfigPath
)){
LOG_ERROR
<<
"camera distance pool config_file "
<<
distanceConfigPath
<<
" not exist."
;
LOG_ERROR
<<
"
Init BSW,
camera distance pool config_file "
<<
distanceConfigPath
<<
" not exist."
;
return
false
;
}
YAML
::
Node
distanceNode
=
YAML
::
LoadFile
(
distanceConfigPath
);
if
(
distanceNode
.
IsNull
())
{
LOG_ERROR
<<
"
Load
"
<<
distanceConfigPath
<<
" failed! please check!"
;
LOG_ERROR
<<
"
Init BSW, Load
"
<<
distanceConfigPath
<<
" failed! please check!"
;
return
false
;
}
...
...
@@ -49,12 +50,12 @@ bool TaskBSW::Init(std::string& taskConfigPath){
bool
TaskBSW
::
Exec
(
std
::
vector
<
cv
::
Mat
*>
inputs
,
std
::
vector
<
interfaces
::
BaseIOPtr
>&
outputs
){
if
(
inputs
.
size
()
!=
1
){
LOG_ERROR
<<
'
Now
only
support
infer
one
image
once
.
'
;
LOG_ERROR
<<
"Task BSW now only support infer one image once."
;
return
false
;
}
std
::
vector
<
interfaces
::
BaseIOPtr
>
dets
;
if
(
!
detector
->
Exec
(
inputs
,
dets
)){
LOG_ERROR
<<
"Task
Detect E
xec error"
;
LOG_ERROR
<<
"Task
BSW's detector e
xec error"
;
return
false
;
};
...
...
@@ -112,15 +113,16 @@ bool TaskBSW::Exec(std::vector<cv::Mat*> inputs, std::vector<interfaces::BaseIOP
void
TaskBSW
::
Visualize
(
cv
::
Mat
*
image
,
interfaces
::
BaseIOPtr
outs
){
for
(
auto
&
bo_pair
:
BSWRes
){
auto
&
bo
=
bo_pair
.
second
;
auto
bo
=
bo_pair
.
second
;
if
(
bo
->
lost_ages
>
0
){
continue
;
}
auto
&
obj
=
bo
->
obj
;
cv
::
Scalar
color
=
bo
->
counters
[
0
]
%
4
==
0
?
cv
::
Scalar
(
255
,
255
,
255
)
:
ranges
[(
int
)
bo
->
msg
].
color
;
cv
::
rectangle
(
*
image
,
cv
::
Rect
(
int
(
obj
->
x1
),
int
(
obj
->
y1
),
int
(
obj
->
x2
-
obj
->
x1
),
int
(
obj
->
x
2
-
obj
->
y1
)),
color
,
2
);
auto
obj
=
bo
->
obj
;
cv
::
Scalar
color
=
ranges
[(
int
)
bo
->
msg
].
color
;
//bo->counters[0] % 4 == 0 ? cv::Scalar(255, 255, 255) :
cv
::
rectangle
(
*
image
,
cv
::
Rect
(
int
(
obj
->
x1
),
int
(
obj
->
y1
),
int
(
obj
->
x2
-
obj
->
x1
),
int
(
obj
->
y
2
-
obj
->
y1
)),
color
,
2
);
cv
::
putText
(
*
image
,
std
::
to_string
(
obj
->
track_id
)
+
"."
+
obj
->
class_name
+
":"
+
common
::
formatValue
(
obj
->
confidence
,
2
),
cv
::
Point
(
int
(
obj
->
x1
),
int
(
obj
->
y1
)
-
5
),
cv
::
FONT_HERSHEY_SIMPLEX
,
0.5
,
color
,
1
);
}
// draw outlines
cv
::
addWeighted
(
*
image
,
0.9
,
mask
,
0.1
,
0
,
*
image
);
...
...
@@ -141,7 +143,6 @@ bool TaskBSW::InitRanges(const std::string& warningRangeConfigPath, YAML::Node&
LOG_ERROR
<<
"Load "
<<
configPath
<<
" failed! please check!"
;
return
false
;
}
bool
useFullPolygan
=
taskNode
[
"useFullPolygan"
].
as
<
bool
>
();
auto
infoNode
=
rangeNode
[
"warningInfos"
];
for
(
int
i
=
0
;
i
<
infoNode
.
size
();
i
++
){
RangeInfo
rinfo
;
...
...
src/tasks/task_bsw.h
View file @
9461f84c
...
...
@@ -63,6 +63,7 @@ public:
std
::
vector
<
RangeInfo
>
ranges
;
std
::
map
<
int
,
BSWResultPtr
>
BSWRes
;
int
imageWidth
,
imageHeight
;
bool
useFullPolygan
=
true
;
cv
::
Mat
mask
;
};
...
...
src/tasks/task_dms.cpp
View file @
9461f84c
...
...
@@ -8,7 +8,7 @@ namespace task{
bool
TaskDMS
::
Init
(
std
::
string
&
taskConfigPath
){
if
(
!
interfaces
::
BaseTask
::
Init
(
taskConfigPath
)){
LOG_ERROR
<<
"Init task d
etect
error"
;
LOG_ERROR
<<
"Init task d
ms
error"
;
return
false
;
};
std
::
string
faceDetectorName
=
taskNode
[
"faceDetectorName"
].
as
<
std
::
string
>
();
...
...
@@ -31,17 +31,17 @@ bool TaskDMS::Init(std::string& taskConfigPath){
faceDetector
.
reset
(
interfaces
::
BaseModelRegisterer
::
GetInstanceByName
(
faceDetectorName
));
if
(
!
faceDetector
->
Init
(
faceDetectorConfigPath
)){
LOG_ERROR
<<
faceDetectorName
<<
" faceDetector init problem"
;
LOG_ERROR
<<
"Init task DMS "
<<
faceDetectorName
<<
" faceDetector init problem"
;
return
false
;
};
landmarkDetector
.
reset
(
interfaces
::
BaseModelRegisterer
::
GetInstanceByName
(
landmarkDetectorName
));
if
(
!
landmarkDetector
->
Init
(
landmarkDetectorConfigPath
)){
LOG_ERROR
<<
landmarkDetectorName
<<
" face landmarks detector init problem"
;
LOG_ERROR
<<
"Init task DMS "
<<
landmarkDetectorName
<<
" face landmarks detector init problem"
;
return
false
;
};
headposeDetector
.
reset
(
interfaces
::
BaseModelRegisterer
::
GetInstanceByName
(
headposeDetectorName
));
if
(
!
headposeDetector
->
Init
(
headposeDetectorConfigPath
)){
LOG_ERROR
<<
headposeDetectorName
<<
" face headpose detector init problem"
;
LOG_ERROR
<<
"Init task DMS "
<<
headposeDetectorName
<<
" face headpose detector init problem"
;
return
false
;
};
...
...
@@ -52,7 +52,7 @@ bool TaskDMS::Init(std::string& taskConfigPath){
bool
TaskDMS
::
Exec
(
std
::
vector
<
cv
::
Mat
*>
inputs
,
std
::
vector
<
interfaces
::
BaseIOPtr
>&
outputs
){
if
(
inputs
.
size
()
!=
1
){
LOG_ERROR
<<
'
Now
only
support
infer
one
image
once
.
'
;
LOG_ERROR
<<
"DMS now only support infer one image once."
;
return
false
;
}
std
::
vector
<
interfaces
::
BaseIOPtr
>
faceDets
;
...
...
@@ -68,7 +68,7 @@ bool TaskDMS::Exec(std::vector<cv::Mat*> inputs, std::vector<interfaces::BaseIOP
NODRIVER_COUNTER
++
;
if
(
NODRIVER_COUNTER
>=
nodriverConsecFrames
){
res
->
msg
=
DMSMsg
::
DMS_NODRIVER
;
LOG_INFO
<<
"No driver!"
;
//
LOG_INFO << "No driver!";
}
else
res
->
msg
=
DMSMsg
::
DMS_NONE
;
return
true
;
...
...
@@ -108,13 +108,13 @@ bool TaskDMS::Exec(std::vector<cv::Mat*> inputs, std::vector<interfaces::BaseIOP
// set landmarks and whenet input src
std
::
vector
<
cv
::
Mat
*>
subInputs
;
auto
faceImage
=
(
*
inputs
[
0
])(
faceROI
)
;
auto
faceImage
=
(
*
inputs
[
0
])(
faceROI
)
.
clone
();
// Mat(Rect) -> temporary reference, need clone() to copy data
subInputs
.
push_back
(
&
faceImage
);
// face landmarks
std
::
vector
<
interfaces
::
BaseIOPtr
>
landmarks_vec
;
if
(
!
landmarkDetector
->
Exec
(
subInputs
,
landmarks_vec
)){
LOG_ERROR
<<
"face landmarks detect doesnot end normally!"
;
LOG_ERROR
<<
"
Task DMS
face landmarks detect doesnot end normally!"
;
return
false
;
};
res
->
face_landmarks
=
std
::
dynamic_pointer_cast
<
ios
::
Landmarks
>
(
landmarks_vec
[
0
]);
...
...
@@ -141,7 +141,7 @@ bool TaskDMS::Exec(std::vector<cv::Mat*> inputs, std::vector<interfaces::BaseIOP
// headpose
std
::
vector
<
interfaces
::
BaseIOPtr
>
headpose_vec
;
if
(
!
headposeDetector
->
Exec
(
subInputs
,
headpose_vec
)){
LOG_ERROR
<<
"face headpose detect doesnot end normally!"
;
LOG_ERROR
<<
"
Task DMS
face headpose detect doesnot end normally!"
;
return
false
;
};
res
->
headPose
=
std
::
dynamic_pointer_cast
<
ios
::
HeadPose
>
(
headpose_vec
[
0
]);
...
...
src/tasks/task_fusion.cpp
View file @
9461f84c
...
...
@@ -8,15 +8,16 @@ namespace task{
bool
TaskFusion
::
Init
(
std
::
string
&
taskConfigPath
){
if
(
!
interfaces
::
BaseTask
::
Init
(
taskConfigPath
)){
LOG_ERROR
<<
"Init task
detect
error"
;
LOG_ERROR
<<
"Init task
fusion
error"
;
return
false
;
};
std
::
string
detectorName
=
taskNode
[
"detectorName"
].
as
<
std
::
string
>
();
std
::
string
detectorConfigPath
=
taskNode
[
"detectorConfigPath"
].
as
<
std
::
string
>
();
mainSrcName
=
taskNode
[
"mainSrcName"
].
as
<
std
::
string
>
();
std
::
string
modelName
=
taskNode
[
"modelName"
].
as
<
std
::
string
>
();
std
::
string
modelConfigPath
=
taskNode
[
"modelConfigPath"
].
as
<
std
::
string
>
();
model
.
reset
(
interfaces
::
BaseModelRegisterer
::
GetInstanceByName
(
detector
Name
));
if
(
!
model
->
Init
(
detector
ConfigPath
)){
LOG_ERROR
<<
detectorName
<<
" detector
init problem"
;
model
.
reset
(
interfaces
::
BaseModelRegisterer
::
GetInstanceByName
(
model
Name
));
if
(
!
model
->
Init
(
model
ConfigPath
)){
LOG_ERROR
<<
"Init Fusion "
<<
modelName
<<
" model
init problem"
;
return
false
;
};
return
true
;
...
...
@@ -25,7 +26,7 @@ bool TaskFusion::Init(std::string& taskConfigPath){
bool
TaskFusion
::
Exec
(
std
::
vector
<
cv
::
Mat
*>
inputs
,
std
::
vector
<
interfaces
::
BaseIOPtr
>&
outputs
){
if
(
!
model
->
Exec
(
inputs
,
outputs
)){
LOG_ERROR
<<
"Task
Detect
Exec error"
;
LOG_ERROR
<<
"Task
fusion
Exec error"
;
return
false
;
};
return
true
;
...
...
@@ -33,15 +34,49 @@ bool TaskFusion::Exec(std::vector<cv::Mat*> inputs, std::vector<interfaces::Base
void
TaskFusion
::
Visualize
(
cv
::
Mat
*
image
,
interfaces
::
BaseIOPtr
outs
){
auto
detections
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
outs
)
->
detections
;
for
(
auto
&
obj
:
detections
){
// LOG_INFO << "box: " << obj->x1 << " " << obj->x2 << " " << obj->y1 << " " << obj->y2;
cv
::
Scalar
color
=
get_color
(
obj
->
class_label
);
cv
::
rectangle
(
*
image
,
cv
::
Rect
(
int
(
obj
->
x1
),
int
(
obj
->
y1
),
int
(
obj
->
x2
-
obj
->
x1
),
int
(
obj
->
y2
-
obj
->
y1
)),
color
,
2
);
cv
::
putText
(
*
image
,
common
::
formatValue
(
obj
->
confidence
,
2
)
+
":"
+
std
::
to_string
(
obj
->
track_id
)
+
"."
+
obj
->
class_name
,
cv
::
Point
(
int
(
obj
->
x1
),
int
(
obj
->
y1
)
-
5
),
cv
::
FONT_HERSHEY_SIMPLEX
,
0.5
,
color
,
1
);
auto
mainSrc
=
std
::
dynamic_pointer_cast
<
ios
::
CameraSrcOut
>
(
interfaces
::
GetIOPtr
(
mainSrcName
));
auto
mainImage
=
mainSrc
->
img_ptr_
->
toCVMat
();
auto
detections
=
std
::
dynamic_pointer_cast
<
ios
::
Detection2Ds
>
(
outs
)
->
detections
;
cv
::
Mat
realInstanceMask
,
colorInstance
;
for
(
auto
&
obj
:
detections
){
cv
::
Scalar
color
=
get_color
(
obj
->
class_label
*
100
+
obj
->
track_id
);
cv
::
putText
(
mainImage
,
std
::
to_string
(
obj
->
track_id
)
+
":"
+
common
::
formatValue
(
obj
->
confidence
,
2
),
cv
::
Point
(
obj
->
x1
,
obj
->
y1
-
5
),
0
,
0.6
,
cv
::
Scalar
(
0
,
0
,
255
),
2
,
cv
::
LINE_AA
);
cv
::
rectangle
(
mainImage
,
cv
::
Rect
(
obj
->
x1
,
obj
->
y1
,
obj
->
x2
-
obj
->
x1
,
obj
->
y2
-
obj
->
y1
),
color
,
2
);
if
(
obj
->
mask_ptr
!=
nullptr
){
cv
::
Mat
instance_mask
=
obj
->
mask_ptr
->
decode
();
instance_mask
.
convertTo
(
instance_mask
,
CV_32FC1
);
cv
::
resize
(
instance_mask
,
realInstanceMask
,
mainImage
.
size
());
mainImage
.
copyTo
(
colorInstance
);
for
(
int
i
=
0
;
i
<
realInstanceMask
.
rows
;
i
++
){
for
(
int
j
=
0
;
j
<
realInstanceMask
.
cols
;
j
++
){
if
(
realInstanceMask
.
at
<
float
>
(
i
,
j
)
>=
0.5
){
colorInstance
.
at
<
cv
::
Vec3b
>
(
i
,
j
)
=
cv
::
Vec3b
(
color
[
0
],
color
[
1
],
color
[
2
]);
}
}
}
cv
::
addWeighted
(
mainImage
,
0.5
,
colorInstance
,
0.5
,
0
,
mainImage
);
}
}
/*for(int i=0; i<cameraHandlers.size(); i++){
if(i != mainCameraIndex){
cv::Mat img = cameraHandlers[i].frame->image_ptr->toCVMat();
cv::Mat dst;
if(cameraHandlers[i].frame->camera_info_ptr->sensor_type == base::SensorType::THERMAL_CAMERA){
cv::applyColorMap(img, img, cv::COLORMAP_JET);
}
cv::Mat homoMatrix;
cv::eigen2cv(cameraHandlers[i].frame->camera_info_ptr->camera_homo_to_main, homoMatrix);
cv::warpPerspective(img, dst, homoMatrix, mainImage.size());
mainImage = cv::max(mainImage, dst);
}
}*/
image
->
data
=
mainImage
.
data
;
}
...
...
src/tasks/task_fusion.h
View file @
9461f84c
...
...
@@ -2,6 +2,9 @@
#ifndef WAYTOUS_DEEPINFER_TASK_FUSION_H_
#define WAYTOUS_DEEPINFER_TASK_FUSION_H_
#include <Eigen/Core>
#include <opencv2/core/eigen.hpp>
#include "interfaces/base_task.h"
#include "models/camera_model.h"
#include "libs/ios/detection.h"
...
...
@@ -22,6 +25,7 @@ public:
public
:
std
::
shared_ptr
<
interfaces
::
BaseModel
>
model
;
std
::
string
mainSrcName
;
};
...
...
src/tasks/task_mots.cpp
View file @
9461f84c
...
...
@@ -8,7 +8,7 @@ namespace task{
bool
TaskMOTS
::
Init
(
std
::
string
&
taskConfigPath
){
if
(
!
interfaces
::
BaseTask
::
Init
(
taskConfigPath
)){
LOG_ERROR
<<
"Init task
detect
error"
;
LOG_ERROR
<<
"Init task
MOTS
error"
;
return
false
;
};
std
::
string
segmentorName
=
taskNode
[
"segmentorName"
].
as
<
std
::
string
>
();
...
...
@@ -16,7 +16,7 @@ bool TaskMOTS::Init(std::string& taskConfigPath){
segmentor
.
reset
(
interfaces
::
BaseModelRegisterer
::
GetInstanceByName
(
segmentorName
));
if
(
!
segmentor
->
Init
(
segmentorConfigPath
)){
LOG_ERROR
<<
segmentorName
<<
" segmentor init problem"
;
LOG_ERROR
<<
"Task MOTS "
<<
segmentorName
<<
" segmentor init problem"
;
return
false
;
};
return
true
;
...
...
@@ -25,7 +25,7 @@ bool TaskMOTS::Init(std::string& taskConfigPath){
bool
TaskMOTS
::
Exec
(
std
::
vector
<
cv
::
Mat
*>
inputs
,
std
::
vector
<
interfaces
::
BaseIOPtr
>&
outputs
){
if
(
!
segmentor
->
Exec
(
inputs
,
outputs
)){
LOG_ERROR
<<
"Task
Detect
Exec error"
;
LOG_ERROR
<<
"Task
MOTS
Exec error"
;
return
false
;
};
return
true
;
...
...
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