Go to the documentation of this file.
51 template <
class CONTAINER>
53 const CONTAINER&
data,
const typename CONTAINER::key_type& searchkey)
56 if (upper ==
data.begin() || upper->first == searchkey)
return upper;
59 if (upper ==
data.end() ||
60 (searchkey - lower->first) < (upper->first - searchkey))
65 void rgbd2rawlog(
const string& src_path,
const string& out_name)
67 const string in_fil_acc = src_path +
string(
"/accelerometer.txt");
68 const string in_fil_depth =
70 ? src_path +
string(
"/ir.txt")
71 : src_path +
string(
"/depth.txt");
72 const string in_fil_rgb = src_path +
string(
"/rgb.txt");
79 map<double, string> list_rgb, list_depth;
80 map<double, vector<double>> list_acc;
81 std::istringstream line;
85 while (fparser.getNextLine(line))
89 if (line >> tim >> f) list_rgb[tim] = f;
95 while (fparser.getNextLine(line))
99 if (line >> tim >> f) list_depth[tim] = f;
105 while (fparser.getNextLine(line))
109 if (line >> tim >> ax >> ay >> az)
111 vector<double>&
v = list_acc[tim];
119 cout <<
"Parsed: " << list_depth.size() <<
" / " << list_rgb.size() <<
" / "
120 << list_acc.size() <<
" depth/rgb/acc entries.\n";
122 const bool only_ir = list_depth.size() > 10 && list_rgb.empty();
123 const bool only_rgb = list_depth.empty() && list_rgb.size() > 10;
126 const string out_img_dir = out_name +
string(
"_Images");
128 cout <<
"Creating images directory: " << out_img_dir << endl;
132 const string out_rawlog_fil = out_name +
string(
".rawlog");
133 cout <<
"Creating rawlog: " << out_rawlog_fil << endl;
144 const double FOCAL = 525.0;
165 unsigned int counter = 0;
166 if (!only_ir && !only_rgb)
169 it_list_rgb != list_rgb.end(); ++it_list_rgb)
171 cout <<
"Processing image " << counter <<
"\r";
181 std::abs(it_list_rgb->first - it_list_depth->first);
184 cout <<
"\nWarning: Discarding observation for too separated "
186 << At * 1e3 <<
" ms\n";
191 const double avrg_time =
192 .5 * (it_list_rgb->first + it_list_depth->first);
198 src_path +
string(
"/") + it_list_rgb->second);
199 const string sRGBfile =
202 out_img_dir +
string(
"/") + sRGBfile);
210 src_path +
string(
"/") + it_list_depth->second))
211 throw std::runtime_error(
212 string(
"Error loading depth image!: ") +
213 it_list_depth->second);
215 const unsigned int w = depth_img.
getWidth();
216 const unsigned int h = depth_img.
getHeight();
219 for (
unsigned int row = 0;
row < h;
row++)
223 for (
unsigned int col = 0; col <
w; col++)
227 const string sDepthfile =
230 sDepthfile, out_img_dir +
string(
"/"));
238 const double At_acc =
239 std::abs(it_list_rgb->first - it_list_acc->first);
258 it_list_depth != list_depth.end(); ++it_list_depth)
260 cout <<
"Processing image " << counter <<
"\r";
264 const double avrg_time = it_list_depth->first;
273 src_path +
string(
"/") + it_list_depth->second))
274 throw std::runtime_error(
275 string(
"Error loading depth image!: ") +
276 it_list_depth->second);
278 const unsigned int w = depth_img.
getWidth();
279 const unsigned int h = depth_img.
getHeight();
282 for (
unsigned int row = 0;
row < h;
row++)
286 for (
unsigned int col = 0; col <
w; col++)
290 const string sDepthfile =
293 sDepthfile, out_img_dir +
string(
"/"));
302 it_list_rgb != list_rgb.end(); ++it_list_rgb)
304 cout <<
"Processing image " << counter <<
"\r";
308 const double avrg_time = it_list_rgb->first;
314 src_path +
string(
"/") + it_list_rgb->second);
315 const string sRGBfile =
mrpt::format(
"%.06f_rgb.png", avrg_time);
324 cout <<
"\nAll done!\n";
330 int main(
int argc,
char** argv)
336 cerr <<
"Usage: " << argv[0]
337 <<
" [PATH_TO_RGBD_DATASET] [OUTPUT_NAME]\n";
345 catch (std::exception& e)
347 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
352 printf(
"Untyped exception!!");
std::string sensorLabel
An arbitrary label that can be used to identify the sensor.
std::vector< double > rawMeasurements
The accelerometer and/or gyroscope measurements taken by the IMU at the given timestamp.
size_t getWidth() const override
Returns the width of the image in pixels.
bool range_is_depth
true: Kinect-like ranges: entries of rangeImage are distances along the +X axis; false: Ranges in ran...
const Scalar * const_iterator
unsigned __int16 uint16_t
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 cameraParamsIntensity
Projection parameters of the intensity (graylevel or RGB) camera.
double fx() const
Get the value of the focal length x-value (in pixels).
uint32_t ncols
Camera resolution.
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
GLubyte GLubyte GLubyte GLubyte w
This class stores measurements from an Inertial Measurement Unit (IMU) (attitude estimation,...
bool fileExists(const std::string &fileName)
Test if a given file (or directory) exists.
void rangeImage_setSize(const int HEIGHT, const int WIDTH)
Similar to calling "rangeImage.setSize(H,W)" but this method provides memory pooling to speed-up the ...
double cy() const
Get the value of the principal point y-coordinate (in pixels).
This namespace contains representation of robot actions and observations.
mrpt::system::TTimeStamp timestamp
The associated UTC time-stamp.
mrpt::img::TCamera cameraParams
Projection parameters of the depth camera.
double fy() const
Get the value of the focal length y-value (in pixels).
mrpt::poses::CPose3D relativePoseIntensityWRTDepth
Relative pose of the intensity camera wrt the depth camera (which is the coordinates origin for this ...
GLsizei GLsizei GLenum GLenum const GLvoid * data
mrpt::img::CImage intensityImage
If hasIntensityImage=true, a color or gray-level intensity image of the same size than "rangeImage".
Declares a class derived from "CObservation" that encapsules a 3D range scan measurement,...
void rgbd2rawlog(const string &src_path, const string &out_name)
double cx() const
Get the value of the principal point x-coordinate (in pixels).
@ IMU_Z_ACC
z-axis acceleration (local/vehicle frame) (m/sec2)
CONTAINER::const_iterator find_closest(const CONTAINER &data, const typename CONTAINER::key_type &searchkey)
std::string format(const char *fmt,...) MRPT_printf_format_check(1
A std::string version of C sprintf.
Saves data to a file and transparently compress the data using the given compression level.
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
bool hasIntensityImage
true means the field intensityImage contains valid data
bool hasRangeImage
true means the field rangeImage contains valid data
unsigned char * get_unsafe(unsigned int col, unsigned int row, unsigned int channel=0) const
Access to pixels without checking boundaries - Use normally the () operator better,...
@ IMU_X_ACC
x-axis acceleration (local/vehicle frame) (m/sec2)
A class for storing images as grayscale or RGB bitmaps.
std::vector< bool > dataIsPresent
Each entry in this vector is true if the corresponding data index contains valid data (the IMU unit s...
bool saveToFile(const std::string &fileName, int jpeg_quality=95) const
Save the image to a file, whose format is determined from the extension (internally uses OpenCV).
CArchiveStreamBase< STREAM > archiveFrom(STREAM &s)
Helper function to create a templatized wrapper CArchive object for a: MRPT's CStream,...
@ IMU_Y_ACC
y-axis acceleration (local/vehicle frame) (m/sec2)
mrpt::math::CMatrix rangeImage
If hasRangeImage=true, a matrix of floats with the range data as captured by the camera (in meters)
size_t getHeight() const override
Returns the height of the image in pixels.
GLenum GLenum GLvoid * row
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 rangeImage_convertToExternalStorage(const std::string &fileName, const std::string &use_this_base_dir)
Users won't normally want to call this, it's only used from internal MRPT programs.
A class for parsing text files, returning each non-empty and non-comment line, along its line number.
GLsizei const GLchar ** string
bool createDirectory(const std::string &dirName)
Creates a directory.
bool loadFromFile(const std::string &fileName, int isColor=-1)
Load image from a file, whose format is determined from the extension (internally uses OpenCV).
void rangeImage_forceResetExternalStorage()
Forces marking this observation as non-externally stored - it doesn't anything else apart from reseti...
double DEG2RAD(const double x)
Degrees to radians.
Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST | |