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.0f, 50.0f, 2,
TColor(255, 255, 0), 4);
101 imgSmall.drawImage(400, 500, imgGray);
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.0f * tictac.
Tac());
121 imgSmall2.saveToFile(
"frame_out_small.png");
136 catch (std::exception& e)
138 std::cout <<
"MRPT exception caught: " << e.what() << std::endl;
143 printf(
"Untyped exception!!");
double Tac() noexcept
Stops the stopwatch.
A high-performance stopwatch, with typical resolution of nanoseconds.
This base provides a set of functions for maths stuff.
CImage scaleHalfSmooth() const
Returns a new image scaled down to half its original size (averaging between every two rows) ...
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)
double leave(const char *func_name)
End of a named section.
GLsizei const GLchar ** string
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.
Classes for creating GUI windows for 2D and 3D visualization.
void ellipseGaussian(const MATRIX2X2 *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.
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.
This class is a "CSerializable" wrapper for "CMatrixFloat".
void TestImageConversion()
void enter(const char *func_name)
Start of a named section.
A class for storing images as grayscale or RGB bitmaps.