23 #include <mrpt/examples_config.h> 24 string myDataDir(MRPT_EXAMPLES_BASE_DIRECTORY +
string(
"img_basic_example/"));
38 if (!
img.loadFromFile(
myDataDir +
string(
"frame_color.jpg")))
40 cerr <<
"Cannot load " <<
myDataDir +
string(
"frame_color.jpg") << endl;
43 printf(
"Image loaded in %.03fms\n", 1000 * tictac.
Tac());
52 cout <<
"Push a key in the console or in the window to continue...";
54 cout <<
"Done" << endl;
56 timlog.
enter(
"grayscale1");
58 timlog.
leave(
"grayscale1");
64 cout <<
"Push a key in the console or in the window to continue...";
66 cout <<
"Done" << endl;
72 CDisplayWindow win1(
"win1"), win2(
"win2"), win3(
"win3"), win4(
"win4");
77 for (
int i = 0; i < 50; i++)
79 timlog.
enter(
"grayscale2");
80 imgSmall.grayscale(imgGray);
81 timlog.
leave(
"grayscale2");
91 imgSmall.line(550, 75, 650, 25,
TColor(0, 0, 255));
92 imgSmall.line(-10, -20, 20, 30,
TColor(0, 0, 255));
97 COV(0, 1) = COV(1, 0) = -30;
98 imgSmall.ellipseGaussian(COV, 600.0, 50.0, 2,
TColor(255, 255, 0), 4);
105 win1.showImage(imgSmall);
107 win2.showImage(imgSmall2);
109 win3.showImage(imgGray);
110 win3.setPos(810, 300);
111 win4.showImage(imgSmallRGB);
112 win4.setPos(300, 400);
114 cout <<
"Press any key on 'win4' to exit" << endl;
119 printf(
"jpeg file saved in %.03fms\n", 1000.0 * tictac.
Tac());
136 catch (
const std::exception& e)
143 printf(
"Untyped exception!!");
double Tac() noexcept
Stops the stopwatch.
A compile-time fixed-size numeric matrix container.
CImage scaleHalf(TInterpolationMethod interp) const
Returns a new image scaled down to half its original size.
void drawImage(int x, int y, const mrpt::img::CImage &img) override
Draws an image as a bitmap at a given position.
A high-performance stopwatch, with typical resolution of nanoseconds.
This base provides a set of functions for maths stuff.
This class creates a window as a graphical user interface (GUI) for displaying images to the user...
void rectangle(int x0, int y0, int x1, int y1, const mrpt::img::TColor color, unsigned int width=1)
Draws a rectangle (an empty rectangle, without filling)
GLsizei const GLchar ** string
void ellipseGaussian(const mrpt::math::CMatrixFixed< double, 2, 2 > &cov2D, const double mean_x, const double mean_y, double confIntervalStds=2, const mrpt::img::TColor &color=mrpt::img::TColor(255, 255, 255), unsigned int width=1, int nEllipsePoints=20)
Draws an ellipse representing a given confidence interval of a 2D Gaussian distribution.
void pause(const std::string &msg=std::string("Press any key to continue...")) noexcept
Shows the message "Press any key to continue" (or other custom message) to the current standard outpu...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
A versatile "profiler" that logs the time spent within each pair of calls to enter(X)-leave(X), among other stats.
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...
Classes for creating GUI windows for 2D and 3D visualization.
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)...
void Tic() noexcept
Starts the stopwatch.
void TestImageConversion()
void enter(const std::string_view &func_name)
Start of a named section.
double leave(const std::string_view &func_name)
End of a named section.
A class for storing images as grayscale or RGB bitmaps.