Welcome to Software Laboratory of Antillia.com.
    Future Windows and Linux Programming

  OZ++ Class Library

  Home     OZ++ Samples     OZ++ Class Tree     OZ++ Class List  

1 Download OZ++
The latest OZ++ library for Linux and sample programs can be downloaded.


OZ++ Class Library 2.2.0 for Motif, OpenGL, OpenCV-4.2.0 and YOLOv3 on Ubuntu 18.04.2 (LTS) (oz++2.2.0: #2020.02.12 )

This library contains both a set of C++ class header files and a lot of sample programs of OZ++.

In the latest oz++2.1.9, we have added a new sample CustomYoloObjectDetector for YOLOv3.

To use in the new sample, we have created Detector3 C++ class from detector.c, image.c, etc in darknet-master/src folder.

The Detector3 class is written by our simple extension code to darknet-master/src, darknet-master-to-use-std to use with C++11 std::list and std::data classe.

Furthermore, we have added ConfigParser C++ class to parse an ini-file by using KeyValueSplitter and hash-map(std::unordered_map).



2 What is OZ++?
2.1 OZ++ 1.0
 OZ++ 1.0 is an experimental and elementary C++ class library for Linux. It is based on author's SOL9 C++ class library for Windows. OZ++ 1.0 has no GUI classes,. We provide a set of C++ class header files and a lot of sample programs for those libaries.
 On OZ++ we implemented all the member functions inside the C++ classes. This is not a conventional coding style of C++ of separating implementation and interface. But OZ++ coding style has one point which enables a rapid prototyping of writing and testing C++ prograqms quickly. It may (or may not) be useful for various experimentation projects.
 Historically, the author started to develop SOL9 C++ class library for Windows about a few years ago, based on SOL++2000 for Windows. The class hierarchy and class names of OZ++ are quite similar to those of SOL9. On OZ++ We have introduced a namespace 'OZ' to avoid the collisions of classes or type names in GNU g++ environment.
 We developed this OZ++ library by using g++ 7.3.0 on Ubuntu 18.04.2 LTS, but didn't test it on other g++ versions or Linux distributions.

$ g++ --version
g++ (Ubuntu 7.3.0-27ubuntu1~18.04) 7.3.0
Copyright (C) 2017 Free Software Foundation, Inc.

In the latest OZ++ 2.1.8 libray, we have updated OZ::SmartPtr class to use std::unique_ptr of C++11.

 In OZ++ 1.0.5, we updated some experimental C++ classes(Netlink++ 1.0.3) for Linux netlink, which seems to be a slightly complicated C library, but a very interesting material from an educational or practical point of view to study C++ class implementation for the library. Netlink++ may help you write programs to communicate with the Linux kernel based on the netlink.
 In the version OZ++ 1.0.6, we updated some experimental C++ classes(Netlink++ 1.0.4) for Linux netlink not to use OZ::String class.


2.2 OZ++ 2.1
2.2.1 OZ++ 2.1
 OZ++ 2.1 is an extension C++ class library of OZ++ 2.0 to support the classic Open Motif-based GUI development environment on Ubuntu 18.04.2 (LTS).
The Motif C++ library (Motif++) is based on author's old Oz++ library developed by AT&T C++ compiler on a UNIX system. (See also: Motif C++ Programming: Design and Implementation of Oz++; ISBN-13: 978-4833741019)
 The latest Open Motif version 2.3.8 has been released on December 2017 ( Motif released as open source software under LGPL v2.1). If you would like to know Motif version on your system, it is helpfull to find XmVERSION_STRING in the file "/usr/include/Xm/Xm.h". For example, you can see the following line:

#define XmVERSION_STRING "@(#)Motif Version 2.3.8"

 In the latest OZ++2.1 library, we have been using Motif 2.3.8 to build our C++ GUI class library, which is used to write the GUI applications of Motif, OpenGL and OpenCV.

In the latest version OZ++2.1.7, we have updated CFLAGS to be empty in Makefiles in sample folders of xft to avoid an abormal termination in runtime.

 Motif++ is a set of thin wrapper C++ classes for Motif widgets. On Motif++ we implemented all the member functions inside the C++ classes, and introduced a namespace 'OZ'.

Schematically, you can imagine that:

OZ++ 2.1 = (OZ++ 1.0) + (Motif++) + (OpenGL++) + (OpenCV++)


We provide a set of C++ class header files and a lot of sample programs for this library.

The OpenGL++ library of OZ++ 2.1 supports not only classic OpenGL APIs but also modern OpenGL Shader Language of GLEW to avoid falling into chaos of devine OpenGL APIs, though we are not enthusiastic followers of OpenGL.

The OpenCV++ library of OZ++ 2.1 supports the Motif-based GUI for the latest OpenCV-4.0.1 features instead of the standard HighGUI of OpenCV.
In the latest OZ++, we have implemented simple thread classes OpenCVVideoReaderThread and OpenCVVideoWriterThread, which are derived from the OZ::Thread class. Those classes will enable us to separate the event handlers for X11-Motif GUI events, and Video-Device I/O events.


2.2.2 Development environment of OZ++ 2.2
  Although far behind others, we have upgraded our development environment of OZ++ from Ubuntu 16.04 LTS to Ubuntu 18.04.2 LTS (2019/04/6).
After the installation the Ubuntu, we have added some development packages to the system in the following way, on the console.

# Update and upgrade
sudo apt-get update
sudo apt-get upgrade

# Update g++. We need the latest c++ compiler
sudo apt-get install g++

# Install X11, Xt libray
sudo apt-get install libx11-dev
sudo apt-get install libxt-dev

# Install OpenGL (Mesa) See : https://www.mesa3d.org/ and related library.
# (See: The Easy Way to Install Mesa 17.0.2 on Ubuntu 16.04 LTS)
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
sudo apt-get install libglew-dev

# Install xpm and jpeg library
sudo apt-get install libxpm-dev
sudo apt-get install libjpeg-dev

# Install video for linux which can be used in OpenCV VideoCapture.
sudo apt-get install libv4l-dev


  • OpenCV-4.2.0
  • We have built and installed the library for OpenCV-4.2.0 from the source code OpenCV-4.2.0. To use the legacy C constants and APIs in OpenCV-4.2.0, we have updated OpenCVImageConverter class.

  • OpenCV-4.1.0
  • We have built and installed the library for OpenCV-4.1.0 from the source code OpenCV-4.1.0. To use the legacy C constants and APIs in OpenCV-4.1.0, we have updated OpenCVObject class and modified OZ++ sample programs. Furthermore, we have modified the Makefiles not to use pkg-config( see 4.0.0 does not produce pkgconfig file · Issue #13154 · opencv-opencv ·).

    You may encounter a strange compilation error undefined reference to std::__cxx11::basic_string to build a C++ OpenCV application as questioned in

    Converting std::__cxx11::string to std::string

    , and furthermore

    Undefined reference to cv::imread(std::string const&, int)

    As suggested in those web-sites, to fix these errors, you have to rebuild the OpenCV library by changing CMakeCache.txt file, in which the CMAKE_CXX_FLAGS:STRING= to have the following value, not empty as default.

    //Flags used by the compiler during all build types.
    //CMAKE_CXX_FLAGS:STRING=
    CMAKE_CXX_FLAGS:STRING=-D_GLIBCXX_USE_CXX11_ABI=0

    Probably, you also have to add the following macro in your Makefile to build your application.

    CFLAG = -D_GLIBCXX_USE_CXX11_ABI=0


    2.2.3 History
    Please see the page OZ++ Class Library History



    2.3 OZ++ Features

    1. OZ++ is basically single inheritance oriented.
    2. OZ++ classes have been implemented in C++ header files using inline member functions.
    3. OZ++ applications only have to include OZ++ class header files, and they can be compiled without linking any OZ++ specific shared or static library.
    4. OZ++ will support multiple charsets of ASCII(char) and UNICODE(wchar_t).

    Note: Current OZ++ version is not thread safe. For example, the instances of LinkedList class cannot be safely accessed by multiple threads.



    2 How to install OZ++
    You download the zip file oz++.zip, and unzip it on your working directory.program. For example, by unzipping on a directory ~/work, you get the following directories:

    2.1 OZ++ 1.0
    ~/work/oz++/iclude
    , which includes all C++ header files for OZ++ 1.0.

    ~/work/oz++/netlink
    , which includes some sample programs for netlink++ and build.sh shell script to compile them.

    ~/work/oz++/samples
    , which includes all sample programs for OZ++ and build.sh shell script to compile them.

    2.2 OZ++ 2.0
    ~/work/oz++/include
    , which includes all C++ header files for OZ++ 1.0 and Motif++.

    ~/work/oz++/netlink
    , which includes some sample programs for netlink++ and build.sh shell script to compile them.

    ~/work/oz++/samples
    , which includes all sample programs for OZ++ 1.0 and build.sh shell script to compile them.

    ~/work/oz++/motif
    , which includes all sample programs for Motif++ and build.sh shell script to compile them.

    ~/work/oz++/opengl
    , which includes all sample programs for OpenGL and build.sh shell script to compile them.

    ~/work/oz++/opengl2
    , which includes all sample programs for OpenGL 2.0 and build.sh shell script to compile them.

    ~/work/oz++/opencv
    , which includes some sample programs for OpenCV and build.sh shell script to compile them.

    ~/work/oz++/openglcv
    , which includes some sample programs for OpenGL and OpenCV and build.sh shell script to compile them.


    ~/work/oz++/xft
    , which includes some sample programs for XFT and build.sh shell script to compile them.


    3 How to write OZ++ applications.

     We show some simple and elementary application programs of OZ++, Netlink++, Motif++, OpenCV and OpenGL which may be helpful to understand OZ++ programming style. For more examples, please see OZ++ samples


    3.1.1 Hello world

    3.2.1 InterfaceAddrRequest

    3.2.2 RoutingTableNewRequest

    3.2.3 IPAddressMonitor

    3.3.1 Label

    3.3.2 Pixelmap and EventHandler

    3.3.3 ApplicationView and Callback

    3.3.4 TreeView

    3.3.5 XFT

    3.3.5.1 CustomScrolledView

    3.3.6 Is Motif a sleeping beauty?

    3.3.7 FTFontPreview

    3.3.8_FileListView

    3.3.9 FileIconBox

    3.3.10 IconBar

    3.3.11 IPAddressWatcher

    3.3.12 Polygon

    3.3.13 ImageViewer

    3.3.14 Texture

    3.3.15 InodeWatcher

    3.3.16 LightedTorus

    3.3.17 MultiJPGTexturedCubeRotationByTimerThread

    3.3.18 MultiColoredTrianglShader

    3.3.19 BufferedColoredRegularIcosahedron

    3.3.20 SphereWithColorEyeLightPositioner

    3.3.21 MaterializedTorusesRotationByTimerThread

    3.3.22 TexturedSphereRotationByKeyInput

    3.3.23 StarSystemModel

    3.3.24 FileSystemBrowser

    3.3.25 ImageBlur

    3.3.26 ImageSharpen

    3.3.27 ObjectDetector

    3.3.28 VideoDeviceEnumerator

    3.3.29 OpenGLCVImageViews

    3.3.30 BlurredMaterializedSpheres

    3.3.31 ImageTransformationByDynamicColorFilter

    3.3.32 TexturedSphereWithAxisEyeAndLightPositioner

    3.3.33 CustomYoloObjectDetector


    3.1 OZ++ 1.0
      1.1 Hello world
    On OZ++ application you simply include OZ++ class header files as your needs, as shown below. You also have to write your own main function of the C/C++ program entry point.




      
    3.1.2 Thread and MessageQueue

     This is an example to write data to POSIX message queue by using OZ++ Thread class.
    Note:
    1. Define your own C++ class (Writer) as a subclass of Thread class.
    2. Add a member variable of MessageQueue class which can be used to send data to other process.
    3. Define a contructor to initialize the above member variable.
    4. Define a run method to send your data to other process through MessageQueue.
    5. In main function, create an instance of your thread class(Writer), and call start and wait methods for the instance.

    >

    3.2 Netlink++
      3.2.1 InterfaceAddrRequest
     On Netlink++ application you simply include OZ++ netlink class header files as your needs, as shown below. You also have to write your own main function of the C/C++ program entry point.
    This is an example to send a NetlinkRequest for the structure ifaddrmsg to get IPv4 interface addresses.
    Note:
    1. Define your own netlink request C++ class.
    2. Add a member variable of NetlinkRequest<T> which includes a netlink message header and a requst body of type T.
    3. Add a member variable of SocketNetlink which can be used as a communication channel to the kernel.
    4. Define a contructor to initialize the above two member variables.
    5. Define a send method to send your netlink request to the kernel through the SocketNetlink.
    6. Define a recv method to receive a reply from the kernel through the SocketNetlink.
    7. In main function, create an instance of your request class, and call the send and recv mothods for the instance.


      3.2.2 RoutingTableNewRequest
    This is an example to send a NetlinkRequest for the structure rtmsg to register a new route.
    Note:
    1. Define your own netlink request C++ class.
    2. Add a member variable of NetlinkRouteAttributeRequest<T> which includes a netlink message header and a requst body of type T.
    3. Add a member variable of SocketNetlink which can be used as a communication channel to the kernel.
    4. Add a member variable of NetlinkReply<T> which includes a netlink message header and ack data from the kernel.
    5. Define a contructor to initialize the above two member variables.
    6. Define a send method to send your netlink request to the kernel through the SocketNetlink.
    7. Define a recv method to receive a reply from the kernel through the SocketNetlink.
    8. In main function, create an instance of your request class, and call the send and recv mothods for the instance.



      3.2.3 IPAddressMonitor
    This is an example to monitor changes of InterfaceAddresses for IPv4 and IPv6.

    Note:
    1. Define your own netlink monitor C++ class.
    2. Add a member variable for groups to monitor.
    3. Add a member variable of SocketNetlink which can be used as a communication channel to the kernel.
    4. Add a member variable of NetlinkReply<T> which includes a netlink message header and ack data from the kernel.
    5. Define a contructor to initialize the group member variable.
    6. Define a bind method to communicate with the kernel through the SocketNetlink.
    7. Define a recv method to receive a notification from the kernel through the SocketNetlink.
    8. In main function, create an instance of your monitor class, and call bind and recv mothods for the instance.


    3.3 Motif++, Xft++, and OpenGL++
      3.3.1 Label
     On Motif++ application for OZ++ 2.0, you simply include Motif++ class header files for your requirement, as shown below.
    Note:
    1. Define your own top level application view class(MainView) to be a subclass of OZ::ApplicationView class.
    2. In main function, create an instance of OZ::Application class, and an instance of your own application view class(MainView).
    3. Call realize method of the instance of the application view.
    4. Call run method of the instance of Application to enter an event loop.




      3.3.2 Pixelmap and EventHandler
     Tis is an example to create a pixelmap and draw colored points on it, and copy the pixelmap onto a window by an eventhandler for ExposureMask.
    Note:
    1. Define your own top level application view class(MainView) to be a subclass of OZ::ApplicationView class.
    2. Define a member varialbe for Pixelmap class to store colored points.
    3. Define a member variable for DC class which can be used as a device(graphics) context for the pixelmap.
    4. Define a constructor to intialize the above member variables.
    5. Define a draw eventhandler method to copy the pixelmap to your window.
    6. In main funcition, create create an instance of OZ::Application class, and an instance of your own application view class(MainView).
    7. Call realize method of the instance of the application view.
    8. Call run method of the instance of Application to enter an event loop.



      3.3.3 ApplicationView and Callback
     On Motif++ application for OZ++ 2.0, you can write easily a typical application window with a menubar and pulldown menus, as shown below.
    This is an example to select a text file from a fileDialog, and to display the content of the selected file in a scrolledText window.
    Note:
    1. Define your own top level application view class(MainView) to be a subclass of OZ::ApplicationView class.
    2. Define member vairlables for MainWindow, MenuBar, PulldownMenu, ScrolledTextm, and FileDialog.
    3. Define a constructor to create the instances of the above classes, and register callbacks to a menu and a file selection.
    4. Define calllback method(fileMenu) for a menu selection, and callback method (open) for a file selection in a fileDialog.
    5. In main function, create an instance of your OZ::Application class, and an instance of your own application view class(MainView).
    6. Call realize method of the instance of the application view.
    7. Call run method of the instance of Application to enter an event loop.



      3.3.4 TreeView
     On Motif++, you can write a TreeView application based on xmTreeWidgetClass (Open Motif 2.2 and later) as shown below.
    This is an example to display a tree of some subnodes of PushButtons or Labels.
    Note:
    1. Define your own top level application view class(MainView) to be a subclass of OZ::ApplicationView class.
    2. Define a member vairlable for Tree class.
    3. Define a constructor to create the instances of Tree, and add nodes (PushButtons or Labels) to the tree instance.
    4. Define calllback method(pushed) for the PushButtons on the nodes.
    5. In main function, create an instance of your OZ::Application class, and an instance of your own application view class(MainView).
    6. Call realize method of the instance of the application view.
    7. Call run method of the instance of Application to enter an event loop.


      3.3.5 XFT
     As you know, Open Motif 2.3 (Appendix G - New Features in Motif 2.3) and later support the free type fonts Xft (X free type).
    To use XFT fonts on Motif, you only have to write some XmRenderTable specific resources into .Xdefaults file as shown below.



    Please note that the *fontTye is a mandatory item and must take FONT_IS_XFT for Xft fonts.
    Fortunately, you don't need to change your already-written C/C++ source files for using Xft.




      3.3.5.1 CustomScrolledView
    You can overried some XmRenderTable specific resources(XmNfontSize, XmNfontName) in .Xdefaults file in your application, and set the XmRenderTable to a graphics context for a pixmap to draw a text string in the pixmap.



      3.3.6 Is Motif a sleeping beauty?
      On Motif++, we have some experimental C++ classes(Xft++) to use FontConfig and Xft on Motif.
    This program ('Is Motif a sleeping beauty?') is an example to display UTF-8 strings by using FTFont (FreeTypeFont) and FTFlatButton (FreeTypeFlatButton) classes of Xft++.




      3.3.7 FTFontPreview
     To see a list of known Fontconfig fonts, you can use fc-list command in Fontconfig package.
    Using an output of fc-list, we can implement a font-preview C++ class to browse X11 Fontconfig fonts.
    This is an example to display available fonts by FTFontPreview (FreeTypeFontPreview) of xft++.



      3.3.8_FileListView
     Open Motif 2.3 (Appendix G - New Features in Motif 2.3) and later give programmers the ability to show pixmaps and label strings simultaneously in Labels or Buttons.
    On OZ++, to create an instance of Label with a pixmap and a string label, you have to specify XmPIXMAP_AND_STRING for XmNlalbelType as shown below:



      3.3.9 FileIconBox
     Open Motif 2.3 and later provide some "Contributed Widgets" such as XmIconButton and XmIconBox classes, which seem to be slightly similar to XmPushButton extension with a pixmap and XmButtonBox respectively. The XmIconButton can be used to show an icon (pixmap) and a label string simultaneously in a button.
    On OZ++, to create an instance of IconButton, you have to specify XmNlalbelString and XmNpixmap resources as shown below:



      3.3.10 IconBar
    The XmIconButton in Open Motif 2.3 can also be used as a menubar by arranging the buttons to one line on a top region in ApplicationView .
    This is an example to display a menu for some file editing operations by using IconBar class (motif++ 1.0.5).
    Please note that to add a button to the IconBar, we specify an icon filename to XmNiconFileName which is an OZ++ specific resource.



      3.3.11 IPAddressWatcher
     On the latest Motif++ 1.0.6, we have introduced a very primitve Model-View update model on View class. By using the model, we can easily write a mixed program of an OZ++ Thread class and Motif++ GUI classes.
     Please note that the libraries of Open Motif 2.1 (and later) are thread-safe(See: Open Motif Overview).
     This is an example to display some IPAddress information retrieved by IPAddressWatcher thread on TableView.
    This sample program is built on two classes IPAddressWatcher(Thread), and MainView(ApplicationView).



      3.3.12 Polygon
     On the latest Motif++ 1.0.7, we have implemented some experimental C++ classes (OpenGL++) for OpenGL.
     To display various OpenGL graphics objects on X11/Motif windows, we have introduced OpenGLView class based on Canvas class of the Motif++.
     This is an example to display a polygon on SimpleView class derived from OpenGLView.



      3.3.13 ImageViewer
     Although you may not be so interested in an image processing on X11/Motif, Open Motif 2.3 has added support of PNG and JPEG images (Appendix G - New Features in Motif 2.3). It will enable us to create easily better imaged widgets such as XmLabel and XmPushButton which have XmNlabelPixmap or XmNsomethingPixmap resources as shown below.



      3.3.14 Texture
     The advanced image support of Motif is also helpful to create an OpenGL texture from an image file of PNG or JPEG.
     This is an example to create an OpenGL texture from a pixmap loaded by using OZ::PixmapFile class which is implemented based on XmGetPixmap API of Motif 2.3.



      
    3.3.15 InodeWatcher
     Linux provides some APIs (inotify_*) to monitor files(inodes). In OZ++ 2.0.15, we have added OZ::NonblockingInodeWatcher class to read inode change notifications from an inotify file descriptor of IN_NOBLOCK mode.
     This is an example to watch changes of inodes of Linux system by using OZ::NonblockingInodeWatcher class.



      3.3.16 LightedTorus
      We have been using FreeGLUT which is a free-software/open-source alternative to the OpenGL Utility Toolkit (GLUT) library.
    GLUT(FreeGULT) is a window system independent library, and very useful to develop simple and portable(cross-platform) OpenGL programs.
      This is an example to draw two toruses by using glutSolidTorus and glutWireTorus APIs of GLUT library.



      3.3.17 MultiJPGTexturedCubeRotationByTimerThread
      We have C++ class OpenGLMultiTexturedCube to render a cube textured by multiple JPG or PNG image files.
     This is a simple sample program based on that class, and six JPG files for the cube fases.
     In this program the cube is rotated around y-axis by RenderingTimer Thead.



      3.3.18 MultiColoredTrianglShader
      In OZ++2.0.23, we have updated our OpenGL C++ classes to use GLEW in order to create a context-version-dependent context, and to use the features of OpenGL Shader Language.   Currently, the default major version and the minor version for OpenGLContex class are 2 and 1 respectively.
      This is a very simple sample program to use OpenGLProram, OpenGLFragmentShader, and OpenGLVertexShader classes to draw a multicolored triangle. In this program, the sources for FragmentShader and VertexShader are defined in the files of "fragmentShader.glsl" and "vertexShader.glsl" respectively.



      3.3.19 BufferedColoredRegularIcosahedron
      In OZ++2.0.23, we have added new classes OpenGLBufferARB, OpenGLBufferedShapd, OpenGLIndexBufferARB, and OpenGLVertexBufferARB to 'oz++/openglarb/' folder to support GL_ARB_vertex_buffer_object extension in GLEW.
      This is a very simple sample program to draw OpenGLColoredRegularIcosahedron by using those classes.





      3.3.20 SphereWithColorEyeLightPositioner
      In OZ++2.0.24 library, we have added new classes Positioner, ColorPositioner, EyePositioner, LightPositiner, and ColorEyeLightPositioner to 'oz++/motif' folder. Those have been implemented by Motif ScrollBar triplet.
     This is a very simple sample program to draw Sphere by using those classes.



       3.3.21 MaterializedTorusesRotationByTimerThread
      As you know, in OpenGL, there is a glMaterial API to set material properties.
    In the latest sol9.2.0, we have implemented OpenGLMateria class to store material properites:face, ambient, diffuse, specular, emission, shininess.




      3.3.22 TexturedSphereRotationByKeyInput
      In OpenGL, there are some methods to map a texture to a solid sphere.

    1. To use gluSphere and gluQuadricTexture APIs in OpenGL GLU library.
    See Texturing a Sphere.

    2. To write your own code to draw a sphere with texture coordinates.
    See Texture map in solid sphere using GLUT(OpenGL) .

    Please note that you cannot use glutSolidSphere API of OpenGL GLUT library to map a texture on the sphere, because the API doesn't support texture coordinates.
    In the latest OZ++ library, we have implemented OpenGLTexturedSphere class based on the first method.

    The following TexturedSphereRotationByKeyInput is a simple example to draw a textured shpere and rotate it by Left or Rigth keys.

    In this example, we have used the world map of 'world.topo.bathy.200412.3x5400x2700.jpg' file in the following page.
    NASA VISIBLE EARTH
    December, Blue Marble Next Generation w/ Topography and Bathymetry
    Credit: Reto Stockli, NASA Earth Observatory





    We have also used Viking's Mars 'mar0kuu2.jpg' created by Caltech/JPL/USGS in the SOLAR SYSTEM SIMULATOR.



    We have also used Jupiter 'PIA07782_hires.jpg' in the JPL Cassini's Best Maps of Jupiter.



      3.3.23 StarSystemModel
    In OpenGL, we can draw a simple star system model like our solar system. We assume an imaginary star system which consists of a single sun-like sphere star and some planet-like spheres rotating on circular oribits around the sun star , and furthermore, to avoid confusion, we do not care the light direction and reflection light problem of sun and the planets.




      3.3.24 FileSystemBrowser

    As you know, Motif has an xmFileSelectionBoxWidgetClass to select a file as shown below:



    We have implemented FileBox and FileDialog to use the widget class. Unfortunately, this is not so convenient to browse folders and select files on a whole Linux file system.

    In the latest OZ++ class library, we have implemented a very simple experimental class FileSystemBrowser as a subclass of PopupView, by using the following two components:

    FolderSelectionBox which is a subclass of ScrolledWindow to wrap xmContainerWidgetClass and xmIconGadgetClass of Motif.

    FileListView which is a sublcas of ScrolledWindow to display folders or fileslist.




      3.3.25 ImageBlur

    As you know, OpenCV has some image filter classes and image-blur APIs Smoothing Images such as:

    blur
    GaussianBlur
    medianBlur
    bilateralFilter

    The following MedianBlur program is a simple example to blur an image based on mediaBlur funcition.
    The left pane is an orignal image, and the right pane is a blurred image created by a KernelSize trackbar control.




      3.3.26 ImageSharpen

    As shown in Unsharp masking, Unsharp masking (USM) is one of the image sharpening techniques. It uses a smoothed (blurred), or "unsharp", negative image to create a mask of the original image.
    The following imageSharpening program is a simple image sharpening example based on the USM technique, in which we have used the following two APIs:

    1 GaussinaBlur to create a blurred mask image from an original image.

    2 addWeighted to combine the blurred image and the original image.

    The left pane is an orignal image, and the right pane is a sharpened image created by KernelSize and Sigma trackbar controls.




      3.3.27 ObjectDetector

    One of the most interesting feature of OpenCV is an image recognition or object detection, which is a very important technology in modern computer vision based systems.
    For detail, please see the OpenCV documentation Cascade Classification Haar Feature-based Cascade Classifier for Object Detection.

    In the latest OpenCV version, the following two types of cascade classifiers are available:

  • Harr Feature-based Cascade Classifier

  • LBP(Local binary pattern) Cascade Classifier

  • On these cascade classifiers, please check your OpenCV installed directory, for example, you can find folders including classifier files under the folder "opencv/data/.
    The following ObjectDetector is a simple object detection example.

    1 Select a folder which contains Harr or LBP cascade classifiers by using a folder open dialog which can be popped up by clicking [...] button
    2 Select a cascade classifier xml file in a combobox.
    3 Open a target image file by using a file open dialog which can be popped up by Open menu item.
    4 Click Detect pushbutton.









      3.3.28 VideoDeviceEnumerator

    You can read a video image from a video input device somthing like a web-camera by using cv::VideoCapture class of OpenCV.
    In Linux enviroment, you have to install libv4l2-dev package.
    After the installation, you can see video devices on the folder /sys/class/video4linux/ as shown below.



    In this case, you have two video devices corresponding to the folders video0 and video1. By enumerating all device folders under the main folder /sys/class/video4linux, you can get all device informaton, and create a combobox to listup them and select a device index by a device name.

    In the latest OZ++ library, we have implemented VideoDevice, VideoInputDeviceEnumerator, and LabeledVideoCombobox classes to listup all video devices and select a device.

    The following VideoDeviceEnumerator program is a simple image capturing example based on the LabeledVideoDeviceComboBox, and VideoCapture classes of OZ++.








      3.3.29 OpenGLCVImageViews

    Imagine to map a cv::Mat image of OpenCV to a shape of OpenGL as a texture by using an image method of OpenGLTexture2D class of OZ++.
    In the latest OZ++ library, we have implemented OpenGLImageInfo and OpenCVImageInfo classes to extract the raw image data from a cv::Mat.
    We have also implemented OpenGLBulletinBoard class to layout an OpenCVImageView and an OpenGLView simultaneously on one bulletinboard.

    The following OpenGLCVImageViews program is a simple example to display an OpenCVImageView and an OpenGLView side by side. In this example, we get an OpenGLImageInfo from the cv::Mat image displayed on the left pane by using OpenCVImageInfo class, and map the OpenGLImageInfo to a quad shape of OpenGL of the right pane as a texture.
    of OZ++.



      3.3.30 BlurredMaterializedSpheres

    Imagine to read pixel data of an OpenGL frame buffer and convert it to a cv::Mat image format of OpenCV.
    Reading pixel data of the frame buffer can be done by using glReadPixels API of OpenGL, and creating a cv::Mat image by calling its constructor in the following way in a subclass, say SimpleGLView, derived from OpenGLView :

    class SimpleGLView : public OpenGLView {

      cv::Mat capture()
      {
        Dimension w = width();
        Dimension h = height();

        w = (w/8)*8;

        glReadBuffer(GL_FRONT);
        glPixelStorei(GL_UNPACK_ALIGNMENT, 1);

        unsigned char* pixels = new unsigned char[3 * w * h];
        glReadPixels(0, 0, w, h, GL_BGR, GL_UNSIGNED_BYTE, pixels);
        
        return cv::Mat(h, w, CV_8UC3, pixels);
      }
    };

    The following BlurredMaterializedSpheres program is a simple example to display some materialized shperes on an OpenGLView and a blurred cv::Mat image ,corresponding to the frame buffer of the OpenGLView, on an OpenCVImageView side by side.





      3.3.31 ImageTransformationByDynamicColorFilter

    As you know, you can transform an image by using a cv::Mat filter(Kernel) and cv::transform API of OpenCV as shown below.

        void applySepiaFilter(const char* filename)
        {
          cv::Mat originalImage = cv::imread(filename, cv::IMREAD_COLOR);
          cv::Mat transformedImage = originalImage.clone();

          //sepia filter
          cv::Mat sepia = (cv::Mat_<float>(3,3) <<
            0.272, 0.534, 0.131,
            0.349, 0.686, 0.168,
            0.393, 0.769, 0.189);
          cv::transform(originalImage, sepia, transformedImage);
         }

    In this case, the originalImage is transformed by the constant sepia filter to the transformedImage. This is a traditional constant filter example, however, it is much better to be able to apply a dynamically changeable color filter (Kernel) to a cv::Mat image.

    The following ImageTransformationByDynamicColorFilter is a simple example to implement a dynamic color filter by using OpenCVColorFilter class and ColorPositioner class of SOL9.





      3.3.32 TexturedSphereWithAxisEyeAndLightPositioner

    As show in 3.3.22_TexturedSphereRotationByKeyInput, it is easy to render and rotate a sphere textured by an image file in OpenGL.
    If we could dynamically change a rotation axis, an eye position, and a light position in that example, however, it would be a much better program.

    The following TexturedSphereWithAxisEyeAndLightPositioner is a simple example to render a sphere textured by a cylindrical planet map.
    In this example, we have used Venus map 'ven0aaa2.jpg' Caltech/JPL/USGS in the page JPL NASA SOLAR SYSTEM SIMULATOR .



    We have also used Lunar Orbiter's 'Lunar_LO_UVVISv2_Hybrid_Mosaic_Global_1024.jpg' in the page Astrogeology Science Center.



    Furthermore, we have used Voyager Galileo IO 'jup1vss2.jpg' in the page JPL NASA SOLAR SYSTEM SIMULATOR



      3.3.33 CustomYoloObjectDetector

    As you may know, the latest YOLOv3 contains a C++ Detetor class implementation (darknet-master/include/Detector.h). You can also define your own Detector C++ class based on C APIs of detector.c, image.c, etc. in darknet-master/src folders. The following CustomYoloObjectDetector is a simple example to use such a Detector C++ class.








     Last modified: 12 Feb. 2020

    Copyright (c) 2000-2020 Antillia.com ALL RIGHTS RESERVED.