50 bool is_kitti_dataset,
const string& src_path0,
const string& src_path1,
51 const string& calib_file,
const string& out_name)
70 bool p1_ok =
false, p2_ok =
false;
72 const string name_P0 = is_kitti_dataset ?
"P0:" :
"P1_roi:";
73 const string name_P1 = is_kitti_dataset ?
"P1:" :
"P2_roi:";
75 std::istringstream ss;
97 throw std::runtime_error(
"Couldn't load P*_ROI calib matrices!");
100 cam_params_l.
ncols = 1344;
101 cam_params_l.
nrows = 391;
102 cam_params_l.
fx(P2_roi(0, 0));
103 cam_params_l.
fy(P2_roi(0, 5));
104 cam_params_l.
cx(P2_roi(0, 2));
105 cam_params_l.
cy(P2_roi(0, 6));
110 const double baseline = -P2_roi(0, 3) / P2_roi(0, 0);
114 cout <<
"baseline: " << baseline << endl;
117 const string out_rawlog_fil = out_name + string(
".rawlog");
118 const string out_imgs_dir = out_name + string(
"_Images");
119 cout <<
"Creating rawlog: " << out_rawlog_fil << endl;
122 if (is_kitti_dataset)
124 cout <<
"Creating imgs dir: " << out_imgs_dir << endl;
131 for (
int i = 0;; i++)
133 string sImgFile_L, sImgFile_R;
134 string sImg_L, sImg_R;
135 string sTrgImgFile_L, sTrgImgFile_R;
136 string sTrgImg_L, sTrgImg_R;
138 if (is_kitti_dataset)
145 mrpt::format(
"%s/%s", src_path0.c_str(), sImgFile_L.c_str());
147 mrpt::format(
"%s/%s", src_path1.c_str(), sImgFile_R.c_str());
149 sTrgImgFile_L =
mrpt::format(
"I0_%s", sImgFile_L.c_str());
150 sTrgImgFile_R =
mrpt::format(
"I1_%s", sImgFile_R.c_str());
153 "%s/%s", out_imgs_dir.c_str(), sTrgImgFile_L.c_str());
155 "%s/%s", out_imgs_dir.c_str(), sTrgImgFile_R.c_str());
163 sTrgImgFile_L = sImgFile_L;
164 sTrgImgFile_R = sImgFile_R;
166 mrpt::format(
"%s/%s", src_path0.c_str(), sImgFile_L.c_str());
168 mrpt::format(
"%s/%s", src_path0.c_str(), sImgFile_R.c_str());
174 cout <<
"Couldn't detect image pair " << sImg_L <<
" | " << sImg_R
183 0, 0, 0, -90.0_deg, 0.0_deg,
DEG2RAD(-90.0 - 4.6)));
198 if (is_kitti_dataset)
202 cerr <<
"Error copying file: " << sImg_L <<
" => " << sTrgImg_L
208 cerr <<
"Error copying file: " << sImg_R <<
" => " << sTrgImg_R
217 cout <<
"\nAll done!\n";
231 " kitti_dataset2rawlog [PATH_TO_DIR_WITH_IMAGES] " 232 "[CALIB_FILE] [OUTPUT_NAME]\n" 234 " kitti_dataset2rawlog [PATH_TO_IMAGE_00] " 235 "[PATH_TO_IMAGE_01] [CALIB_FILE] [OUTPUT_NAME]\n";
252 catch (
const std::exception& e)
259 printf(
"Untyped exception!!");
bool createDirectory(const std::string &dirName)
Creates a directory.
mrpt::img::CImage imageLeft
Image from the left camera (this image will be ALWAYS present)
double fx() const
Get the value of the focal length x-value (in pixels).
std::string std::string format(std::string_view fmt, ARGS &&... args)
bool strStartsI(const std::string &str, const std::string &subStr)
Return true if "str" starts with "subStr" (case insensitive)
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
double fy() const
Get the value of the focal length y-value (in pixels).
A class for parsing text files, returning each non-empty and non-comment line, along its line number...
mrpt::system::TTimeStamp now()
A shortcut for system::getCurrentTime.
void setExternalStorage(const std::string &fileName) noexcept
By using this method the image is marked as referenced to an external file, which will be loaded only...
void stereo2rawlog(bool is_kitti_dataset, const string &src_path0, const string &src_path1, const string &calib_file, const string &out_name)
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream, std::istream, std::ostream, std::stringstream.
mrpt::poses::CPose3DQuat cameraPose
The pose of the LEFT camera, relative to the robot.
#define ASSERT_(f)
Defines an assertion mechanism.
mrpt::Clock::time_point TTimeStamp
A system independent time type, it holds the the number of 100-nanosecond intervals since January 1...
double cy() const
Get the value of the principal point y-coordinate (in pixels).
double timestampTotime_t(const mrpt::system::TTimeStamp t) noexcept
Transform from TTimeStamp to standard "time_t" (actually a double number, it can contain fractions of...
Observation class for either a pair of left+right or left+disparity images from a stereo camera...
This namespace contains representation of robot actions and observations.
Parameters for the Brown-Conrady camera lens distortion model.
void open(const std::string &fil)
Open a file (an alternative to the constructor with a file name)
bool getNextLine(std::string &out_str)
Reads from the file and return the next (non-comment) line, as a std::string.
mrpt::img::TCamera rightCamera
A class used to store a 3D pose as a translation (x,y,z) and a quaternion (qr,qx,qy,qz).
size_type rows() const
Number of rows in the matrix.
size_type cols() const
Number of columns in the matrix.
double cx() const
Get the value of the principal point x-coordinate (in pixels).
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::poses::CPose3DQuat rightCameraPose
The pose of the right camera, relative to the left one: Note that using the conventional reference co...
std::string exception_to_str(const std::exception &e)
Builds a nice textual representation of a nested exception, which if generated using MRPT macros (THR...
bool copyFile(const std::string &sourceFile, const std::string &targetFile, std::string *outErrStr=nullptr, bool copyAttribs=true)
Copies file sourceFile to targetFile.
A quaternion, which can represent a 3D rotation as pair , with a real part "r" and a 3D vector ...
Saves data to a file and transparently compress the data using the given compression level...
mrpt::system::TTimeStamp time_tToTimestamp(const double t)
Transform from standard "time_t" (actually a double number, it can contain fractions of seconds) to T...
mrpt::img::TCamera leftCamera
Parameters for the left/right cameras: individual intrinsic and distortion parameters of the cameras...
uint32_t ncols
Camera resolution.
mrpt::img::CImage imageRight
Image from the right camera, only contains a valid image if hasImageRight == true.
void loadFromTextFile(std::istream &f)
Loads a vector/matrix from a text file, compatible with MATLAB text format.