"Fossies" - the Fresh Open Source Software Archive

Member "dlib-19.18/docs/3d_point_cloud_ex.cpp.html" (22 Sep 2019, 4880 Bytes) of package /linux/misc/dlib-19.18.tar.bz2:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) HTML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <html><!-- Created using the cpp_pretty_printer from the dlib C++ library.  See http://dlib.net for updates. --><head><title>dlib C++ Library - 3d_point_cloud_ex.cpp</title></head><body bgcolor='white'><pre>
    2 <font color='#009900'>// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt
    3 </font><font color='#009900'>/*
    4 
    5     This is an example illustrating the use of the perspective_window tool
    6     in the dlib C++ Library.  It is a simple tool for displaying 3D point 
    7     clouds on the screen.
    8 
    9 */</font>
   10 
   11 <font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>dlib<font color='#5555FF'>/</font>gui_widgets.h<font color='#5555FF'>&gt;</font>
   12 <font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>dlib<font color='#5555FF'>/</font>image_transforms.h<font color='#5555FF'>&gt;</font>
   13 <font color='#0000FF'>#include</font> <font color='#5555FF'>&lt;</font>cmath<font color='#5555FF'>&gt;</font>
   14 
   15 <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> dlib;
   16 <font color='#0000FF'>using</font> <font color='#0000FF'>namespace</font> std;
   17 
   18 <font color='#009900'>// ----------------------------------------------------------------------------------------
   19 </font>
   20 <font color='#0000FF'><u>int</u></font> <b><a name='main'></a>main</b><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>
   21 <b>{</b>
   22     <font color='#009900'>// Let's make a point cloud that looks like a 3D spiral.
   23 </font>    std::vector<font color='#5555FF'>&lt;</font>perspective_window::overlay_dot<font color='#5555FF'>&gt;</font> points;
   24     dlib::rand rnd;
   25     <font color='#0000FF'>for</font> <font face='Lucida Console'>(</font><font color='#0000FF'><u>double</u></font> i <font color='#5555FF'>=</font> <font color='#979000'>0</font>; i <font color='#5555FF'>&lt;</font> <font color='#979000'>20</font>; i<font color='#5555FF'>+</font><font color='#5555FF'>=</font><font color='#979000'>0.001</font><font face='Lucida Console'>)</font>
   26     <b>{</b>
   27         <font color='#009900'>// Get a point on a spiral
   28 </font>        dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font> <font color='#BB00BB'>val</font><font face='Lucida Console'>(</font><font color='#BB00BB'>sin</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>,<font color='#BB00BB'>cos</font><font face='Lucida Console'>(</font>i<font face='Lucida Console'>)</font>,i<font color='#5555FF'>/</font><font color='#979000'>4</font><font face='Lucida Console'>)</font>;
   29 
   30         <font color='#009900'>// Now add some random noise to it
   31 </font>        dlib::vector<font color='#5555FF'>&lt;</font><font color='#0000FF'><u>double</u></font><font color='#5555FF'>&gt;</font> <font color='#BB00BB'>temp</font><font face='Lucida Console'>(</font>rnd.<font color='#BB00BB'>get_random_gaussian</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
   32                                   rnd.<font color='#BB00BB'>get_random_gaussian</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>,
   33                                   rnd.<font color='#BB00BB'>get_random_gaussian</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
   34         val <font color='#5555FF'>+</font><font color='#5555FF'>=</font> temp<font color='#5555FF'>/</font><font color='#979000'>20</font>;
   35 
   36         <font color='#009900'>// Pick a color based on how far we are along the spiral
   37 </font>        rgb_pixel color <font color='#5555FF'>=</font> <font color='#BB00BB'>colormap_jet</font><font face='Lucida Console'>(</font>i,<font color='#979000'>0</font>,<font color='#979000'>20</font><font face='Lucida Console'>)</font>;
   38 
   39         <font color='#009900'>// And add the point to the list of points we will display
   40 </font>        points.<font color='#BB00BB'>push_back</font><font face='Lucida Console'>(</font>perspective_window::<font color='#BB00BB'>overlay_dot</font><font face='Lucida Console'>(</font>val, color<font face='Lucida Console'>)</font><font face='Lucida Console'>)</font>;
   41     <b>}</b>
   42 
   43     <font color='#009900'>// Now finally display the point cloud.
   44 </font>    perspective_window win;
   45     win.<font color='#BB00BB'>set_title</font><font face='Lucida Console'>(</font>"<font color='#CC0000'>perspective_window 3D point cloud</font>"<font face='Lucida Console'>)</font>;
   46     win.<font color='#BB00BB'>add_overlay</font><font face='Lucida Console'>(</font>points<font face='Lucida Console'>)</font>;
   47     win.<font color='#BB00BB'>wait_until_closed</font><font face='Lucida Console'>(</font><font face='Lucida Console'>)</font>;
   48 <b>}</b>
   49 
   50 <font color='#009900'>//  ----------------------------------------------------------------------------
   51 </font>
   52 
   53 </pre></body></html>