Skip to content

Commit ecbc22c

Browse files
more marker stuff
1 parent 8396148 commit ecbc22c

File tree

6 files changed

+85
-58
lines changed

6 files changed

+85
-58
lines changed

config/eod_example.rviz

Lines changed: 24 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,9 @@ Panels:
33
Help Height: 87
44
Name: Displays
55
Property Tree Widget:
6-
Expanded:
7-
- /TF1/Status1
8-
- /SimpleObjects1/Status1
6+
Expanded: ~
97
Splitter Ratio: 0.5
10-
Tree Height: 669
8+
Tree Height: 361
119
- Class: rviz/Selection
1210
Name: Selection
1311
- Class: rviz/Tool Properties
@@ -57,7 +55,7 @@ Visualization Manager:
5755
Frame Timeout: 15
5856
Frames:
5957
All Enabled: true
60-
dai_rgb_optical_frame:
58+
dai_rgb_camera_optical_frame:
6159
Value: true
6260
map:
6361
Value: true
@@ -89,23 +87,8 @@ Visualization Manager:
8987
Show Names: true
9088
Tree:
9189
map:
92-
dai_rgb_optical_frame:
90+
dai_rgb_camera_optical_frame:
9391
{}
94-
oak-d-base-frame:
95-
oak-d_frame:
96-
oak_imu_frame:
97-
{}
98-
oak_left_camera_frame:
99-
oak_left_camera_optical_frame:
100-
{}
101-
oak_model_origin:
102-
{}
103-
oak_rgb_camera_frame:
104-
oak_rgb_camera_optical_frame:
105-
{}
106-
oak_right_camera_frame:
107-
oak_right_camera_optical_frame:
108-
{}
10992
Update Interval: 0
11093
Value: true
11194
- Alpha: 1
@@ -141,7 +124,8 @@ Visualization Manager:
141124
Marker Topic: /extended_object_detection/simple_objects_markers
142125
Name: SimpleObjects
143126
Namespaces:
144-
{}
127+
CnnPerson_arrow: true
128+
CnnPerson_frame: true
145129
Queue Size: 100
146130
Value: true
147131
- Class: rviz/MarkerArray
@@ -164,6 +148,18 @@ Visualization Manager:
164148
Transport Hint: raw
165149
Unreliable: false
166150
Value: true
151+
- Class: rviz/Image
152+
Enabled: true
153+
Image Topic: /rgb_stereo_publisher/stereo/depth
154+
Max Value: 1
155+
Median window: 5
156+
Min Value: 0
157+
Name: DepthImage
158+
Normalize Range: false
159+
Queue Size: 2
160+
Transport Hint: raw
161+
Unreliable: false
162+
Value: true
167163
Enabled: true
168164
Global Options:
169165
Background Color: 48; 48; 48
@@ -200,9 +196,9 @@ Visualization Manager:
200196
Value: false
201197
Field of View: 0.7853981852531433
202198
Focal Point:
203-
X: 1.0510656833648682
204-
Y: -0.8599390387535095
205-
Z: -0.3137734830379486
199+
X: 1.1988993883132935
200+
Y: -0.6332588195800781
201+
Z: -0.4015747904777527
206202
Focal Shape Fixed Size: true
207203
Focal Shape Size: 0.05000000074505806
208204
Invert Z Axis: false
@@ -213,14 +209,16 @@ Visualization Manager:
213209
Yaw: 2.4104363918304443
214210
Saved: ~
215211
Window Geometry:
212+
DepthImage:
213+
collapsed: false
216214
Detected Image:
217215
collapsed: false
218216
Displays:
219217
collapsed: false
220218
Height: 1015
221219
Hide Left Dock: false
222220
Hide Right Dock: false
223-
QMainWindow State: 000000ff00000000fd00000004000000000000016a00000341fc0200000008fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000007901000003fb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c006100790073010000004200000341000000fd01000003fb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261000000010000037e00000341fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fc0000004200000341000000ef0100001bfa000000000100000002fb0000001c0044006500740065006300740065006400200049006d0061006700650100000000ffffffff000000a201000003fb0000000a005600690065007700730100000670000001100000011001000003fb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000780000001e8fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007800000004efc0100000002fb0000000800540069006d0065010000000000000780000002ad01000003fb0000000800540069006d00650100000000000004500000000000000000000002960000034100000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
221+
QMainWindow State: 000000ff00000000fd00000004000000000000016a00000341fc0200000009fb0000001200530065006c0065006300740069006f006e00000001e10000009b0000007901000003fb0000001e0054006f006f006c002000500072006f007000650072007400690065007302000001ed000001df00000185000000a3fb000000120056006900650077007300200054006f006f02000001df000002110000018500000122fb000000200054006f006f006c002000500072006f0070006500720074006900650073003203000002880000011d000002210000017afb000000100044006900730070006c00610079007301000000420000020d000000fd01000003fb0000002000730065006c0065006300740069006f006e00200062007500660066006500720200000138000000aa0000023a00000294fb00000014005700690064006500530074006500720065006f02000000e6000000d2000003ee0000030bfb0000000c004b0069006e0065006300740200000186000001060000030c00000261fb00000014004400650070007400680049006d0061006700650100000250000001330000002201000003000000010000031100000341fc0200000003fb0000001e0054006f006f006c002000500072006f00700065007200740069006500730100000041000000780000000000000000fc0000004200000341000000ef0100001bfa000000000100000002fb0000001c0044006500740065006300740065006400200049006d0061006700650100000000ffffffff000000a201000003fb0000000a005600690065007700730100000670000001100000011001000003fb0000001200530065006c0065006300740069006f006e010000025a000000b200000000000000000000000200000780000001e8fc0100000001fb0000000a00560069006500770073030000004e00000080000002e10000019700000003000007800000004efc0100000002fb0000000800540069006d0065010000000000000780000002ad01000003fb0000000800540069006d00650100000000000004500000000000000000000003030000034100000004000000040000000800000008fc0000000100000002000000010000000a0054006f006f006c00730100000000ffffffff0000000000000000
224222
Selection:
225223
collapsed: false
226224
Time:

config/object_base_example/ObjectBaseExample.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@
8282

8383
<Attribute Name="StickerRoughDist" Type="RoughDist" realWidth="0.075"/>
8484

85-
<!--<Attribute Name="DepthKinect" Type="Depth" depthScale="0.001"/>-->
85+
<Attribute Name="DepthKinect" Type="Depth" depthScale="0.001"/>
8686

8787
<Attribute Name="DlibFace" Type="FaceDlib" Probability="0.4" base_file_path="face_recognition/base_faces.db" base_dir_path="face_recognition/base_faces/" sp_path="face_recognition/shape_predictor_5_face_landmarks.dat" net_path="face_recognition/dlib_face_recognition_resnet_model_v1.dat"/>
8888

@@ -255,6 +255,7 @@
255255
<SimpleObject Name="CnnPerson" ID="67">
256256
<Attribute Type="Detect">COCO_Dnn</Attribute>
257257
<Attribute Type="Check">COCO_person</Attribute>
258+
<Attribute Type="Extract" Channel="DEPTH">DepthKinect</Attribute>
258259

259260
</SimpleObject>
260261

launch/extended_object_detection_oakd_example.launch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
<remap from="depth/image_raw" to="/rgb_stereo_publisher/stereo/depth"/>
2222
<remap from="depth/info" to="/rgb_stereo_publisher/stereo/camera_info"/>
2323

24-
<rosparam param="selected_on_start_simple_objects">[]</rosparam>
24+
<rosparam param="selected_on_start_simple_objects">[67]</rosparam>
2525
<rosparam param="selected_on_start_complex_objects">[-1]</rosparam>
2626

2727
</node>

src/extended_object_detection_node/eod_node.cpp

Lines changed: 55 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,14 @@ geometry_msgs::Vector3 multiplyVectorScalar(geometry_msgs::Vector3 vector, doubl
2323
return new_vector;
2424
}
2525

26+
geometry_msgs::Point fromVector(const geometry_msgs::Vector3& vector){
27+
geometry_msgs::Point point;
28+
point.x = vector.x;
29+
point.y = vector.y;
30+
point.z = vector.z;
31+
return point;
32+
}
33+
2634
EOD_ROS::EOD_ROS(ros::NodeHandle nh, ros::NodeHandle nh_p){
2735
nh_ = nh;
2836
nh_p_ = nh_p;
@@ -181,7 +189,7 @@ void EOD_ROS::rgbd_info_cb(const sensor_msgs::ImageConstPtr& rgb_image, const se
181189
}
182190

183191
eod::InfoImage ii_rgb = eod::InfoImage(rgb, getK(rgb_info), getD(rgb_info) );
184-
eod::InfoImage ii_depth = eod::InfoImage(depth, getK(depth_info), cv::Mat() );
192+
eod::InfoImage ii_depth = eod::InfoImage(depth, getK(depth_info), getD(depth_info) );
185193

186194
detect(ii_rgb, ii_depth, rgb_image->header);
187195
}
@@ -219,7 +227,9 @@ void EOD_ROS::detect(const eod::InfoImage& rgb, const eod::InfoImage& depth, std
219227
visualization_msgs::MarkerArray mrk_array_msg;
220228
int id_cnt = 0;
221229
for(auto& bo : simples_msg.objects){
222-
mrk_array_msg.markers.push_back(base_object_to_marker_arrow(bo, rgb.K(), header, cv::Scalar(0, 255, 0),id_cnt++));
230+
mrk_array_msg.markers.push_back(base_object_to_marker_arrow(bo, rgb.K(), header, cv::Scalar(0, 255, 0),id_cnt));
231+
mrk_array_msg.markers.push_back(base_object_to_marker_frame(bo, rgb.K(), header, cv::Scalar(0, 255, 0),id_cnt));
232+
id_cnt++;
223233
}
224234
simple_objects_markers_pub_.publish(mrk_array_msg);
225235
}
@@ -245,28 +255,11 @@ extended_object_detection::BaseObject EOD_ROS::eoi_to_base_object( eod::SimpleOb
245255
bo.type_id = so->ID;
246256
bo.type_name = so->name;
247257
bo.score = eoi->total_score;
248-
258+
// extracted info
249259
for( auto& exi : eoi->extracted_info){
250260
bo.extracted_info.keys.push_back(exi.first);
251261
bo.extracted_info.values.push_back(exi.second);
252-
}
253-
// rect
254-
bo.rect.left_bottom.x = eoi->x;
255-
bo.rect.left_bottom.y = eoi->y;
256-
bo.rect.right_up.x = eoi->x + eoi->width;
257-
bo.rect.right_up.y = eoi->y + eoi->height;
258-
259-
// translation to rect's corners
260-
geometry_msgs::Vector3 temp_translation;
261-
temp_translation = getUnitTranslation(cv::Point(eoi->x, eoi->y), K);
262-
bo.rect.cornerTranslates.push_back(temp_translation);
263-
temp_translation = getUnitTranslation(cv::Point(eoi->x, eoi->y + eoi->width), K);
264-
bo.rect.cornerTranslates.push_back(temp_translation);
265-
temp_translation = getUnitTranslation(cv::Point(eoi->x + eoi->height, eoi->y + eoi->width), K);
266-
bo.rect.cornerTranslates.push_back(temp_translation);
267-
temp_translation = getUnitTranslation(cv::Point(eoi->x + eoi->height, eoi->y), K);
268-
bo.rect.cornerTranslates.push_back(temp_translation);
269-
262+
}
270263
// translation
271264
if( eoi->tvec.size() > 0 ){
272265
bo.transform.translation.x = eoi->tvec[0][0];
@@ -286,25 +279,40 @@ extended_object_detection::BaseObject EOD_ROS::eoi_to_base_object( eod::SimpleOb
286279
bo.transform.rotation.y = quaternion[1];
287280
bo.transform.rotation.z = quaternion[2];
288281
bo.transform.rotation.w = quaternion[3];
289-
}
282+
}
290283
else // use zero quaternion
291284
bo.transform.rotation.w = 1;
285+
286+
// rect
287+
bo.rect.left_bottom.x = eoi->x;
288+
bo.rect.left_bottom.y = eoi->y;
289+
bo.rect.right_up.x = eoi->x + eoi->width;
290+
bo.rect.right_up.y = eoi->y + eoi->height;
291+
292+
// translation to rect's corners
293+
geometry_msgs::Vector3 temp_translation;
294+
temp_translation = multiplyVectorScalar(getUnitTranslation(cv::Point(eoi->x, eoi->y), K),bo.transform.translation.z);
295+
bo.rect.cornerTranslates.push_back(temp_translation);
296+
temp_translation = multiplyVectorScalar(getUnitTranslation(cv::Point(eoi->x, eoi->y + eoi->height), K),bo.transform.translation.z);
297+
bo.rect.cornerTranslates.push_back(temp_translation);
298+
temp_translation = multiplyVectorScalar(getUnitTranslation(cv::Point(eoi->x + eoi->width, eoi->y + eoi->height), K),bo.transform.translation.z);
299+
bo.rect.cornerTranslates.push_back(temp_translation);
300+
temp_translation = multiplyVectorScalar(getUnitTranslation(cv::Point(eoi->x + eoi->width, eoi->y), K),bo.transform.translation.z);
301+
bo.rect.cornerTranslates.push_back(temp_translation);
302+
292303

293304
//TODO tracks
294305
return bo;
295306
}
296307

297-
visualization_msgs::Marker EOD_ROS::base_object_to_marker_arrow(extended_object_detection::BaseObject base_object, const cv::Mat& K, std_msgs::Header header, cv::Scalar color, int id){
308+
visualization_msgs::Marker EOD_ROS::base_object_to_marker_arrow(extended_object_detection::BaseObject& base_object, const cv::Mat& K, std_msgs::Header header, cv::Scalar color, int id){
298309
visualization_msgs::Marker mrk;
299310
mrk.header = header;
300311
mrk.ns = base_object.type_name +"_arrow";
301312
mrk.id = id;
302313
mrk.type = visualization_msgs::Marker::ARROW;
303314
mrk.points.push_back(geometry_msgs::Point());
304-
geometry_msgs::Point end;
305-
end.x = base_object.transform.translation.x;
306-
end.y = base_object.transform.translation.y;
307-
end.z = base_object.transform.translation.z;
315+
geometry_msgs::Point end = fromVector(base_object.transform.translation);
308316
mrk.points.push_back(end);
309317
mrk.scale.x = 0.01;
310318
mrk.scale.y = 0.02;
@@ -317,6 +325,26 @@ visualization_msgs::Marker EOD_ROS::base_object_to_marker_arrow(extended_object_
317325
return mrk;
318326
}
319327

328+
visualization_msgs::Marker EOD_ROS::base_object_to_marker_frame(extended_object_detection::BaseObject& base_object, const cv::Mat& K, std_msgs::Header header, cv::Scalar color, int id){
329+
visualization_msgs::Marker mrk;
330+
mrk.header = header;
331+
mrk.ns = base_object.type_name +"_frame";
332+
mrk.id = id;
333+
mrk.type = visualization_msgs::Marker::LINE_STRIP;
334+
for( auto& corner : base_object.rect.cornerTranslates )
335+
mrk.points.push_back(fromVector(corner));
336+
mrk.points.push_back(mrk.points[0]);
337+
mrk.scale.x = 0.02;
338+
mrk.scale.y = 0.02;
339+
mrk.scale.z = 0.1;
340+
mrk.pose.orientation.w = 1;
341+
mrk.color.r = color[0]/255;
342+
mrk.color.g = color[1]/255;
343+
mrk.color.b = color[2]/255;
344+
mrk.color.a = 1;
345+
return mrk;
346+
}
347+
320348
int EOD_ROS::find_simple_obj_index_by_id(int id){
321349
for( int i = 0 ; i < selected_simple_objects.size() ; i++ ){
322350
if( selected_simple_objects[i]->ID == id )

src/extended_object_detection_node/eod_node.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,8 @@ class EOD_ROS{
8484
cv::Mat getK(const sensor_msgs::CameraInfoConstPtr& info_msg);
8585
cv::Mat getD(const sensor_msgs::CameraInfoConstPtr& info_msg);
8686

87-
visualization_msgs::Marker base_object_to_marker_arrow(extended_object_detection::BaseObject base_object, const cv::Mat& K, std_msgs::Header header, cv::Scalar color, int id);
88-
87+
visualization_msgs::Marker base_object_to_marker_arrow(extended_object_detection::BaseObject& base_object, const cv::Mat& K, std_msgs::Header header, cv::Scalar color, int id);
88+
visualization_msgs::Marker base_object_to_marker_frame(extended_object_detection::BaseObject& base_object, const cv::Mat& K, std_msgs::Header header, cv::Scalar color, int id);
8989

9090
int find_simple_obj_index_by_id(int id);
9191

src/lib

0 commit comments

Comments
 (0)