The Library

- Algorithms
- API Wrappers
- Bayesian Nets
- Compression
- Containers
- Graph Tools
- Image Processing
- Linear Algebra
- Machine Learning
- Metaprogramming
- Miscellaneous
- Networking
- Optimization
- Parsing

Help/Info

- Examples: C++
  - 3D_Point_Cloud
  - Assignment_Learning
  - Base64_Encoder
  - Bayesian_Network
  - Bayesian_Network_From_Disk
  - Bayesian_Network_GUI
  - Bridge
  - BSP
  - C-Support_Vector_Machine
  - Cmd_Line_Parser
  - Compress_Stream
  - Config_File_Reader
  - Custom_Trainers
  - Directory_Navigation
  - Empirical_Kernel_Map
  - Face_Detection
  - Face_Landmark_Detection
  - FHOG_Feature_Extraction
  - FHOG_Object_Detection
  - Graph_Labeling
  - GUI
  - Hough_Transform
  - HTTP_Server
  - Image
  - IO Socket Streams
  - IO Streams Server
  - Kernel_Centroid
  - Kernel_K-Means_Clustering
  - Kernel_Ridge_Regression
  - Kernel_RLS_Filtering
  - Kernel_RLS_Regression
  - KRR_Classification
  - Learning_to_Track
  - Linear_Assignment_Problems
  - Linear_Manifold_Regularizer
  - Logger
  - Logger_Advanced
  - Logger_Custom_Output
  - Matrix
  - Matrix_Expressions
  - Member_Function_Pointer
  - Model_Selection
  - Multiclass_Classification
  - Multithreaded_Object
  - Neural_Network
  - Non-Linear Least Squares
  - Nu-Support_Vector_Machine
  - Numerical_Integration
  - Object_Detector
  - Object_Detector_Advanced
  - One_Class_Classifiers
  - Online_SVM
  - Optimization
  - Parallel_For_Loops
  - Pipe
  - Pipe_2
  - Quantum_Computing
  - Queue
  - Rank_Features
  - Relevance_Vector_Classification
  - Relevance_Vector_Regression
  - Running_Stats
  - Sequence_Labeling
  - Sequence_Segmentation
  - Sockets
  - Sockstreambuf
  - Sparse_Vectors
  - SQLite
  - Std_C++_Allocator
  - Structural_Support_Vector_Machines
  - Support_Vector_Regression
  - SURF
  - SVM-Rank
  - Threaded_Object
  - Threads
  - Thread_Function
  - Thread_Pool
  - Timer
  - Train_Object_Detector
  - Train_Shape_Predictor
  - Using_Custom_Kernels
  - Video_Object_Tracking
  - Webcam_Face_Pose_Estimation
  - XML_Parser
- Examples: Python
  - Face_Detector
  - Face_Landmark_Detection
  - find_candidate_object_locations
  - Linear_Assignment_Problems
  - Sequence_Segmenter
  - Structural_Support_Vector_Machines
  - SVM-Rank
  - Train_Object_Detector
  - Train_Shape_Predictor
- FAQ
- Home
- How to compile
- How to contribute
- Index
- Introduction
- License
- Python API
- Suggested Books

Current Release

- Change Log
- Release Notes
- Version: 18.15

Last Modified: Mar 22, 2015

# API Wrappers

These wrappers provide a portable object oriented interface for networking, multithreading, GUI development, and file browsing. Programs written using them can be compiled under POSIX or MS Windows platforms without changing the code.

API

- dir_nav
  - directory
  - file
  - file_exists
  - get_filesystem_roots
  - get_files_in_directory_tree
  - get_parent_directory
- gui_core
  - base_window
  - canvas
  - get_from_clipboard
  - put_on_clipboard
- gui_widgets
  - canvas drawing functions
    - draw_button_down
    - draw_button_up
    - draw_checkered
    - draw_circle
    - draw_image
    - draw_line
    - draw_pixel
    - draw_rectangle
    - draw_rounded_rectangle
    - draw_solid_circle
    - draw_solid_convex_polygon
    - draw_sunken_rectangle
    - fill_gradient_rounded
    - fill_rect
    - fill_rect_with_vertical_gradient
  - drawable
    - disable
    - disable_events
    - enable
    - enable_events
    - events
      - draw
      - on_focus_gained
      - on_focus_lost
      - on_keydown
      - on_mouse_down
      - on_mouse_enter
      - on_mouse_leave
      - on_mouse_move
      - on_mouse_up
      - on_string_put
      - on_user_event
      - on_wheel_down
      - on_wheel_up
      - on_window_moved
      - on_window_resized
    - events_are_enabled
    - hide
    - is_enabled
    - is_hidden
    - main_font
    - next_free_user_event_number
    - parent_window
    - set_main_font
    - set_pos
    - set_z_order
    - shape
      - bottom
      - get_rect
      - height
      - left
      - right
      - top
      - width
    - show
    - z_order
  - drawable_window
  - fonts
    - bdf_font
    - default_font
    - font
    - get_native_font
    - letter
  - styles
    - button_style
    - button_style_arrow
    - button_style_default
    - button_style_toolbar1
    - button_style_toolbar_icon1
    - list_box_style
    - list_box_style_default
    - scrollable_region_style
    - scrollable_region_style_default
    - scroll_bar_style
    - scroll_bar_style_default
    - text_box_style
    - text_box_style_default
    - text_field_style
    - text_field_style_default
    - toggle_button_style
    - toggle_button_style_check_box
    - toggle_button_style_default
    - toggle_button_style_radio_button
  - widgets
    - button
    - button_action
    - check_box
    - directed_graph_drawer
    - draggable
    - image_display
    - image_widget
    - image_window
    - label
    - list_box
    - menu_bar
    - menu_item
    - menu_item_separator
    - menu_item_submenu
    - menu_item_text
    - message_box
    - message_box_blocking
    - mouse_over_event
    - mouse_tracker
    - named_rectangle
    - open_existing_file_box
    - open_file_box
    - perspective_display
    - perspective_window
    - popup_menu
    - popup_menu_region
    - radio_button
    - save_file_box
    - scrollable_region
    - scroll_bar
    - tabbed_display
    - text_box
    - text_field
    - text_grid
    - toggle_button
    - tooltip
    - widget_group
    - zoomable_region
- misc_api
  - create_directory
  - get_current_dir
  - locally_change_current_dir
  - set_current_dir
  - sleep
  - timestamper
- sockets
  - extensions
    - close_gracefully
    - connect
    - is_ip_address
    - network_address
  - functions
    - create_connection
    - create_listener
    - get_local_hostname
    - hostname_to_ip
    - ip_to_hostname
  - objects
    - connection
    - listener
- threads
  - create_new_thread
  - extensions
    - auto_mutex
    - auto_mutex_readonly
    - auto_unlock
    - auto_unlock_readonly
    - create_new_thread_extension
    - future
    - multithreaded_object
    - parallel_for
    - read_write_mutex
    - rmutex
    - rsignaler
    - threaded_object
    - thread_function
    - thread_pool
    - thread_specific_data
  - get_thread_id
  - is_dlib_thread
  - mutex
  - register_thread_end_handler
  - signaler
  - unregister_thread_end_handler

[top]

# dir_nav

This is a set of objects that provide an easy and portable way to traverse a directory tree.
`#include <dlib/dir_nav.h>`
Detailed Documentation
C++ Example Programs: dir_nav_ex.cpp
Implementations:

> dir_nav_kernel_1: MS Windows implementation
> dir_nav_kernel_2: POSIX implementation

# Extensions to dir_nav

dir_nav_extensions
This is just some miscellaneous extensions to the dir_nav component.
Detailed Documentation
[top]

# gui_core

This is a set of objects and functions which provide a very basic framework for manipulating windows. It is intended to provide a portable interface which can be used to build a more complex windowing toolkit.
`#include <dlib/gui_core.h>`
Detailed Documentation
Implementations:

> gui_core_kernel_1: MS Windows implementation
> gui_core_kernel_2: X Windows implementation

[top]

# gui_widgets

This component is a collection of various windowing widgets such as buttons, labels, text boxes, and so on. It also includes the drawable interface, drawable_window, and font handling objects. dlib/gui_widgets/widgets_abstract.h defines all of the high level graphical widgets provided by this component that can appear in a drawable_window. To view the specifications for the other members of this component look at dlib/gui_widgets/fonts_abstract.h, dlib/gui_widgets/drawable_abstract.h, and dlib/gui_widgets/base_widgets_abstract.h.

This component isn't actually a wrapper on top of OS APIs. Rather, it is implemented on top of the gui_core component. I put it on this page just because I expect that people would look here when searching for the sort of functionality provided by this component.

## Primary widgets

`#include <dlib/gui_widgets.h>`
C++ Example Programs: gui_api_ex.cpp, image_ex.cpp, 3d_point_cloud_ex.cpp, surf_ex.cpp, bayes_net_gui_ex.cpp
[top]

# misc_api

This is just a collection of miscellaneous APIs that were small/simple enough not to warrant their own module.
`#include <dlib/misc_api.h>`
Detailed Documentation
Implementations:

> misc_api_kernel_1: MS Windows implementation
> misc_api_kernel_2: POSIX implementation

[top]

# sockets

This is a set of objects that provides an easy to use and object oriented interface for dealing with TCP networking. There are currently two implementations, one for UNIX and another for all versions of Windows after Windows95. Both provide the exact same interface so programs written with them can be recompiled on either platform without a problem.

You also may want to take note of the timeout object. It provides a mechanism which you can use to add a timeout to a network operation.

`#include <dlib/sockets.h>`
Detailed Documentation
C++ Example Programs: iosockstream_ex.cpp, sockets_ex.cpp, sockstreambuf_ex.cpp, server_http_ex.cpp, server_iostream_ex.cpp
Implementations:

> sockets_kernel_1: MS Windows implementation
> sockets_kernel_2: POSIX implementation

# Extensions to sockets

sockets_extensions
This is just some miscellaneous extensions to the socket api.
Detailed Documentation
[top]

# threads

This is a set of objects that provides an easy to use and object oriented interface for creating multi-threaded programs. There are currently two implementations, one for UNIX and another for any variant of MS Windows after Windows 95. Both provide the exact same interface so programs written with them can be recompiled on either platform without a problem.

You also probably want to take note of the pipe object. It provides an easy to use typesafe mechanism to send messages between threads.

`#include <dlib/threads.h>`
Detailed Documentation
C++ Example Programs: threads_ex.cpp, logger_ex_2.cpp, pipe_ex.cpp, multithreaded_object_ex.cpp, threaded_object_ex.cpp, thread_function_ex.cpp, thread_pool_ex.cpp
Implementations:

> threads_kernel_1: MS Windows implementation
> threads_kernel_2: POSIX implementation

# Extensions to threads

auto_mutex
This extension adds a mechanism to automatically lock and unlock a mutex. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
Detailed Documentation
C++ Example Programs: threads_ex.cpp
auto_mutex_readonly
This extension adds a mechanism to automatically perform a readonly lock and unlock of a read_write_mutex. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
Detailed Documentation
auto_unlock
This extension adds a mechanism to automatically unlock a mutex. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
Detailed Documentation
auto_unlock_readonly
This extension adds a mechanism to automatically remove a readonly unlock from a read_write_mutex. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
Detailed Documentation
create_new_thread_extension
This extension adds some templated overloads to the create_new_thread() function. They allow you to create new threads using member functions from a class. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
Detailed Documentation
multithreaded_object
This object represents a multithreaded object. It is similar to the threaded_object except it allows you to have many threads in a single object rather than just one.
Detailed Documentation
C++ Example Programs: multithreaded_object_ex.cpp, pipe_ex.cpp
parallel_for
This is a set of functions for executing the contents of a for loop in parallel. It is useful for taking advantage of multi-processor systems.
Detailed Documentation
C++ Example Programs: parallel_for_ex.cpp
read_write_mutex
This extension adds a mutex object that can perform both normal "write locks" as well as "readonly locks". See the specification for details. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
Detailed Documentation
rmutex
This extension adds a mutex object that can handle recursive calls to lock(). Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
Detailed Documentation
rsignaler
This extension adds a signaler object that can be used with the rmutex object. Also note that this extension is included by dlib/threads.h so you don't have to include anything extra to get it.
Detailed Documentation
threaded_object
This extension represents a simple threaded object. It provides a convenient mechanism to create an object that contains a thread.
Detailed Documentation
C++ Example Programs: threaded_object_ex.cpp
thread_function
This object represents a thread on a global C++ function. That is, it allows you to run a global function in its own thread.
Detailed Documentation
C++ Example Programs: thread_function_ex.cpp
thread_pool

This object represents a fixed size group of threads which you can submit tasks to and then wait for those tasks to be completed. It also provides a future object that provides a container which allows you to safely pass objects into the tasks.

The implementation of this extension can be found here. It is implemented such that no memory allocations occur after the thread pool has been constructed so long as the user doesn't call any of the add_task_by_value() routines. The future object also doesn't perform any memory allocations or contain any system resources such as mutex objects.
Detailed Documentation
C++ Example Programs: thread_pool_ex.cpp
thread_specific_data
This extension adds the ability to easily create thread specific data.
Detailed Documentation