Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
R
ros_camera_bev
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
ros_camera_bev
Commits
dac2e427
Commit
dac2e427
authored
Mar 28, 2025
by
yangxue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update pub_msg; limit filtering non-stones objs
parent
b88313e6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
14 deletions
+35
-14
sensor_manager.cpp
src/camera_bev_infer/src/sensor_manager.cpp
+9
-5
sensor_manager.h
src/camera_bev_infer/src/sensor_manager.h
+3
-3
vision_3d.cpp
src/camera_bev_infer/src/vision_transform/vision_3d.cpp
+23
-6
No files found.
src/camera_bev_infer/src/sensor_manager.cpp
View file @
dac2e427
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
* @Date: 2023-09-03 02:18:07
* @Date: 2023-09-03 02:18:07
* @email: xin.wang@waytous.com
* @email: xin.wang@waytous.com
* @LastEditors: yangxue xue.yang@waytous.com
* @LastEditors: yangxue xue.yang@waytous.com
* @LastEditTime: 2025-03-28 0
6:58
:22
* @LastEditTime: 2025-03-28 0
9:27
:22
*/
*/
...
@@ -160,6 +160,8 @@ void sensorManager::publishDetection()
...
@@ -160,6 +160,8 @@ void sensorManager::publishDetection()
usleep
(
5000
);
// 5ms
usleep
(
5000
);
// 5ms
continue
;
continue
;
}
}
std
::
cout
<<
"Infer objects: "
<<
frame_ptr
->
objs_
.
size
()
<<
std
::
endl
;
auto
vGrid
=
std
::
make_shared
<
BEV_GridMap
>
();
auto
vGrid
=
std
::
make_shared
<
BEV_GridMap
>
();
auto
point_cloud_ptr
=
getCurPointcloud
();
auto
point_cloud_ptr
=
getCurPointcloud
();
...
@@ -174,9 +176,9 @@ void sensorManager::publishDetection()
...
@@ -174,9 +176,9 @@ void sensorManager::publishDetection()
vision_converter_
->
Process_objects
(
frame_ptr
->
img_src_
,
frame_ptr
->
depth_
,
frame_ptr
->
objs_
,
*
vGrid
);
vision_converter_
->
Process_objects
(
frame_ptr
->
img_src_
,
frame_ptr
->
depth_
,
frame_ptr
->
objs_
,
*
vGrid
);
}
}
waytous_perception_msgs
::
ObjectArray
obFrame
;
std
::
cout
<<
"BEV objects: "
<<
vGrid
->
vInsObjs
.
size
()
<<
std
::
endl
;
obFrame
.
sensor_type
=
waytous_perception_msgs
::
Object
::
SENSOR_CAMERA
;
waytous_perception_msgs
::
ObjectArray
obFrame
;
int8_t
obj_id
=
0
;
int8_t
obj_id
=
0
;
for
(
auto
&
obj
:
vGrid
->
vInsObjs
)
for
(
auto
&
obj
:
vGrid
->
vInsObjs
)
{
{
...
@@ -185,6 +187,7 @@ void sensorManager::publishDetection()
...
@@ -185,6 +187,7 @@ void sensorManager::publishDetection()
continue
;
continue
;
}
}
waytous_perception_msgs
::
Object
ob
;
waytous_perception_msgs
::
Object
ob
;
ob
.
sensor_type
=
waytous_perception_msgs
::
Object
::
SENSOR_CAMERA
;
//int8 id = 1;
//int8 id = 1;
ob
.
id
=
obj_id
++
;
ob
.
id
=
obj_id
++
;
...
@@ -250,7 +253,7 @@ void sensorManager::publishDetection()
...
@@ -250,7 +253,7 @@ void sensorManager::publishDetection()
pxyzi
.
z
=
0
;
pxyzi
.
z
=
0
;
res_pcl_cloud
->
points
.
emplace_back
(
pxyzi
);
res_pcl_cloud
->
points
.
emplace_back
(
pxyzi
);
}
}
pcl
::
toROSMsg
(
*
res_pcl_cloud
,
ob
.
cloud
);
pcl
::
toROSMsg
(
*
res_pcl_cloud
,
ob
.
point
cloud
);
// int8 label_type = 9
// int8 label_type = 9
ob
.
label_type
=
(
name2type
.
find
(
obj
.
names
)
==
name2type
.
end
()
?
Perception_Default_Classification
:
name2type
[
obj
.
names
]);
ob
.
label_type
=
(
name2type
.
find
(
obj
.
names
)
==
name2type
.
end
()
?
Perception_Default_Classification
:
name2type
[
obj
.
names
]);
...
@@ -279,7 +282,8 @@ void sensorManager::publishDetection()
...
@@ -279,7 +282,8 @@ void sensorManager::publishDetection()
obFrame
.
foreground_objects
.
emplace_back
(
ob
);
obFrame
.
foreground_objects
.
emplace_back
(
ob
);
}
}
obj_publisher_
.
publish
(
obFrame
);
obj_publisher_
.
publish
(
obFrame
);
std
::
cout
<<
" onRun : "
<<
double
(
clock
()
-
start_
)
/
CLOCKS_PER_SEC
<<
"s"
<<
std
::
endl
;
//输出时间(单位:s)
std
::
cout
<<
" onRun : "
<<
double
(
clock
()
-
start_
)
/
CLOCKS_PER_SEC
<<
"s. "
<<
"Detected Objects: "
<<
obFrame
.
foreground_objects
.
size
()
<<
std
::
endl
;
//输出时间(单位:s)
if
(
ros_visualization_ptr_
!=
nullptr
&&
infer_param
.
vis_res
){
if
(
ros_visualization_ptr_
!=
nullptr
&&
infer_param
.
vis_res
){
ros_visualization_ptr_
->
Visualization
(
*
vGrid
,
frame_ptr
->
img_src_
,
frame_ptr
->
objs_
);
ros_visualization_ptr_
->
Visualization
(
*
vGrid
,
frame_ptr
->
img_src_
,
frame_ptr
->
objs_
);
...
...
src/camera_bev_infer/src/sensor_manager.h
View file @
dac2e427
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
* @Author: wxin
* @Author: wxin
* @Date: 2023-09-03 01:53:20
* @Date: 2023-09-03 01:53:20
* @email: xin.wang@waytous.com
* @email: xin.wang@waytous.com
* @LastEditors:
xin.wang.waytous xin.w
ang@waytous.com
* @LastEditors:
yangxue xue.y
ang@waytous.com
* @LastEditTime: 202
4-10-31 08:43:47
* @LastEditTime: 202
5-03-28 08:31:29
*/
*/
#ifndef SENSORMANAGER_H
#ifndef SENSORMANAGER_H
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
// msg
// msg
#include "waytous_perception_msgs/ObjectArray.h"
#include "waytous_perception_msgs/ObjectArray.h"
#include "waytous_perception_msgs/Object.h"
#include "waytous_perception_msgs/Object.h"
#include "waytous_perception_msgs/Rect.h"
//
#include "waytous_perception_msgs/Rect.h"
#include "common_maps.h"
#include "common_maps.h"
#include "utils.h"
#include "utils.h"
...
...
src/camera_bev_infer/src/vision_transform/vision_3d.cpp
View file @
dac2e427
...
@@ -4,8 +4,8 @@
...
@@ -4,8 +4,8 @@
* @Author: wxin
* @Author: wxin
* @Date: 2023-09-03 03:13:41
* @Date: 2023-09-03 03:13:41
* @email: xin.wang@waytous.com
* @email: xin.wang@waytous.com
* @LastEditors:
wxin
* @LastEditors:
yangxue xue.yang@waytous.com
* @LastEditTime: 202
4-03-12 06:38:25
* @LastEditTime: 202
5-03-28 10:58:33
*/
*/
...
@@ -401,6 +401,7 @@ int Visione_3D::Process_objects(const cv::Mat& image, const cv::Mat& imgdist, st
...
@@ -401,6 +401,7 @@ int Visione_3D::Process_objects(const cv::Mat& image, const cv::Mat& imgdist, st
Process_Segmantic_Objects
(
obj
,
imgdist
,
pTable
,
vGrid
);
Process_Segmantic_Objects
(
obj
,
imgdist
,
pTable
,
vGrid
);
}
}
}
}
// 将静态目标投影到栅格地图中
// 将静态目标投影到栅格地图中
pcl
::
PointXYZI
bev_point
;
pcl
::
PointXYZI
bev_point
;
cv
::
Point2f
pt2f
;
cv
::
Point2f
pt2f
;
...
@@ -566,7 +567,11 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& di
...
@@ -566,7 +567,11 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& di
insobj
.
fromDepth
=
true
;
insobj
.
fromDepth
=
true
;
vGrid
.
vInsObjs
.
push_back
(
insobj
);
vGrid
.
vInsObjs
.
push_back
(
insobj
);
obj
.
valid
=
obj
.
valid
+
2
;
obj
.
valid
=
obj
.
valid
+
2
;
}
else
{
std
::
cout
<<
"[Vision_3d.cpp] invalid object [rrc]: "
<<
insobj
.
rrc
.
size
.
height
<<
" "
<<
insobj
.
rrc
.
size
.
width
<<
std
::
endl
;
}
}
}
else
{
std
::
cout
<<
"[Vision_3d.cpp] invalid object [objRc]: "
<<
nValidNum
<<
" "
<<
objRc
.
width
<<
" "
<<
objRc
.
height
<<
std
::
endl
;
}
}
// std::cout<<" instance rc vision "<<double(clock()-start_)/CLOCKS_PER_SEC<<"s"<<std::endl; //输出时间(单位:s)
// std::cout<<" instance rc vision "<<double(clock()-start_)/CLOCKS_PER_SEC<<"s"<<std::endl; //输出时间(单位:s)
return
0
;
return
0
;
...
@@ -817,6 +822,7 @@ int Visione_3D::Process_objects(const cv::Mat& image, Cloud::Ptr& pcl_cloud, std
...
@@ -817,6 +822,7 @@ int Visione_3D::Process_objects(const cv::Mat& image, Cloud::Ptr& pcl_cloud, std
Process_Segmantic_Objects
(
obj
,
point_index_in_camera
,
pcl_cloud
,
vGrid
);
Process_Segmantic_Objects
(
obj
,
point_index_in_camera
,
pcl_cloud
,
vGrid
);
}
}
}
}
// 将静态目标投影到栅格地图中
// 将静态目标投影到栅格地图中
pcl
::
PointXYZI
bev_point
;
pcl
::
PointXYZI
bev_point
;
cv
::
Point2f
pt2f
;
cv
::
Point2f
pt2f
;
...
@@ -966,12 +972,14 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
...
@@ -966,12 +972,14 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
Tracks
[
obj
.
track_id
]
=
STrack
();
// init
Tracks
[
obj
.
track_id
]
=
STrack
();
// init
}
}
bool
valid
=
Tracks
[
obj
.
track_id
].
valid
;
bool
valid
=
Tracks
[
obj
.
track_id
].
valid
;
// std::cout<<"obj: "<< obj.track_id<< ","<< obj.name <<" with project ratio: "<< project_ratio << ", " << project_count << std::endl;
std
::
cout
<<
"obj: "
<<
obj
.
track_id
<<
","
<<
obj
.
name
<<
" with project ratio: "
<<
project_ratio
<<
", "
<<
project_count
<<
std
::
endl
;
if
(
valid
)
std
::
cout
<<
"valid----------------"
<<
std
::
endl
;
if
(
valid
){
if
(
valid
){
Tracks
[
obj
.
track_id
].
last_update_age
=
0
;
// update
Tracks
[
obj
.
track_id
].
last_update_age
=
0
;
// update
}
}
bool
pointEnough
=
false
;
bool
pointEnough
=
false
;
cv
::
Rect
objRc
=
cv
::
Rect
(
objX1
,
objY1
,
MIN
(
objBin
.
cols
,
objX2
+
1
)
-
objX1
,
MIN
(
objBin
.
rows
,
objY2
+
1
)
-
objY1
);
cv
::
Rect
objRc
=
cv
::
Rect
(
objX1
,
objY1
,
MIN
(
objBin
.
cols
,
objX2
+
1
)
-
objX1
,
MIN
(
objBin
.
rows
,
objY2
+
1
)
-
objY1
);
//目标bev矩形区域
//目标bev矩形区域
InstanceBevObject
insobj
;
InstanceBevObject
insobj
;
if
(
nValidNum
>=
3
&&
objRc
.
width
>
0
&&
objRc
.
height
>
0
)
if
(
nValidNum
>=
3
&&
objRc
.
width
>
0
&&
objRc
.
height
>
0
)
...
@@ -982,6 +990,8 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
...
@@ -982,6 +990,8 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
pointEnough
=
true
;
pointEnough
=
true
;
}
}
}
}
if
(
pointEnough
)
std
::
cout
<<
"point enough----------------"
<<
std
::
endl
;
if
(
valid
){
if
(
valid
){
if
(
pointEnough
)
if
(
pointEnough
)
{
{
...
@@ -993,7 +1003,7 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
...
@@ -993,7 +1003,7 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
obj
.
valid
=
obj
.
valid
+
1
;
obj
.
valid
=
obj
.
valid
+
1
;
// std::cout<< obj.track_id<<"valid----------------"<<std::endl;
// std::cout<< obj.track_id<<"valid----------------"<<std::endl;
}
else
{
}
else
{
// std::cout<< obj.track_id<<"dept
h----------------"<<std::endl;
std
::
cout
<<
obj
.
track_id
<<
"not enoug
h----------------"
<<
std
::
endl
;
return
-
1
;
// depth estimination
return
-
1
;
// depth estimination
}
}
}
else
{
}
else
{
...
@@ -1014,6 +1024,7 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
...
@@ -1014,6 +1024,7 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
}
}
}
}
// 获得高低差
// 获得高低差
std
::
cout
<<
"obj points size: "
<<
points3d
.
size
()
<<
std
::
endl
;
float
min_z
=
1e5
,
max_z
=
-
1e5
;
float
min_z
=
1e5
,
max_z
=
-
1e5
;
for
(
auto
&
p3d_
:
points3d
){
for
(
auto
&
p3d_
:
points3d
){
if
(
p3d_
.
z
>
max_z
){
if
(
p3d_
.
z
>
max_z
){
...
@@ -1023,8 +1034,9 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
...
@@ -1023,8 +1034,9 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
min_z
=
p3d_
.
z
;
min_z
=
p3d_
.
z
;
}
}
}
}
std
::
cout
<<
"object height: "
<<
max_z
-
min_z
<<
"m, max-z: "
<<
max_z
<<
"m."
<<
std
::
endl
;
bool
filtered
=
(
max_z
-
min_z
<
obstacle_height_threshold
*
0.01
)
||
(
max_z
<
obstacle_height_threshold
*
0.01
*
0.5
);
bool
filtered
=
(
max_z
-
min_z
<
obstacle_height_threshold
*
0.01
)
||
(
max_z
<
obstacle_height_threshold
*
0.01
*
0.5
);
if
(
obj
.
name
!=
"stone"
)
filtered
=
false
;
// dont filter pedestrian and vehicle
if
(
!
filtered
){
if
(
!
filtered
){
Tracks
[
obj
.
track_id
].
valid_frame_num
++
;
// add
Tracks
[
obj
.
track_id
].
valid_frame_num
++
;
// add
std
::
cout
<<
"------------------------ "
<<
obj
.
track_id
<<
": "
<<
obj
.
name
<<
" with "
<<
points3d
.
size
()
<<
std
::
cout
<<
"------------------------ "
<<
obj
.
track_id
<<
": "
<<
obj
.
name
<<
" with "
<<
points3d
.
size
()
<<
...
@@ -1038,6 +1050,8 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
...
@@ -1038,6 +1050,8 @@ int Visione_3D::Process_Instance_Objects(object_Seg_info& obj, const cv::Mat& in
vGrid
.
vInsObjs
.
push_back
(
insobj
);
vGrid
.
vInsObjs
.
push_back
(
insobj
);
obj
.
valid
=
obj
.
valid
+
1
;
obj
.
valid
=
obj
.
valid
+
1
;
}
}
}
else
{
std
::
cout
<<
"filtered!-------------------------"
<<
std
::
endl
;
}
}
// point enough, filtered by
// point enough, filtered by
}
}
...
@@ -1086,13 +1100,14 @@ int Visione_3D::Process_objects(const cv::Mat& image, const cv::Mat& depth, Clou
...
@@ -1086,13 +1100,14 @@ int Visione_3D::Process_objects(const cv::Mat& image, const cv::Mat& depth, Clou
point_index_in_camera
.
at
<
cv
::
Vec2i
>
(
y
,
x
)[
1
]
=
i
;
point_index_in_camera
.
at
<
cv
::
Vec2i
>
(
y
,
x
)[
1
]
=
i
;
}
}
if
(
vis_project
&&
i
%
sep
==
0
){
if
(
vis_project
&&
i
%
sep
==
0
){
auto
color
=
indexs
[
0
]
==
0
?
cv
::
Scalar
(
0
,
0
,
255
)
:
cv
::
Scalar
(
255
,
255
,
0
);
auto
color
=
indexs
[
0
]
==
0
?
cv
::
Scalar
(
0
,
0
,
100
)
:
cv
::
Scalar
(
255
,
255
,
0
);
cv
::
circle
(
cv_image
,
cv
::
Point
(
x
,
y
),
1
,
color
,
-
1
);
cv
::
circle
(
cv_image
,
cv
::
Point
(
x
,
y
),
1
,
color
,
-
1
);
}
}
}
}
}
}
}
}
std
::
cout
<<
" pcl2camera with "
<<
camera_cloud
->
size
()
<<
" points: "
<<
double
(
clock
()
-
start_
)
/
CLOCKS_PER_SEC
<<
"s"
<<
std
::
endl
;
//输出时间(单位:s)
std
::
cout
<<
" pcl2camera with "
<<
camera_cloud
->
size
()
<<
" points: "
<<
double
(
clock
()
-
start_
)
/
CLOCKS_PER_SEC
<<
"s"
<<
std
::
endl
;
//输出时间(单位:s)
std
::
cout
<<
"[Vision_3d.cpp] objs size = "
<<
objs
.
size
()
<<
std
::
endl
;
//循环每个目标
//循环每个目标
// start_ = clock();
// start_ = clock();
...
@@ -1125,6 +1140,8 @@ int Visione_3D::Process_objects(const cv::Mat& image, const cv::Mat& depth, Clou
...
@@ -1125,6 +1140,8 @@ int Visione_3D::Process_objects(const cv::Mat& image, const cv::Mat& depth, Clou
t
++
;
t
++
;
}
}
}
}
std
::
cout
<<
"[Vision_3d.cpp] Process_objects size = "
<<
vGrid
.
vInsObjs
.
size
()
<<
std
::
endl
;
// 将静态目标投影到栅格地图中
// 将静态目标投影到栅格地图中
pcl
::
PointXYZI
bev_point
;
pcl
::
PointXYZI
bev_point
;
...
...
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