16 #include <mrpt/examples_config.h>    18     MRPT_EXAMPLES_BASE_DIRECTORY +
    19     std::string(
"img_basic_example/frame_color.jpg"));
    36     CImage imgCol_2N, imgBW_2N;
    54     for (
int y = 0; y < H; y++)
    55         for (
int x = 0; x < W; x++)
    56             *transpMask_N(x, y) = (((x + y) >> 5) & 1) ? 240 : 10;
    59     transpMask_N.
scaleImage(transpMask_2N, 512, 512);
    61     cout << 
"Loaded image size: " << imgCol_N.
getWidth() << 
"x"    63     cout << 
"2^N image size   : " << imgCol_2N.
getWidth() << 
"x"    71     const double off_y_label = 4;
    72     const double STEP_X = 15;
    77             opengl::CTexturedPlane::Create(-3, 3, -3, 3);
    78         obj->assignImage(imgCol_N);
    79         obj->setLocation(off_x, 0, 0);
    80         theScene->insert(obj);
    83             opengl::CText::Create(
"Color texture, random size, w/o transp");
    84         gl_txt->setLocation(off_x, off_y_label, 0);
    85         theScene->insert(gl_txt);
    92             opengl::CTexturedPlane::Create(-3, 3, -3, 3);
    93         obj->assignImage(imgCol_N, transpMask_N);
    94         obj->setLocation(off_x, 0, 0);
    95         theScene->insert(obj);
    98             opengl::CText::Create(
"Color texture, random size, with transp");
    99         gl_txt->setLocation(off_x, off_y_label, 0);
   100         theScene->insert(gl_txt);
   107             opengl::CTexturedPlane::Create(-3, 3, -3, 3);
   108         obj->assignImage(imgBW_N);
   109         obj->setLocation(off_x, 0, 0);
   110         theScene->insert(obj);
   113             opengl::CText::Create(
"B/W texture, random size, w/o transp");
   114         gl_txt->setLocation(off_x, off_y_label, 0);
   115         theScene->insert(gl_txt);
   122             opengl::CTexturedPlane::Create(-3, 3, -3, 3);
   123         obj->assignImage(imgBW_N, transpMask_N);
   124         obj->setLocation(off_x, 0, 0);
   125         theScene->insert(obj);
   128             opengl::CText::Create(
"B/W texture, random size, with transp");
   129         gl_txt->setLocation(off_x, off_y_label, 0);
   130         theScene->insert(gl_txt);
   137             opengl::CTexturedPlane::Create(-3, 3, -3, 3);
   138         obj->assignImage(imgCol_2N);
   139         obj->setLocation(off_x, 0, 0);
   140         theScene->insert(obj);
   143             opengl::CText::Create(
"Color texture, 2^N size, w/o transp");
   144         gl_txt->setLocation(off_x, off_y_label, 0);
   145         theScene->insert(gl_txt);
   152             opengl::CTexturedPlane::Create(-3, 3, -3, 3);
   153         obj->assignImage(imgCol_2N, transpMask_2N);
   154         obj->setLocation(off_x, 0, 0);
   155         theScene->insert(obj);
   158             opengl::CText::Create(
"Color texture, 2^N size, with transp");
   159         gl_txt->setLocation(off_x, off_y_label, 0);
   160         theScene->insert(gl_txt);
   167             opengl::CTexturedPlane::Create(-3, 3, -3, 3);
   168         obj->assignImage(imgBW_2N);
   169         obj->setLocation(off_x, 0, 0);
   170         theScene->insert(obj);
   173             opengl::CText::Create(
"B/W texture, 2^N size, w/o transp");
   174         gl_txt->setLocation(off_x, off_y_label, 0);
   175         theScene->insert(gl_txt);
   182             opengl::CTexturedPlane::Create(-3, 3, -3, 3);
   183         obj->assignImage(imgBW_2N, transpMask_2N);
   184         obj->setLocation(off_x, 0, 0);
   185         theScene->insert(obj);
   188             opengl::CText::Create(
"B/W texture, 2^N size, with transp");
   189         gl_txt->setLocation(off_x, off_y_label, 0);
   190         theScene->insert(gl_txt);
   194     win.setCameraZoom(150);
   195     win.setCameraAzimuthDeg(90);
   198     win.unlockAccess3DScene();
   201     cout << 
"Close the window to end.\n";
   204         win.addTextMessage(5, 5, 
format(
"%.02fFPS", 
win.getRenderingFPS()));
   205         std::this_thread::sleep_for(2ms);
   221     catch (
const std::exception& e)
   228         printf(
"Untyped exception!!");
 
std::string std::string format(std::string_view fmt, ARGS &&... args)
size_t getHeight() const override
Returns the height of the image in pixels. 
void scaleImage(CImage &out_img, unsigned int width, unsigned int height, TInterpolationMethod interp=IMG_INTERP_CUBIC) const
Scales this image to a new size, interpolating as needed, saving the new image in a different output ...
bool loadFromFile(const std::string &fileName, int isColor=-1)
Load image from a file, whose format is determined from the extension (internally uses OpenCV)...
This base provides a set of functions for maths stuff. 
size_t getWidth() const override
Returns the width of the image in pixels. 
mrpt::gui::CDisplayWindow3D::Ptr win
CImage grayscale() const
Returns a grayscale version of the image, or a shallow copy of itself if it is already a grayscale im...
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries. 
const std::string myTestFile(MRPT_EXAMPLES_BASE_DIRECTORY+std::string("img_basic_example/frame_color.jpg"))
The namespace for 3D scene representation and rendering. 
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. 
A class for storing images as grayscale or RGB bitmaps. 
A graphical user interface (GUI) for efficiently rendering 3D scenes in real-time.