Skip to content

Commit 2e10516

Browse files
committed
[ H264 Codec ] : Resolves h264 video encoding problems
1 parent 4e3b8af commit 2e10516

File tree

5 files changed

+114
-9
lines changed

5 files changed

+114
-9
lines changed

Examples/ROS/ORB_SLAM3/Tello.yaml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
%YAML:1.0
2+
3+
# Camera calibration and distortion parameters (OpenCV)
4+
Camera.type: "PinHole"
5+
6+
Camera.fx: 924.873180
7+
Camera.fy: 923.504522
8+
Camera.cx: 486.997346
9+
Camera.cy: 364.308527
10+
11+
# data: [ 924.873180, 0.000000 , 486.997346,
12+
# 0.000000 , 923.504522, 364.308527,
13+
# 0.000000 , 0.000000 , 1.000000 ]
14+
15+
# [ fx 0 cx]
16+
# [ 0 fy cy]
17+
# [ 0 0 1 ]
18+
19+
20+
Camera.k1: -0.034749
21+
Camera.k2: 0.071514
22+
Camera.p1: 0.000363
23+
Camera.p2: 0.003131
24+
Camera.k3: 0.0
25+
26+
# data: [-0.034749, 0.071514, 0.000363, 0.003131, 0.000000]
27+
28+
29+
Camera.width: 960
30+
Camera.height: 720
31+
32+
# Camera frames per second
33+
# Camera.fps: 60.0
34+
Camera.fps: 30.0
35+
36+
# Color order of the images (0: BGR, 1: RGB. It is ignored if images are grayscale)
37+
Camera.RGB: 1
38+
39+
#--------------------------------------------------------------------------------------------
40+
# ORB Parameters
41+
#--------------------------------------------------------------------------------------------
42+
43+
# ORB Extractor: Number of features per image
44+
ORBextractor.nFeatures: 10000
45+
46+
# ORB Extractor: Scale factor between levels in the scale pyramid
47+
ORBextractor.scaleFactor: 1.15
48+
49+
# ORB Extractor: Number of levels in the scale pyramid
50+
ORBextractor.nLevels: 10
51+
52+
# ORB Extractor: Fast threshold
53+
# Image is divided in a grid. At each cell FAST are extracted imposing a minimum response.
54+
# Firstly we impose iniThFAST. If no corners are detected we impose a lower value minThFAST
55+
# You can lower these values if your images have low contrast
56+
ORBextractor.iniThFAST: 20
57+
ORBextractor.minThFAST: 14
58+
59+
60+
# image_width: 960
61+
#hanged the resolution of the cameras so as to have the biggest resolution they can. The results seem similar for the camera matrix, but the distorti
62+
#image_height: 720
63+
# camera_name: narrow_stereo
64+
# camera_matrix:
65+
# rows: 3
66+
# cols: 3
67+
# data: [ 924.873180, 0.000000 , 486.997346,
68+
# 0.000000 , 923.504522, 364.308527,
69+
# 0.000000 , 0.000000 , 1.000000 ]
70+
71+
# [ fx 0 cx]
72+
# [ 0 fy cy]
73+
# [ 0 0 1 ]
74+
# distortion_model: plumb_bob
75+
# distortion_coefficients:
76+
# rows: 1
77+
# cols: 5
78+
# data: [-0.034749, 0.071514, 0.000363, 0.003131, 0.000000]
79+
# rectification_matrix:
80+
# rows: 3
81+
# cols: 3
82+
# data: [ 1.000000, 0.000000, 0.000000,
83+
# 0.000000, 1.000000, 0.000000,
84+
# 0.000000, 0.000000, 1.000000]
85+
# projection_matrix:
86+
# rows: 3
87+
# cols: 4
88+
# data: [ 921.967102, 0.000000 , 489.492281, 0.000000,
89+
# 0.000000 , 921.018890, 364.508536, 0.000000,
90+
# 0.000000 , 0.000000 , 1.000000 , 0.000000]
91+
92+
Viewer.KeyFrameSize: 0.05
93+
Viewer.KeyFrameLineWidth: 1
94+
Viewer.GraphLineWidth: 0.9
95+
Viewer.PointSize:2
96+
Viewer.CameraSize: 0.08
97+
Viewer.CameraLineWidth: 3
98+
Viewer.ViewpointX: 0
99+
Viewer.ViewpointY: -0.7
100+
Viewer.ViewpointZ: -1.8
101+
Viewer.ViewpointF: 500

Examples/ROS/ORB_SLAM3/src/ros_mono.cc

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@
1818

1919
#include <iostream>
2020
#include <ros/ros.h>
21+
#include <sensor_msgs/CompressedImage.h>
2122
#include <cv_bridge/cv_bridge.h>
22-
#include <sensor_msgs/Image.h>
23+
#include <image_transport/image_encoding.h>
2324
#include <opencv2/core.hpp>
2425
#include "../../../include/System.h"
2526

@@ -30,7 +31,7 @@ class ImageGrabber
3031
public:
3132
ImageGrabber(ORB_SLAM3::System* pSLAM) : mpSLAM(pSLAM) {}
3233

33-
void GrabImage(const sensor_msgs::ImageConstPtr& msg);
34+
void GrabImage(const sensor_msgs::CompressedImageConstPtr& msg);
3435

3536
ORB_SLAM3::System* mpSLAM;
3637
};
@@ -53,7 +54,7 @@ int main(int argc, char** argv)
5354
ImageGrabber igb(&SLAM);
5455

5556
ros::NodeHandle nodeHandler;
56-
ros::Subscriber sub = nodeHandler.subscribe("/camera/image_raw", 1, &ImageGrabber::GrabImage, &igb);
57+
ros::Subscriber sub = nodeHandler.subscribe("/camera/image_raw/compressed", 1, &ImageGrabber::GrabImage, &igb);
5758

5859
ros::spin();
5960

@@ -68,13 +69,13 @@ int main(int argc, char** argv)
6869
return 0;
6970
}
7071

71-
void ImageGrabber::GrabImage(const sensor_msgs::ImageConstPtr& msg)
72+
void ImageGrabber::GrabImage(const sensor_msgs::CompressedImageConstPtr& msg)
7273
{
7374
// Copy the ros image message to cv::Mat.
7475
cv_bridge::CvImageConstPtr cv_ptr;
7576
try
7677
{
77-
cv_ptr = cv_bridge::toCvShare(msg);
78+
cv_ptr = cv_bridge::toCvCopy(msg,image_transport::ImageEncodings::BGR8 );
7879
}
7980
catch (cv_bridge::Exception& e)
8081
{
@@ -83,4 +84,4 @@ void ImageGrabber::GrabImage(const sensor_msgs::ImageConstPtr& msg)
8384
}
8485

8586
mpSLAM->TrackMonocular(cv_ptr->image, cv_ptr->header.stamp.toSec());
86-
}
87+
}

Examples/ROS/ORB_SLAM3/src/ros_mono_inertial.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ int main(int argc, char **argv)
9292
ImageGrabber igb(&SLAM,&imugb,bEqual);
9393

9494
// Maximum delay, 5 seconds
95-
ros::Subscriber sub_imu = n.subscribe("/imu", 1000, &ImuGrabber::GrabImu, &imugb);
96-
ros::Subscriber sub_img0 = n.subscribe("/camera/image_raw", 100, &ImageGrabber::GrabImage,&igb);
95+
ros::Subscriber sub_imu = n.subscribe("/tello/imu", 1000, &ImuGrabber::GrabImu, &imugb);
96+
ros::Subscriber sub_img0 = n.subscribe("/tello/image_raw", 100, &ImageGrabber::GrabImage,&igb);
9797

9898
std::thread sync_thread(&ImageGrabber::SyncWithImu,&igb);
9999

Examples/ROS/ORB_SLAM3/src/ros_stereo_inertial.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ int main(int argc, char **argv)
132132
}
133133

134134
// Maximum delay, 5 seconds
135-
ros::Subscriber sub_imu = n.subscribe("/imu", 1000, &ImuGrabber::GrabImu, &imugb);
135+
ros::Subscriber sub_imu = n.subscribe("/tello/imu", 1000, &ImuGrabber::GrabImu, &imugb);
136136
ros::Subscriber sub_img_left = n.subscribe("/camera/left/image_raw", 100, &ImageGrabber::GrabImageLeft, &igb);
137137
ros::Subscriber sub_img_right = n.subscribe("/camera/right/image_raw", 100, &ImageGrabber::GrabImageRight, &igb);
138138

get_map.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Don't Forget to connect the tello drone first with the camera topic
2+
3+
rosrun ORB_SLAM3 Mono ~/ORB_SLAM3/Vocabulary/ORBvoc.txt ~/ORB_SLAM3/Examples/ROS/ORB_SLAM3/Tello.yaml

0 commit comments

Comments
 (0)