├── dlib ├── cassert ├── cstring ├── fstream ├── iomanip ├── iosfwd ├── istream ├── locale ├── ostream ├── sstream ├── iostream ├── string │ ├── cassert │ ├── iomanip │ ├── iosfwd │ ├── locale │ └── iostream ├── md5.h ├── dir_nav │ ├── posix.h │ └── windows.h ├── sockets │ ├── posix.h │ └── windows.h ├── threads │ ├── posix.h │ ├── windows.h │ ├── threads_kernel.h │ ├── create_new_thread_extension_abstract.h │ ├── create_new_thread_extension.h │ ├── threads_kernel_2.cpp │ └── threads_kernel_1.cpp ├── gui_core │ ├── windows.h │ └── xlib.h ├── misc_api │ ├── posix.h │ ├── windows.h │ ├── misc_api_shared.h │ └── misc_api_kernel_2.h ├── revision.h.in ├── revision.h ├── rand.h ├── bsp.h ├── pipe.h ├── base64.h ├── crc32.h ├── linker.h ├── bridge.h ├── release_build_by_default ├── string.h ├── timeout.h ├── tuple.h ├── unicode.h ├── timer.h ├── sqlite.h ├── array.h ├── control.h ├── set_utils.h ├── vectorstream.h ├── bayes_utils.h ├── gui_widgets.h ├── sparse_vector.h ├── byte_orderer.h ├── matlab │ ├── example.m │ ├── CMakeLists.txt │ ├── README.txt │ └── example_mex_callback.cpp ├── stl_checked.h ├── test │ ├── examples │ │ └── CMakeLists.txt │ ├── create_iris_datafile.h │ ├── gui │ │ └── CMakeLists.txt │ ├── blas_bindings │ │ └── CMakeLists.txt │ ├── cmd_line_parser.cpp │ ├── cmd_line_parser_wchar_t.cpp │ ├── binary_search_tree_kernel_2a.cpp │ ├── binary_search_tree_kernel_1a.cpp │ ├── binary_search_tree_mm2.cpp │ ├── checkerboard.h │ ├── binary_search_tree_mm1.cpp │ ├── md5.cpp │ └── crc32.cpp ├── iosockstream.h ├── disjoint_subsets.h ├── opencv.h ├── all_gui.cpp ├── simd.h ├── type_safe_union.h ├── all_console.cpp ├── filtering.h ├── lsh.h ├── quantum_computing.h ├── server.h ├── logger.h ├── any.h ├── hash.h ├── bound_function_pointer.h ├── array2d.h ├── sockstreambuf.h ├── smart_pointers_thread_safe.h ├── xml_parser.h ├── graph_utils_threaded.h ├── graph_utils.h ├── numerical_integration.h ├── smart_pointers.h ├── gui_core.h ├── member_function_pointer.h ├── server │ └── server_iostream.cpp ├── python.h ├── external │ ├── libjpeg │ │ ├── jversion.h │ │ ├── jconfig.h │ │ └── jchuff.h │ └── zlib │ │ ├── inffast.h │ │ ├── gzclose.c │ │ └── uncompr.c ├── data_io.h ├── sockets.h ├── geometry.h ├── misc_api.h ├── clustering.h ├── dir_nav.h ├── graph_cuts.h ├── manifold_regularization.h ├── image_io.h ├── statistics.h ├── image_keypoint.h ├── mlp.h ├── matrix │ ├── cblas_constants.h │ ├── matrix_fwd.h │ └── matrix_data_layout_abstract.h ├── sync_extension.h ├── tell_visual_studio_to_use_static_runtime.cmake ├── python │ ├── pyassert.h │ └── boost_python_utils.h ├── matrix.h ├── tokenizer.h ├── reference_counter.h ├── stack.h ├── threads.h ├── image_processing │ ├── frontal_face_detector_abstract.h │ └── render_face_detections_abstract.h ├── graph.h ├── memory_manager_global.h ├── sliding_buffer.h ├── image_processing.h ├── directed_graph.h ├── optimization.h ├── static_map.h ├── bigint.h ├── image_keypoint │ ├── draw_surf_points_abstract.h │ └── draw_surf_points.h ├── image_transforms.h ├── noncopyable.h ├── add_global_compiler_switch.cmake ├── config.h ├── cpp_pretty_printer.h ├── array │ ├── array_tools.h │ └── array_tools_abstract.h ├── cpp_tokenizer.h ├── dlib_include_path_tutorial.txt ├── entropy_encoder.h ├── config_reader.h ├── entropy_decoder.h ├── lzp_buffer.h ├── bit_stream.h ├── svm │ ├── null_df.h │ ├── multiclass_tools_abstract.h │ ├── null_trainer.h │ └── multiclass_tools.h ├── config.h.in ├── logger │ ├── extra_logger_headers.cpp │ └── extra_logger_headers.h ├── lz77_buffer.h ├── opencv │ ├── to_open_cv_abstract.h │ └── to_open_cv.h ├── static_set.h ├── svm_threaded.h ├── general_hash │ ├── count_bits_abstract.h │ └── count_bits.h ├── image_loader │ └── load_image_abstract.h ├── md5 │ └── md5_kernel_1.h ├── LICENSE.txt ├── numerical_integration │ └── integrate_function_adapt_simpson_abstract.h ├── binary_search_tree.h ├── windows_magic.h ├── config_reader │ └── config_reader_thread_safe_abstract.h ├── platform.h ├── map.h ├── dlibConfig.cmake.in ├── sync_extension │ └── sync_extension_kernel_1.h ├── sequence │ ├── sequence_sort_abstract.h │ ├── sequence_sort_2.h │ └── sequence_compare_abstract.h ├── hash_set.h ├── numeric_constants.h ├── enable_if.h ├── clustering │ ├── spectral_cluster_abstract.h │ └── bottom_up_cluster_abstract.h ├── array2d │ └── array2d_generic_image.h ├── hash_table.h ├── statistics │ ├── image_feature_sampling_abstract.h │ └── average_precision.h ├── any │ └── any_function_impl2.h ├── image_saver │ ├── save_png_abstract.h │ └── save_jpeg_abstract.h ├── set.h ├── svm.h ├── hash_map.h ├── optimization │ └── max_sum_submatrix_abstract.h ├── queue.h ├── interfaces │ └── map_pair.h ├── sequence.h ├── entropy_encoder_model │ └── entropy_encoder_model_kernel_c.h ├── memory_manager.h └── memory_manager_stateless │ └── memory_manager_stateless_kernel_1.h ├── .gitignore ├── CMakeLists.txt ├── src ├── mainCaller.cpp ├── header │ └── FacialLandmark.h └── FacialLandmark.cpp ├── faces ├── training.xml └── testing.xml └── README.md /dlib/cassert: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/cstring: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/fstream: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/iomanip: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/iosfwd: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/istream: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/locale: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/ostream: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/sstream: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/iostream: -------------------------------------------------------------------------------- 1 | #include "dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/string/cassert: -------------------------------------------------------------------------------- 1 | #include "../dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/string/iomanip: -------------------------------------------------------------------------------- 1 | #include "../dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/string/iosfwd: -------------------------------------------------------------------------------- 1 | #include "../dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/string/locale: -------------------------------------------------------------------------------- 1 | #include "../dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/string/iostream: -------------------------------------------------------------------------------- 1 | #include "../dlib_include_path_tutorial.txt" 2 | -------------------------------------------------------------------------------- /dlib/md5.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #include "md5/md5_kernel_1.h" 4 | -------------------------------------------------------------------------------- /dlib/dir_nav/posix.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_DIR_NAV_KERNEl_1_ 4 | #include "dir_nav_kernel_2.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/sockets/posix.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SOCKETS_KERNEl_1_ 4 | #include "sockets_kernel_2.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/threads/posix.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_THREADS_KERNEl_1_ 4 | #include "threads_kernel_2.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/dir_nav/windows.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_DIR_NAV_KERNEl_2_ 4 | #include "dir_nav_kernel_1.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/gui_core/windows.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_GUI_CORE_KERNEl_2_ 4 | #include "gui_core_kernel_1.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/gui_core/xlib.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_GUI_CORE_KERNEl_1_ 4 | #include "gui_core_kernel_2.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/misc_api/posix.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MISC_API_KERNEl_1_ 4 | #include "misc_api_kernel_2.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/misc_api/windows.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MISC_API_KERNEl_2_ 4 | #include "misc_api_kernel_1.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/revision.h.in: -------------------------------------------------------------------------------- 1 | #ifndef DLIB_REVISION_H 2 | #define DLIB_MAJOR_VERSION @CPACK_PACKAGE_VERSION_MAJOR@ 3 | #define DLIB_MINOR_VERSION @CPACK_PACKAGE_VERSION_MINOR@ 4 | #define DLIB_PATCH_VERSION @CPACK_PACKAGE_VERSION_PATCH@ 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/sockets/windows.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SOCKETS_KERNEl_2_ 4 | #include "sockets_kernel_1.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/threads/windows.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_THREADS_KERNEl_2_ 4 | #include "threads_kernel_1.h" 5 | #endif 6 | 7 | -------------------------------------------------------------------------------- /dlib/revision.h: -------------------------------------------------------------------------------- 1 | #ifndef DLIB_REVISION_H 2 | // Version: 18.18 3 | // Date: Wed Oct 28 20:26:06 EDT 2015 4 | // Mercurial Revision ID: cea7cff961e1 5 | #define DLIB_MAJOR_VERSION 18 6 | #define DLIB_MINOR_VERSION 18 7 | #define DLIB_PATCH_VERSION 0 8 | #endif 9 | -------------------------------------------------------------------------------- /dlib/rand.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_RANd_ 4 | #define DLIB_RANd_ 5 | 6 | #include "rand/rand_kernel_1.h" 7 | 8 | #endif // DLIB_RANd_ 9 | 10 | -------------------------------------------------------------------------------- /dlib/bsp.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BSPh_ 4 | #define DLIB_BSPh_ 5 | 6 | 7 | #include "bsp/bsp.h" 8 | 9 | #endif // DLIB_BSPh_ 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /dlib/pipe.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_PIPe_ 4 | #define DLIB_PIPe_ 5 | 6 | #include "pipe/pipe_kernel_1.h" 7 | 8 | 9 | #endif // DLIB_PIPe_ 10 | 11 | -------------------------------------------------------------------------------- /dlib/base64.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BASe64_ 4 | #define DLIB_BASe64_ 5 | 6 | #include "base64/base64_kernel_1.h" 7 | 8 | #endif // DLIB_BASe64_ 9 | 10 | -------------------------------------------------------------------------------- /dlib/crc32.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_CRc32_ 4 | #define DLIB_CRc32_ 5 | 6 | 7 | #include "crc32/crc32_kernel_1.h" 8 | 9 | #endif // DLIB_CRc32_ 10 | 11 | -------------------------------------------------------------------------------- /dlib/linker.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_LINKEr_ 4 | #define DLIB_LINKEr_ 5 | 6 | #include "linker/linker_kernel_1.h" 7 | 8 | #endif // DLIB_LINKEr_ 9 | 10 | -------------------------------------------------------------------------------- /dlib/bridge.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BRIdGE_ 4 | #define DLIB_BRIdGE_ 5 | 6 | 7 | #include "bridge/bridge.h" 8 | 9 | #endif // DLIB_BRIdGE_ 10 | 11 | 12 | -------------------------------------------------------------------------------- /dlib/release_build_by_default: -------------------------------------------------------------------------------- 1 | 2 | #set default build type to Release 3 | if(NOT CMAKE_BUILD_TYPE) 4 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING 5 | "Choose the type of build, options are: Debug Release 6 | RelWithDebInfo MinSizeRel." FORCE) 7 | endif() 8 | 9 | 10 | -------------------------------------------------------------------------------- /dlib/string.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_STRINg_TOP_ 4 | #define DLIB_STRINg_TOP_ 5 | 6 | #include "string/string.h" 7 | 8 | #endif // DLIB_STRINg_TOP_ 9 | 10 | -------------------------------------------------------------------------------- /dlib/timeout.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_TIMEOUt_ 4 | #define DLIB_TIMEOUt_ 5 | 6 | #include "timeout/timeout.h" 7 | 8 | #endif // DLIB_TIMEOUt_ 9 | 10 | 11 | -------------------------------------------------------------------------------- /dlib/tuple.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_TUPLe_TOP_ 4 | #define DLIB_TUPLe_TOP_ 5 | 6 | #include "tuple/tuple.h" 7 | 8 | #endif // DLIB_TUPLe_TOPh_ 9 | 10 | 11 | -------------------------------------------------------------------------------- /dlib/unicode.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_UNICODe_TOP_ 4 | #define DLIB_UNICODe_TOP_ 5 | 6 | #include "unicode/unicode.h" 7 | 8 | #endif // DLIB_UNICODe_TOP_ 9 | 10 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.jpg 2 | *.jpeg 3 | Makefile* 4 | CMakeFile* 5 | cmake_install.cmake 6 | CMakeCache.txt 7 | dlib* 8 | dlib_build* 9 | haarcascades* 10 | shape_predictor_68_face_landmarks.dat 11 | testing_with_face_landmarks.xml 12 | training_with_face_landmarks.xml 13 | exec/* 14 | dlib_build/libdlib.a 15 | -------------------------------------------------------------------------------- /dlib/timer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_TIMEr_ 4 | #define DLIB_TIMEr_ 5 | 6 | #include "timer/timer.h" 7 | #include "timer/timer_heavy.h" 8 | 9 | #endif // DLIB_TIMEr_ 10 | 11 | -------------------------------------------------------------------------------- /dlib/sqlite.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SQLiTE_HEADER 4 | #define DLIB_SQLiTE_HEADER 5 | 6 | #include "sqlite/sqlite_tools.h" 7 | 8 | #endif // DLIB_SVm_HEADER 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /dlib/array.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ARRAy_ 4 | #define DLIB_ARRAy_ 5 | 6 | #include "array/array_kernel.h" 7 | #include "array/array_tools.h" 8 | 9 | #endif // DLIB_ARRAy_ 10 | 11 | -------------------------------------------------------------------------------- /dlib/control.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_CONTRoL_ 4 | #define DLIB_CONTRoL_ 5 | 6 | #include "control/lspi.h" 7 | #include "control/mpc.h" 8 | 9 | #endif // DLIB_CONTRoL_ 10 | 11 | 12 | -------------------------------------------------------------------------------- /dlib/set_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SET_UTILs_H_ 4 | #define DLIB_SET_UTILs_H_ 5 | 6 | #include "set_utils/set_utils.h" 7 | 8 | #endif // DLIB_SET_UTILs_H_ 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /dlib/vectorstream.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_VECTORSTReAMh_ 4 | #define DLIB_VECTORSTReAMh_ 5 | 6 | #include "vectorstream/vectorstream.h" 7 | 8 | 9 | #endif // DLIB_VECTORSTReAMh_ 10 | 11 | -------------------------------------------------------------------------------- /dlib/bayes_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BAYES_UTILs_H_ 4 | #define DLIB_BAYES_UTILs_H_ 5 | 6 | #include "bayes_utils/bayes_utils.h" 7 | 8 | #endif // DLIB_BAYES_UTILs_H_ 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /dlib/gui_widgets.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_GUI_WIDGETs_ 4 | #define DLIB_GUI_WIDGETs_ 5 | 6 | 7 | 8 | #include "gui_widgets/widgets.h" 9 | 10 | 11 | 12 | #endif // DLIB_GUI_WIDGETs_ 13 | 14 | -------------------------------------------------------------------------------- /dlib/sparse_vector.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SPaRSE_VECTOR_Hh_ 4 | #define DLIB_SPaRSE_VECTOR_Hh_ 5 | 6 | #include "svm/sparse_vector.h" 7 | 8 | #endif // DLIB_SPaRSE_VECTOR_Hh_ 9 | 10 | 11 | -------------------------------------------------------------------------------- /dlib/byte_orderer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BYTE_ORDEREr_ 4 | #define DLIB_BYTE_ORDEREr_ 5 | 6 | 7 | #include "byte_orderer/byte_orderer_kernel_1.h" 8 | 9 | #endif // DLIB_BYTE_ORDEREr_ 10 | 11 | -------------------------------------------------------------------------------- /dlib/matlab/example.m: -------------------------------------------------------------------------------- 1 | % This example calls the two mex functions defined in this folder. As you 2 | % can see, you call them just like you would normal MATLAB functions. 3 | 4 | x = magic(3) 5 | y = 2*magic(3) 6 | 7 | [out1, out2] = example_mex_function(x,y, 12345) 8 | 9 | z = example_mex_callback(x, @(a)a+a) 10 | 11 | -------------------------------------------------------------------------------- /dlib/stl_checked.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_STL_CHECKEd_HEADER 4 | #define DLIB_STL_CHECKEd_HEADER 5 | 6 | #include "stl_checked/std_vector_c.h" 7 | 8 | #endif // DLIB_STL_CHECKEd_HEADER 9 | 10 | 11 | -------------------------------------------------------------------------------- /dlib/test/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Disable some warnings from gcc when compiling the examples because fixing them would make the 3 | # examples harder to read. 4 | if (CMAKE_COMPILER_IS_GNUCXX) 5 | add_definitions("-Wno-comment -Wno-unused-parameter") 6 | endif() 7 | 8 | add_subdirectory(../../../examples examples_build) 9 | -------------------------------------------------------------------------------- /dlib/iosockstream.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_IOSOCkSTREAM_H_h_ 4 | #define DLIB_IOSOCkSTREAM_H_h_ 5 | 6 | #include "iosockstream/iosockstream.h" 7 | 8 | 9 | #endif // DLIB_IOSOCkSTREAM_H_h_ 10 | 11 | 12 | -------------------------------------------------------------------------------- /dlib/disjoint_subsets.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_DISJOINt_SUBSETS_ 4 | #define DLIB_DISJOINt_SUBSETS_ 5 | 6 | 7 | #include "disjoint_subsets/disjoint_subsets.h" 8 | 9 | #endif // DLIB_DISJOINt_SUBSETS_ 10 | 11 | 12 | -------------------------------------------------------------------------------- /dlib/opencv.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_OPEnCV_HEADER 4 | #define DLIB_OPEnCV_HEADER 5 | 6 | #include "opencv/cv_image.h" 7 | #include "opencv/to_open_cv.h" 8 | 9 | #endif // DLIB_OPEnCV_HEADER 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /dlib/all_gui.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ALL_GUi_ 4 | #define DLIB_ALL_GUi_ 5 | 6 | #error "This file has been replaced. Instead you should add dlib/all/source.cpp to your project" 7 | 8 | #endif // DLIB_ALL_GUi_ 9 | 10 | -------------------------------------------------------------------------------- /dlib/simd.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SIMd_Hh_ 4 | #define DLIB_SIMd_Hh_ 5 | 6 | #include "simd/simd4f.h" 7 | #include "simd/simd4i.h" 8 | #include "simd/simd8f.h" 9 | #include "simd/simd8i.h" 10 | 11 | #endif // DLIB_SIMd_Hh_ 12 | 13 | -------------------------------------------------------------------------------- /dlib/type_safe_union.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_TYPE_SAFE_UNIOn_TOP_ 4 | #define DLIB_TYPE_SAFE_UNIOn_TOP_ 5 | 6 | #include "type_safe_union/type_safe_union_kernel.h" 7 | 8 | #endif // DLIB_TYPE_SAFE_UNIOn_TOP_ 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /dlib/all_console.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ALL_CONSOLe_ 4 | #define DLIB_ALL_CONSOLe_ 5 | 6 | #error "This file has been replaced. Instead you should add dlib/all/source.cpp to your project" 7 | 8 | #endif // DLIB_ALL_CONSOLe_ 9 | 10 | -------------------------------------------------------------------------------- /dlib/filtering.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_FILTERiNG_HEADER 4 | #define DLIB_FILTERiNG_HEADER 5 | 6 | #include "filtering/kalman_filter.h" 7 | #include "filtering/rls_filter.h" 8 | 9 | #endif // DLIB_FILTERiNG_HEADER 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /dlib/lsh.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_LSh_ 4 | #define DLIB_LSh_ 5 | 6 | 7 | #include "lsh/projection_hash.h" 8 | #include "lsh/create_random_projection_hash.h" 9 | #include "lsh/hashes.h" 10 | 11 | 12 | #endif // DLIB_LSh_ 13 | 14 | 15 | -------------------------------------------------------------------------------- /dlib/quantum_computing.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_QUANTUM_COMPUTINg_H_ 4 | #define DLIB_QUANTUM_COMPUTINg_H_ 5 | 6 | #include "quantum_computing/quantum_computing.h" 7 | 8 | #endif // DLIB_QUANTUM_COMPUTINg_H_ 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /dlib/server.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SERVEr_ 4 | #define DLIB_SERVEr_ 5 | 6 | #include "server/server_kernel.h" 7 | #include "server/server_iostream.h" 8 | #include "server/server_http.h" 9 | 10 | 11 | #endif // DLIB_SERVEr_ 12 | 13 | -------------------------------------------------------------------------------- /dlib/logger.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_LOGGEr_ 4 | #define DLIB_LOGGEr_ 5 | 6 | #include "logger/logger_kernel_1.h" 7 | #include "logger/extra_logger_headers.h" 8 | #include "logger/logger_config_file.h" 9 | 10 | #endif // DLIB_LOGGEr_ 11 | 12 | -------------------------------------------------------------------------------- /dlib/any.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_AnY_ 4 | #define DLIB_AnY_ 5 | 6 | #include "any/any.h" 7 | #include "any/any_trainer.h" 8 | #include "any/any_decision_function.h" 9 | #include "any/any_function.h" 10 | 11 | #endif // DLIB_AnY_ 12 | 13 | 14 | -------------------------------------------------------------------------------- /dlib/hash.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_HASh_ 4 | #define DLIB_HASh_ 5 | 6 | 7 | #include "general_hash/hash.h" 8 | #include "general_hash/random_hashing.h" 9 | #include "general_hash/count_bits.h" 10 | 11 | 12 | #endif // DLIB_HASh_ 13 | 14 | 15 | -------------------------------------------------------------------------------- /dlib/bound_function_pointer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BOUND_FUNCTION_POINTEr_ 4 | #define DLIB_BOUND_FUNCTION_POINTEr_ 5 | 6 | #include "bound_function_pointer/bound_function_pointer_kernel_1.h" 7 | 8 | #endif // DLIB_BOUND_FUNCTION_POINTEr_ 9 | 10 | 11 | -------------------------------------------------------------------------------- /dlib/array2d.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ARRAY2d_ 4 | #define DLIB_ARRAY2d_ 5 | 6 | 7 | #include "array2d/array2d_kernel.h" 8 | #include "array2d/serialize_pixel_overloads.h" 9 | #include "array2d/array2d_generic_image.h" 10 | 11 | #endif // DLIB_ARRAY2d_ 12 | 13 | -------------------------------------------------------------------------------- /dlib/sockstreambuf.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SOCKSTREAMBUf_H_h_ 4 | #define DLIB_SOCKSTREAMBUf_H_h_ 5 | 6 | #include "sockstreambuf/sockstreambuf.h" 7 | #include "sockstreambuf/sockstreambuf_unbuffered.h" 8 | 9 | 10 | #endif // DLIB_SOCKSTREAMBUf_H_h_ 11 | 12 | -------------------------------------------------------------------------------- /dlib/smart_pointers_thread_safe.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SMART_POINTERs_THREAD_SAFE_H_ 4 | #define DLIB_SMART_POINTERs_THREAD_SAFE_H_ 5 | 6 | #include "smart_pointers/shared_ptr_thread_safe.h" 7 | 8 | #endif // DLIB_SMART_POINTERs_THREAD_SAFE_H_ 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /dlib/xml_parser.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_XML_PARSEr_ 4 | #define DLIB_XML_PARSEr_ 5 | 6 | #include 7 | 8 | #include "xml_parser/xml_parser_kernel_interfaces.h" 9 | #include "xml_parser/xml_parser_kernel_1.h" 10 | 11 | 12 | #endif // DLIB_XML_PARSEr_ 13 | 14 | -------------------------------------------------------------------------------- /dlib/graph_utils_threaded.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_GRAPH_UTILs_THREADED_H_ 4 | #define DLIB_GRAPH_UTILs_THREADED_H_ 5 | 6 | #include "graph_utils.h" 7 | #include "graph_utils/find_k_nearest_neighbors_lsh.h" 8 | 9 | #endif // DLIB_GRAPH_UTILs_THREADED_H_ 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /dlib/graph_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_GRAPH_UTILs_H_ 4 | #define DLIB_GRAPH_UTILs_H_ 5 | 6 | #include "graph_utils/graph_utils.h" 7 | #include "graph_utils/edge_list_graphs.h" 8 | #include "graph_utils/function_objects.h" 9 | 10 | #endif // DLIB_GRAPH_UTILs_H_ 11 | 12 | 13 | -------------------------------------------------------------------------------- /dlib/numerical_integration.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Steve Taylor (steve98654@gmail.com) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_HEADER 4 | #define DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_HEADER 5 | 6 | #include "numerical_integration/integrate_function_adapt_simpson.h" 7 | 8 | #endif // DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_HEADER 9 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8) 2 | 3 | project( AnimeAvataar ) 4 | 5 | include(./dlib/cmake) 6 | 7 | #FILE(GLOB source src/*.cpp) 8 | #set (source src/face_landmark_detection_ex.cpp) 9 | set (source src/mainCaller.cpp src/FacialLandmark.cpp src/header/FacialLandmark.h) 10 | ADD_EXECUTABLE(exec/Feature_extraction ${source}) 11 | 12 | TARGET_LINK_LIBRARIES(exec/Feature_extraction dlib) 13 | -------------------------------------------------------------------------------- /dlib/smart_pointers.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SMART_POINTERs_H_ 4 | #define DLIB_SMART_POINTERs_H_ 5 | 6 | #include "smart_pointers/scoped_ptr.h" 7 | #include "smart_pointers/shared_ptr.h" 8 | #include "smart_pointers/weak_ptr.h" 9 | 10 | #endif // DLIB_SMART_POINTERs_H_ 11 | 12 | 13 | -------------------------------------------------------------------------------- /dlib/gui_core.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_GUI_CORe_ 4 | #define DLIB_GUI_CORe_ 5 | 6 | 7 | #include "platform.h" 8 | 9 | 10 | 11 | #ifdef WIN32 12 | #include "gui_core/windows.h" 13 | #else 14 | #include "gui_core/xlib.h" 15 | #endif 16 | 17 | 18 | 19 | #endif // DLIB_GUI_CORe_ 20 | 21 | -------------------------------------------------------------------------------- /dlib/member_function_pointer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MEMBER_FUNCTION_POINTEr_ 4 | #define DLIB_MEMBER_FUNCTION_POINTEr_ 5 | 6 | #include "member_function_pointer/member_function_pointer_kernel_1.h" 7 | #include "member_function_pointer/make_mfp.h" 8 | 9 | #endif // DLIB_MEMBER_FUNCTION_POINTEr_ 10 | 11 | -------------------------------------------------------------------------------- /dlib/server/server_iostream.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SERVER_IOSTREAM_CPp_ 4 | #define DLIB_SERVER_IOSTREAM_CPp_ 5 | 6 | #include "server_iostream.h" 7 | 8 | namespace dlib 9 | { 10 | const logger server_iostream::_dLog("dlib.server_iostream"); 11 | } 12 | 13 | #endif // DLIB_SERVER_IOSTREAM_CPp_ 14 | 15 | -------------------------------------------------------------------------------- /dlib/threads/threads_kernel.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_THREADs_KERNEL_ 4 | #define DLIB_THREADs_KERNEL_ 5 | 6 | #include "../platform.h" 7 | 8 | #ifdef WIN32 9 | #include "windows.h" 10 | #endif 11 | 12 | #ifndef WIN32 13 | #include "posix.h" 14 | #endif 15 | 16 | #endif // DLIB_THREADs_KERNEL_ 17 | 18 | 19 | -------------------------------------------------------------------------------- /dlib/python.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_PYTHoN_TOP_ 4 | #define DLIB_PYTHoN_TOP_ 5 | 6 | #include "python/boost_python_utils.h" 7 | #include "python/pyassert.h" 8 | #include "python/serialize_pickle.h" 9 | #include "python/numpy.h" 10 | #include "python/numpy_image.h" 11 | 12 | #endif // DLIB_PYTHoN_TOP_ 13 | 14 | 15 | -------------------------------------------------------------------------------- /dlib/external/libjpeg/jversion.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jversion.h 3 | * 4 | * Copyright (C) 1991-1998, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains software version identification. 9 | */ 10 | 11 | 12 | #define JVERSION "6b 27-Mar-1998" 13 | 14 | #define JCOPYRIGHT "Copyright (C) 1998, Thomas G. Lane" 15 | -------------------------------------------------------------------------------- /dlib/data_io.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_DATA_Io_HEADER 4 | #define DLIB_DATA_Io_HEADER 5 | 6 | #include "data_io/libsvm_io.h" 7 | #include "data_io/image_dataset_metadata.h" 8 | 9 | #ifndef DLIB_ISO_CPP_ONLY 10 | #include "data_io/load_image_dataset.h" 11 | #endif 12 | 13 | #endif // DLIB_DATA_Io_HEADER 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /dlib/sockets.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SOCKETs_ 4 | #define DLIB_SOCKETs_ 5 | 6 | #include "platform.h" 7 | 8 | 9 | #ifdef WIN32 10 | #include "sockets/windows.h" 11 | #endif 12 | 13 | #ifndef WIN32 14 | #include "sockets/posix.h" 15 | #endif 16 | 17 | #include "sockets/sockets_extensions.h" 18 | 19 | #endif // DLIB_SOCKETs_ 20 | 21 | -------------------------------------------------------------------------------- /dlib/geometry.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_GEOMETRy_HEADER 4 | #define DLIB_GEOMETRy_HEADER 5 | 6 | #include "geometry/rectangle.h" 7 | #include "geometry/drectangle.h" 8 | #include "geometry/vector.h" 9 | #include "geometry/border_enumerator.h" 10 | #include "geometry/point_transforms.h" 11 | 12 | #endif // DLIB_GEOMETRy_HEADER 13 | 14 | 15 | -------------------------------------------------------------------------------- /dlib/misc_api.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | 4 | #ifndef DLIB_MISC_APi_ 5 | #define DLIB_MISC_APi_ 6 | 7 | #include "platform.h" 8 | 9 | #ifdef WIN32 10 | #include "misc_api/windows.h" 11 | #endif 12 | 13 | #ifndef WIN32 14 | #include "misc_api/posix.h" 15 | #endif 16 | 17 | #include "misc_api/misc_api_shared.h" 18 | 19 | #endif // DLIB_MISC_APi_ 20 | 21 | -------------------------------------------------------------------------------- /dlib/clustering.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_CLuSTERING_ 4 | #define DLIB_CLuSTERING_ 5 | 6 | #include "clustering/modularity_clustering.h" 7 | #include "clustering/chinese_whispers.h" 8 | #include "clustering/spectral_cluster.h" 9 | #include "clustering/bottom_up_cluster.h" 10 | #include "svm/kkmeans.h" 11 | 12 | #endif // DLIB_CLuSTERING_ 13 | 14 | -------------------------------------------------------------------------------- /dlib/dir_nav.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_DIR_NAv_ 4 | #define DLIB_DIR_NAv_ 5 | 6 | 7 | #include "platform.h" 8 | 9 | 10 | #ifdef WIN32 11 | #include "dir_nav/windows.h" 12 | #endif 13 | 14 | #ifndef WIN32 15 | #include "dir_nav/posix.h" 16 | #endif 17 | 18 | #include "dir_nav/dir_nav_extensions.h" 19 | 20 | #endif // DLIB_DIR_NAv_ 21 | 22 | -------------------------------------------------------------------------------- /dlib/graph_cuts.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_GRAPH_CUTs_HEADER_ 4 | #define DLIB_GRAPH_CUTs_HEADER_ 5 | 6 | #include "graph_cuts/min_cut.h" 7 | #include "graph_cuts/general_flow_graph.h" 8 | #include "graph_cuts/find_max_factor_graph_potts.h" 9 | #include "graph_cuts/graph_labeler.h" 10 | 11 | #endif // DLIB_GRAPH_CUTs_HEADER_ 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /dlib/matlab/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 2.8.4) 3 | 4 | PROJECT(mex_functions) 5 | 6 | include(cmake_mex_wrapper) 7 | 8 | include(../cmake) 9 | 10 | # Compile the example_mex_function.cpp file and link it to dlib. Note 11 | # that you can give a list of things to link to here. E.g. 12 | # add_mex_function(some_other_mex_function pthread dlib fftw) 13 | add_mex_function(example_mex_function dlib) 14 | add_mex_function(example_mex_callback dlib) 15 | 16 | -------------------------------------------------------------------------------- /src/mainCaller.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "header/FacialLandmark.h" 3 | using namespace std; 4 | 5 | int main(int argc, char** argv) 6 | { 7 | if(argc < 2){ 8 | cout << "please provide shape_predictor_68_face_landmarks and image as command line input \n" << endl; 9 | cout << " e.g. program shape_predictor_68_face_landmarks.dat faces/*.jpg \n" << endl; 10 | return 0; 11 | } 12 | featureExtractor landmark(argc, argv); 13 | landmark.faceShape(); 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /dlib/external/zlib/inffast.h: -------------------------------------------------------------------------------- 1 | /* inffast.h -- header to use inffast.c 2 | * Copyright (C) 1995-2003, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* WARNING: this file should *not* be used by applications. It is 7 | part of the implementation of the compression library and is 8 | subject to change. Applications should only use zlib.h. 9 | */ 10 | 11 | void ZLIB_INTERNAL inflate_fast OF((z_streamp strm, unsigned start)); 12 | -------------------------------------------------------------------------------- /dlib/manifold_regularization.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MANIFOLD_REGULARIzATION_HEADER 4 | #define DLIB_MANIFOLD_REGULARIzATION_HEADER 5 | 6 | #include "graph_utils/edge_list_graphs.h" 7 | #include "manifold_regularization/linear_manifold_regularizer.h" 8 | #include "graph_utils/function_objects.h" 9 | 10 | #endif // DLIB_MANIFOLD_REGULARIzATION_HEADER 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /dlib/image_io.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_IMAGe_IO_ 4 | #define DLIB_IMAGe_IO_ 5 | 6 | #include "image_loader/image_loader.h" 7 | #include "image_loader/png_loader.h" 8 | #include "image_loader/jpeg_loader.h" 9 | #include "image_loader/load_image.h" 10 | #include "image_saver/image_saver.h" 11 | #include "image_saver/save_png.h" 12 | #include "image_saver/save_jpeg.h" 13 | 14 | #endif // DLIB_IMAGe_IO_ 15 | 16 | -------------------------------------------------------------------------------- /dlib/statistics.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_STATISTICs_H_ 4 | #define DLIB_STATISTICs_H_ 5 | 6 | #include "statistics/statistics.h" 7 | #include "statistics/dpca.h" 8 | #include "statistics/random_subset_selector.h" 9 | #include "statistics/image_feature_sampling.h" 10 | #include "statistics/sammon.h" 11 | #include "statistics/cca.h" 12 | #include "statistics/average_precision.h" 13 | #include "statistics/vector_normalizer_frobmetric.h" 14 | #include "statistics/lda.h" 15 | 16 | #endif // DLIB_STATISTICs_H_ 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /src/header/FacialLandmark.h: -------------------------------------------------------------------------------- 1 | #ifndef _FACIALLANDMARK_H 2 | #define _FACIALLANDMARK_H 3 | 4 | // included dependencies 5 | #include "../../dlib/image_processing/frontal_face_detector.h" 6 | #include "../../dlib/image_processing/render_face_detections.h" 7 | #include "../../dlib/image_processing.h" 8 | #include "../../dlib/gui_widgets.h" 9 | #include "../../dlib/image_io.h" 10 | 11 | 12 | class featureExtractor { 13 | private: 14 | int numberOfImage; 15 | char ** imageList; 16 | public: 17 | featureExtractor(int numberOfImage, char **imageList); 18 | //std::vector faceShape(); 19 | void faceShape(); 20 | }; 21 | #endif 22 | -------------------------------------------------------------------------------- /dlib/image_keypoint.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_IMAGE_KEYPOINt_H_ 4 | #define DLIB_IMAGE_KEYPOINt_H_ 5 | 6 | #include "image_keypoint/surf.h" 7 | #include "image_keypoint/hessian_pyramid.h" 8 | #include "image_keypoint/hog.h" 9 | #include "image_keypoint/poly_image.h" 10 | #include "image_keypoint/fine_hog_image.h" 11 | #include "image_keypoint/hashed_feature_image.h" 12 | #include "image_keypoint/nearest_neighbor_feature_image.h" 13 | #include "image_keypoint/binned_vector_feature_image.h" 14 | 15 | #endif // DLIB_IMAGE_KEYPOINt_H_ 16 | 17 | -------------------------------------------------------------------------------- /dlib/mlp.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MLp_ 4 | #define DLIB_MLp_ 5 | 6 | #include "mlp/mlp_kernel_1.h" 7 | #include "mlp/mlp_kernel_c.h" 8 | 9 | namespace dlib 10 | { 11 | 12 | class mlp 13 | { 14 | mlp() {} 15 | 16 | public: 17 | 18 | //----------- kernels --------------- 19 | 20 | // kernel_1a 21 | typedef mlp_kernel_1 22 | kernel_1a; 23 | typedef mlp_kernel_c 24 | kernel_1a_c; 25 | 26 | }; 27 | } 28 | 29 | #endif // DLIB_MLp_ 30 | 31 | -------------------------------------------------------------------------------- /dlib/test/create_iris_datafile.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_CREATE_IRIS_DAtAFILE_Hh_ 4 | #define DLIB_CREATE_IRIS_DAtAFILE_Hh_ 5 | 6 | namespace dlib 7 | { 8 | void create_iris_datafile ( 9 | ); 10 | /*! 11 | ensures 12 | - Creates a local file called iris.scale that contains the 13 | 150 samples from the 3-class Iris dataset from the UCI 14 | repository. The file will be in LIBSVM format (it was 15 | originally downloaded from the LIBSVM website). 16 | !*/ 17 | } 18 | 19 | #endif // DLIB_CREATE_IRIS_DAtAFILE_Hh_ 20 | -------------------------------------------------------------------------------- /dlib/matrix/cblas_constants.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_CBLAS_CONSTAnTS_Hh_ 4 | #define DLIB_CBLAS_CONSTAnTS_Hh_ 5 | 6 | namespace dlib 7 | { 8 | namespace blas_bindings 9 | { 10 | enum CBLAS_ORDER {CblasRowMajor=101, CblasColMajor=102}; 11 | enum CBLAS_TRANSPOSE {CblasNoTrans=111, CblasTrans=112, CblasConjTrans=113}; 12 | enum CBLAS_UPLO {CblasUpper=121, CblasLower=122}; 13 | enum CBLAS_DIAG {CblasNonUnit=131, CblasUnit=132}; 14 | enum CBLAS_SIDE {CblasLeft=141, CblasRight=142}; 15 | 16 | } 17 | } 18 | 19 | #endif // DLIB_CBLAS_CONSTAnTS_Hh_ 20 | 21 | -------------------------------------------------------------------------------- /dlib/test/gui/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This is a CMake makefile. You can find the cmake utility and 3 | # information about it at http://www.cmake.org 4 | # 5 | 6 | # create a variable called target_name and set it to the string "test" 7 | set (target_name gui) 8 | 9 | PROJECT(${target_name}) 10 | 11 | # add all the cpp files we want to compile to this list. This tells 12 | # cmake that they are part of our target (which is the executable named test) 13 | ADD_EXECUTABLE(${target_name} main.cpp ) 14 | 15 | # Add the folder containing the dlib folder to the include path 16 | INCLUDE_DIRECTORIES(../../..) 17 | 18 | # Tell cmake to link our target executable to dlib. 19 | TARGET_LINK_LIBRARIES(${target_name} dlib ) 20 | 21 | -------------------------------------------------------------------------------- /dlib/matlab/README.txt: -------------------------------------------------------------------------------- 1 | This folder contains a set of tools which make it easy to create MATLAB mex 2 | functions. To understand how they work, you should read the 3 | example_mex_function.cpp and example_mex_callback.cpp examples. 4 | 5 | To compile them, you can use CMake. In particular, from this folder execute 6 | these commands: 7 | 8 | mkdir build 9 | cd build 10 | cmake .. 11 | cmake --build . --config release --target install 12 | 13 | That should build the mex files on any platform. 14 | 15 | Note that on windows you will probably need to tell CMake to use a 64bit 16 | version of visual studio. You can do this by using a command like: 17 | cmake -G "Visual Studio 10 Win64" .. 18 | instead of 19 | cmake .. 20 | 21 | -------------------------------------------------------------------------------- /dlib/sync_extension.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SYNC_EXTENSIOn_ 4 | #define DLIB_SYNC_EXTENSIOn_ 5 | 6 | #include "sync_extension/sync_extension_kernel_1.h" 7 | 8 | 9 | 10 | namespace dlib 11 | { 12 | 13 | template < 14 | typename base 15 | > 16 | class sync_extension 17 | { 18 | sync_extension() {} 19 | public: 20 | 21 | //----------- kernels --------------- 22 | 23 | // kernel_1a 24 | typedef sync_extension_kernel_1 25 | kernel_1a; 26 | 27 | }; 28 | } 29 | 30 | #endif // DLIB_SYNC_EXTENSIOn_ 31 | 32 | -------------------------------------------------------------------------------- /dlib/tell_visual_studio_to_use_static_runtime.cmake: -------------------------------------------------------------------------------- 1 | 2 | # Including this cmake script into your cmake project will cause visual studio 3 | # to build your project against the static C runtime. 4 | 5 | cmake_minimum_required(VERSION 2.6.4) 6 | if (POLICY CMP0054) 7 | cmake_policy(SET CMP0054 NEW) 8 | endif() 9 | 10 | if (MSVC OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC") 11 | foreach(flag_var 12 | CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE 13 | CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO) 14 | if(${flag_var} MATCHES "/MD") 15 | string(REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}") 16 | endif() 17 | endforeach(flag_var) 18 | endif() 19 | 20 | -------------------------------------------------------------------------------- /dlib/python/pyassert.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_PYaSSERT_Hh_ 4 | #define DLIB_PYaSSERT_Hh_ 5 | 6 | #include 7 | 8 | #define pyassert(_exp,_message) \ 9 | {if ( !(_exp) ) \ 10 | { \ 11 | PyErr_SetString( PyExc_ValueError, _message ); \ 12 | boost::python::throw_error_already_set(); \ 13 | }} 14 | 15 | #endif // DLIB_PYaSSERT_Hh_ 16 | 17 | -------------------------------------------------------------------------------- /dlib/matrix.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MATRIx_HEADER 4 | #define DLIB_MATRIx_HEADER 5 | 6 | #include "matrix/matrix.h" 7 | #include "matrix/matrix_utilities.h" 8 | #include "matrix/matrix_subexp.h" 9 | #include "matrix/matrix_math_functions.h" 10 | #include "matrix/matrix_assign.h" 11 | #include "matrix/matrix_la.h" 12 | #include "matrix/symmetric_matrix_cache.h" 13 | #include "matrix/matrix_conv.h" 14 | #include "matrix/matrix_read_from_istream.h" 15 | #include "matrix/matrix_fft.h" 16 | #include "matrix/matrix_generic_image.h" 17 | 18 | #ifdef DLIB_USE_BLAS 19 | #include "matrix/matrix_blas_bindings.h" 20 | #endif 21 | 22 | #endif // DLIB_MATRIx_HEADER 23 | 24 | 25 | -------------------------------------------------------------------------------- /dlib/tokenizer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_TOKENIZEr_ 4 | #define DLIB_TOKENIZEr_ 5 | 6 | #include "tokenizer/tokenizer_kernel_1.h" 7 | #include "tokenizer/tokenizer_kernel_c.h" 8 | 9 | 10 | namespace dlib 11 | { 12 | 13 | class tokenizer 14 | { 15 | tokenizer() {} 16 | 17 | 18 | public: 19 | 20 | //----------- kernels --------------- 21 | 22 | // kernel_1a 23 | typedef tokenizer_kernel_1 24 | kernel_1a; 25 | typedef tokenizer_kernel_c 26 | kernel_1a_c; 27 | 28 | 29 | }; 30 | } 31 | 32 | #endif // DLIB_TOKENIZEr_ 33 | 34 | -------------------------------------------------------------------------------- /dlib/external/zlib/gzclose.c: -------------------------------------------------------------------------------- 1 | /* gzclose.c -- zlib gzclose() function 2 | * Copyright (C) 2004, 2010 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "gzguts.h" 7 | 8 | /* gzclose() is in a separate file so that it is linked in only if it is used. 9 | That way the other gzclose functions can be used instead to avoid linking in 10 | unneeded compression or decompression routines. */ 11 | int ZEXPORT gzclose(file) 12 | gzFile file; 13 | { 14 | #ifndef NO_GZCOMPRESS 15 | gz_statep state; 16 | 17 | if (file == NULL) 18 | return Z_STREAM_ERROR; 19 | state = (gz_statep)file; 20 | 21 | return state->mode == GZ_READ ? gzclose_r(file) : gzclose_w(file); 22 | #else 23 | return gzclose_r(file); 24 | #endif 25 | } 26 | -------------------------------------------------------------------------------- /dlib/reference_counter.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_REFERENCE_COUNTEr_ 4 | #define DLIB_REFERENCE_COUNTEr_ 5 | 6 | #include "reference_counter/reference_counter_kernel_1.h" 7 | #include "algs.h" 8 | 9 | namespace dlib 10 | { 11 | 12 | template < 13 | typename T, 14 | typename copy = copy_functor 15 | > 16 | class reference_counter 17 | { 18 | reference_counter() {} 19 | public: 20 | 21 | //----------- kernels --------------- 22 | 23 | // kernel_1a 24 | typedef reference_counter_kernel_1 25 | kernel_1a; 26 | 27 | }; 28 | } 29 | 30 | #endif // DLIB_REFERENCE_COUNTEr_ 31 | 32 | -------------------------------------------------------------------------------- /dlib/stack.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_STACk_ 4 | #define DLIB_STACk_ 5 | 6 | #include "stack/stack_kernel_1.h" 7 | #include "stack/stack_kernel_c.h" 8 | #include "algs.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | template < 14 | typename T, 15 | typename mem_manager = default_memory_manager 16 | > 17 | class stack 18 | { 19 | stack() {} 20 | public: 21 | 22 | //----------- kernels --------------- 23 | 24 | // kernel_1a 25 | typedef stack_kernel_1 26 | kernel_1a; 27 | typedef stack_kernel_c 28 | kernel_1a_c; 29 | 30 | }; 31 | } 32 | 33 | #endif // DLIB_STACk_ 34 | 35 | -------------------------------------------------------------------------------- /dlib/threads.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_THREADs_ 4 | #define DLIB_THREADs_ 5 | 6 | #include "threads/threads_kernel.h" 7 | 8 | #include "threads/auto_mutex_extension.h" 9 | #include "threads/auto_unlock_extension.h" 10 | #include "threads/create_new_thread_extension.h" 11 | #include "threads/multithreaded_object_extension.h" 12 | #include "threads/rmutex_extension.h" 13 | #include "threads/rsignaler_extension.h" 14 | #include "threads/threaded_object_extension.h" 15 | #include "threads/thread_specific_data_extension.h" 16 | #include "threads/thread_function_extension.h" 17 | #include "threads/thread_pool_extension.h" 18 | #include "threads/read_write_mutex_extension.h" 19 | #include "threads/parallel_for_extension.h" 20 | 21 | #endif // DLIB_THREADs_ 22 | 23 | -------------------------------------------------------------------------------- /dlib/image_processing/frontal_face_detector_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_FRONTAL_FACE_DETECTOr_ABSTRACT_Hh_ 4 | #ifdef DLIB_FRONTAL_FACE_DETECTOr_ABSTRACT_Hh_ 5 | 6 | #include "object_detector_abstract.h" 7 | #include "scan_fhog_pyramid_abstract.h" 8 | #include "../image_transforms/image_pyramid_abstract.h" 9 | 10 | namespace dlib 11 | { 12 | typedef object_detector > > frontal_face_detector; 13 | 14 | frontal_face_detector get_frontal_face_detector( 15 | ); 16 | /*! 17 | ensures 18 | - returns an object_detector that is configured to find human faces that are 19 | looking more or less towards the camera. 20 | !*/ 21 | 22 | } 23 | 24 | #endif // DLIB_FRONTAL_FACE_DETECTOr_ABSTRACT_Hh_ 25 | 26 | -------------------------------------------------------------------------------- /dlib/graph.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_GRAPh_ 4 | #define DLIB_GRAPh_ 5 | 6 | #include "graph/graph_kernel_1.h" 7 | 8 | #include "algs.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | template < 14 | typename T, 15 | typename E = char, 16 | typename mem_manager = default_memory_manager 17 | > 18 | class graph 19 | { 20 | graph() {} 21 | public: 22 | 23 | 24 | //----------- kernels --------------- 25 | 26 | // kernel_1a 27 | typedef graph_kernel_1 28 | kernel_1a; 29 | typedef graph_kernel_1 30 | kernel_1a_c; 31 | 32 | }; 33 | } 34 | 35 | #endif // DLIB_GRAPh_ 36 | 37 | 38 | -------------------------------------------------------------------------------- /dlib/memory_manager_global.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MEMORY_MANAGER_GLOBAl_ 4 | #define DLIB_MEMORY_MANAGER_GLOBAl_ 5 | 6 | #include "memory_manager_global/memory_manager_global_kernel_1.h" 7 | #include "memory_manager.h" 8 | 9 | 10 | 11 | namespace dlib 12 | { 13 | 14 | template < 15 | typename T, 16 | typename factory 17 | > 18 | class memory_manager_global 19 | { 20 | memory_manager_global() {} 21 | 22 | 23 | public: 24 | 25 | //----------- kernels --------------- 26 | 27 | // kernel_1 28 | typedef memory_manager_global_kernel_1 29 | kernel_1a; 30 | 31 | 32 | 33 | 34 | }; 35 | } 36 | 37 | #endif // DLIB_MEMORY_MANAGER_GLOBAl_ 38 | 39 | -------------------------------------------------------------------------------- /dlib/matrix/matrix_fwd.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MATRIx_FWD 4 | #define DLIB_MATRIx_FWD 5 | 6 | #include "../algs.h" 7 | 8 | namespace dlib 9 | { 10 | 11 | // ---------------------------------------------------------------------------------------- 12 | 13 | struct row_major_layout; 14 | 15 | // ---------------------------------------------------------------------------------------- 16 | 17 | template < 18 | typename T, 19 | long num_rows = 0, 20 | long num_cols = 0, 21 | typename mem_manager = default_memory_manager, 22 | typename layout = row_major_layout 23 | > 24 | class matrix; 25 | 26 | // ---------------------------------------------------------------------------------------- 27 | 28 | } 29 | 30 | #endif // DLIB_MATRIx_FWD 31 | 32 | -------------------------------------------------------------------------------- /dlib/sliding_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SLIDING_BUFFEr_ 4 | #define DLIB_SLIDING_BUFFEr_ 5 | 6 | 7 | #include "sliding_buffer/sliding_buffer_kernel_1.h" 8 | #include "sliding_buffer/sliding_buffer_kernel_c.h" 9 | #include "sliding_buffer/circular_buffer.h" 10 | 11 | 12 | 13 | namespace dlib 14 | { 15 | 16 | template < 17 | typename T 18 | > 19 | class sliding_buffer 20 | { 21 | 22 | sliding_buffer() {} 23 | public: 24 | 25 | //----------- kernels --------------- 26 | 27 | // kernel_1a 28 | typedef sliding_buffer_kernel_1 29 | kernel_1a; 30 | typedef sliding_buffer_kernel_c 31 | kernel_1a_c; 32 | 33 | 34 | }; 35 | } 36 | 37 | #endif // DLIB_SLIDING_BUFFEr_ 38 | 39 | -------------------------------------------------------------------------------- /dlib/image_processing.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_IMAGE_PROCESSInG_H_h_ 4 | #define DLIB_IMAGE_PROCESSInG_H_h_ 5 | 6 | #include "image_processing/scan_image.h" 7 | #include "image_processing/scan_image_pyramid.h" 8 | #include "image_processing/detection_template_tools.h" 9 | #include "image_processing/object_detector.h" 10 | #include "image_processing/box_overlap_testing.h" 11 | #include "image_processing/scan_image_pyramid_tools.h" 12 | #include "image_processing/setup_hashed_features.h" 13 | #include "image_processing/scan_image_boxes.h" 14 | #include "image_processing/scan_image_custom.h" 15 | #include "image_processing/remove_unobtainable_rectangles.h" 16 | #include "image_processing/scan_fhog_pyramid.h" 17 | #include "image_processing/shape_predictor.h" 18 | #include "image_processing/correlation_tracker.h" 19 | 20 | #endif // DLIB_IMAGE_PROCESSInG_H_h_ 21 | 22 | 23 | -------------------------------------------------------------------------------- /dlib/directed_graph.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_DIRECTED_GRAPh_ 4 | #define DLIB_DIRECTED_GRAPh_ 5 | 6 | #include "directed_graph/directed_graph_kernel_1.h" 7 | 8 | #include "algs.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | template < 14 | typename T, 15 | typename E = char, 16 | typename mem_manager = default_memory_manager 17 | > 18 | class directed_graph 19 | { 20 | directed_graph() {} 21 | public: 22 | 23 | 24 | //----------- kernels --------------- 25 | 26 | // kernel_1a 27 | typedef directed_graph_kernel_1 28 | kernel_1a; 29 | typedef directed_graph_kernel_1 30 | kernel_1a_c; 31 | 32 | }; 33 | } 34 | 35 | #endif // DLIB_DIRECTED_GRAPh_ 36 | 37 | 38 | -------------------------------------------------------------------------------- /dlib/optimization.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_OPTIMIZATIOn_HEADER 4 | #define DLIB_OPTIMIZATIOn_HEADER 5 | 6 | #include "optimization/optimization.h" 7 | #include "optimization/optimization_bobyqa.h" 8 | #include "optimization/optimization_solve_qp_using_smo.h" 9 | #include "optimization/optimization_solve_qp2_using_smo.h" 10 | #include "optimization/optimization_solve_qp3_using_smo.h" 11 | #include "optimization/optimization_oca.h" 12 | #include "optimization/optimization_trust_region.h" 13 | #include "optimization/optimization_least_squares.h" 14 | #include "optimization/max_cost_assignment.h" 15 | #include "optimization/max_sum_submatrix.h" 16 | #include "optimization/find_max_factor_graph_nmplp.h" 17 | #include "optimization/find_max_factor_graph_viterbi.h" 18 | #include "optimization/find_max_parse_cky.h" 19 | 20 | #endif // DLIB_OPTIMIZATIOn_HEADER 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /dlib/static_map.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_STATIC_MAp_ 4 | #define DLIB_STATIC_MAp_ 5 | 6 | #include "static_map/static_map_kernel_1.h" 7 | #include "static_map/static_map_kernel_c.h" 8 | 9 | #include 10 | 11 | 12 | namespace dlib 13 | { 14 | 15 | template < 16 | typename domain, 17 | typename range, 18 | typename compare = std::less 19 | > 20 | class static_map 21 | { 22 | static_map() {} 23 | 24 | 25 | public: 26 | 27 | //----------- kernels --------------- 28 | 29 | // kernel_1a 30 | typedef static_map_kernel_1 31 | kernel_1a; 32 | typedef static_map_kernel_c 33 | kernel_1a_c; 34 | 35 | 36 | 37 | 38 | 39 | }; 40 | } 41 | 42 | #endif // DLIB_STATIC_MAp_ 43 | 44 | -------------------------------------------------------------------------------- /dlib/bigint.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BIGINt_ 4 | #define DLIB_BIGINt_ 5 | 6 | #include "bigint/bigint_kernel_1.h" 7 | #include "bigint/bigint_kernel_2.h" 8 | #include "bigint/bigint_kernel_c.h" 9 | 10 | 11 | 12 | 13 | namespace dlib 14 | { 15 | 16 | 17 | class bigint 18 | { 19 | bigint() {} 20 | 21 | 22 | public: 23 | 24 | //----------- kernels --------------- 25 | 26 | // kernel_1a 27 | typedef bigint_kernel_1 28 | kernel_1a; 29 | typedef bigint_kernel_c 30 | kernel_1a_c; 31 | 32 | // kernel_2a 33 | typedef bigint_kernel_2 34 | kernel_2a; 35 | typedef bigint_kernel_c 36 | kernel_2a_c; 37 | 38 | 39 | }; 40 | } 41 | 42 | #endif // DLIB_BIGINt_ 43 | 44 | -------------------------------------------------------------------------------- /dlib/image_keypoint/draw_surf_points_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_DRAW_SURf_POINTS_ABSTRACT_H_ 4 | #ifdef DLIB_DRAW_SURf_POINTS_ABSTRACT_H_ 5 | 6 | #include "surf_abstract.h" 7 | #include "../gui_widgets.h" 8 | 9 | namespace dlib 10 | { 11 | 12 | // ---------------------------------------------------------------------------------------- 13 | 14 | void draw_surf_points ( 15 | image_window& win, 16 | const std::vector& sp 17 | ); 18 | /*! 19 | ensures 20 | - draws all the SURF points in sp onto the given image_window. They 21 | are drawn as overlay circles with extra lines to indicate the rotation 22 | of the SURF descriptor. 23 | !*/ 24 | 25 | // ---------------------------------------------------------------------------------------- 26 | 27 | } 28 | 29 | #endif // DLIB_DRAW_SURf_POINTS_ABSTRACT_H_ 30 | 31 | -------------------------------------------------------------------------------- /dlib/threads/create_new_thread_extension_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_CREATE_NEW_THREAD_EXTENSIOn_ABSTRACT_ 4 | #ifdef DLIB_CREATE_NEW_THREAD_EXTENSIOn_ABSTRACT_ 5 | 6 | #include "threads_kernel_abstract.h" 7 | 8 | namespace dlib 9 | { 10 | 11 | // ---------------------------------------------------------------------------------------- 12 | 13 | template < 14 | typename T, 15 | void (T::*funct)() 16 | > 17 | bool create_new_thread ( 18 | T& obj 19 | ); 20 | /*! 21 | ensures 22 | - creates a new thread and calls obj.*funct() from it. 23 | - returns true upon success and false upon failure to create the new thread. 24 | !*/ 25 | 26 | // ---------------------------------------------------------------------------------------- 27 | 28 | } 29 | 30 | #endif // DLIB_CREATE_NEW_THREAD_EXTENSIOn_ABSTRACT_ 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /dlib/image_transforms.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_IMAGE_TRANSFORMs_ 4 | #define DLIB_IMAGE_TRANSFORMs_ 5 | 6 | #include "image_transforms/assign_image.h" 7 | #include "image_transforms/equalize_histogram.h" 8 | #include "image_transforms/morphological_operations.h" 9 | #include "image_transforms/spatial_filtering.h" 10 | #include "image_transforms/thresholding.h" 11 | #include "image_transforms/edge_detector.h" 12 | #include "image_transforms/draw.h" 13 | #include "image_transforms/integral_image.h" 14 | #include "image_transforms/image_pyramid.h" 15 | #include "image_transforms/hough_transform.h" 16 | #include "image_transforms/label_connected_blobs.h" 17 | #include "image_transforms/colormaps.h" 18 | #include "image_transforms/segment_image.h" 19 | #include "image_transforms/interpolation.h" 20 | #include "image_transforms/fhog.h" 21 | #include "image_transforms/lbp.h" 22 | 23 | #endif // DLIB_IMAGE_TRANSFORMs_ 24 | 25 | -------------------------------------------------------------------------------- /dlib/noncopyable.h: -------------------------------------------------------------------------------- 1 | // (C) Copyright Beman Dawes 1999-2003. Distributed under the Boost 2 | // Software License, Version 1.0. (See accompanying file 3 | // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) 4 | // Contributed by Dave Abrahams 5 | // See http://www.boost.org/libs/utility for documentation. 6 | 7 | #ifndef DLIB_BOOST_NONCOPYABLE_HPP_INCLUDED 8 | #define DLIB_BOOST_NONCOPYABLE_HPP_INCLUDED 9 | 10 | 11 | namespace dlib 12 | { 13 | class noncopyable 14 | { 15 | /*! 16 | This class makes it easier to declare a class as non-copyable. 17 | If you want to make an object that can't be copied just inherit 18 | from this object. 19 | !*/ 20 | 21 | protected: 22 | noncopyable() {} 23 | ~noncopyable() {} 24 | private: // emphasize the following members are private 25 | noncopyable(const noncopyable&); 26 | const noncopyable& operator=(const noncopyable&); 27 | 28 | }; 29 | } 30 | 31 | #endif // DLIB_BOOST_NONCOPYABLE_HPP_INCLUDED 32 | 33 | -------------------------------------------------------------------------------- /dlib/add_global_compiler_switch.cmake: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Make macros that can add compiler switches to the entire project. Not just 4 | # to the current cmake folder being built. 5 | macro ( add_global_compiler_switch switch_name ) 6 | if (NOT CMAKE_CXX_FLAGS MATCHES "${switch_name}") 7 | set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${switch_name}" 8 | CACHE STRING "Flags used by the compiler during all C++ builds." 9 | FORCE) 10 | endif () 11 | endmacro() 12 | 13 | macro ( remove_global_compiler_switch switch_name ) 14 | if (CMAKE_CXX_FLAGS MATCHES " ${switch_name}") 15 | string (REGEX REPLACE " ${switch_name}" "" temp_var ${CMAKE_CXX_FLAGS}) 16 | set (CMAKE_CXX_FLAGS "${temp_var}" 17 | CACHE STRING "Flags used by the compiler during all C++ builds." 18 | FORCE) 19 | endif () 20 | endmacro() 21 | 22 | macro (add_global_define def_name) 23 | add_global_compiler_switch(-D${def_name}) 24 | endmacro() 25 | 26 | macro (remove_global_define def_name) 27 | remove_global_compiler_switch(-D${def_name}) 28 | endmacro() 29 | -------------------------------------------------------------------------------- /dlib/config.h: -------------------------------------------------------------------------------- 1 | 2 | 3 | // If you are compiling dlib as a shared library and installing it somewhere on your system 4 | // then it is important that any programs that use dlib agree on the state of the 5 | // DLIB_ASSERT statements (i.e. they are either always on or always off). Therefore, 6 | // uncomment one of the following lines to force all DLIB_ASSERTs to either always on or 7 | // always off. If you don't define one of these two macros then DLIB_ASSERT will toggle 8 | // automatically depending on the state of certain other macros, which is not what you want 9 | // when creating a shared library. 10 | //#define ENABLE_ASSERTS // asserts always enabled 11 | //#define DLIB_DISABLE_ASSERTS // asserts always disabled 12 | 13 | 14 | 15 | // You should also consider telling dlib to link against libjpeg, libpng, fftw, and a BLAS 16 | // and LAPACK library. To do this you need to uncomment the following #defines. 17 | // #define DLIB_JPEG_SUPPORT 18 | // #define DLIB_PNG_SUPPORT 19 | // #define DLIB_USE_FFTW 20 | // #define DLIB_USE_BLAS 21 | // #define DLIB_USE_LAPACK 22 | -------------------------------------------------------------------------------- /dlib/test/blas_bindings/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This is a CMake makefile. You can find the cmake utility and 3 | # information about it at http://www.cmake.org 4 | # 5 | 6 | cmake_minimum_required(VERSION 2.8.4) 7 | 8 | # This variable contains a list of all the tests we are building 9 | # into the regression test suite. 10 | set (tests 11 | blas_bindings_gemm.cpp 12 | blas_bindings_gemv.cpp 13 | blas_bindings_ger.cpp 14 | blas_bindings_dot.cpp 15 | blas_bindings_scal_axpy.cpp 16 | vector.cpp 17 | ) 18 | 19 | # create a variable called target_name and set it to the string "test" 20 | set (target_name dtest) 21 | 22 | PROJECT(${target_name}) 23 | 24 | # add all the cpp files we want to compile to this list. This tells 25 | # cmake that they are part of our target (which is the executable named test) 26 | ADD_EXECUTABLE(${target_name} ../main.cpp ../tester.cpp ${tests}) 27 | 28 | ADD_DEFINITIONS(-DDLIB_TEST_BLAS_BINDINGS) 29 | 30 | # Tell cmake to link our target executable to dlib 31 | include(../../cmake) 32 | TARGET_LINK_LIBRARIES(${target_name} dlib ) 33 | 34 | -------------------------------------------------------------------------------- /dlib/cpp_pretty_printer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_CPP_PRETTY_PRINTEr_ 4 | #define DLIB_CPP_PRETTY_PRINTEr_ 5 | 6 | 7 | #include "cpp_pretty_printer/cpp_pretty_printer_kernel_1.h" 8 | #include "cpp_pretty_printer/cpp_pretty_printer_kernel_2.h" 9 | #include "cpp_tokenizer.h" 10 | #include "stack.h" 11 | 12 | namespace dlib 13 | { 14 | 15 | class cpp_pretty_printer 16 | { 17 | cpp_pretty_printer() {} 18 | 19 | 20 | typedef stack::kernel_1a stack; 21 | typedef cpp_tokenizer::kernel_1a tok; 22 | 23 | public: 24 | 25 | //----------- kernels --------------- 26 | 27 | // kernel_1a 28 | typedef cpp_pretty_printer_kernel_1 29 | kernel_1a; 30 | 31 | // kernel_2a 32 | typedef cpp_pretty_printer_kernel_2 33 | kernel_2a; 34 | 35 | }; 36 | } 37 | 38 | #endif // DLIB_CPP_PRETTY_PRINTEr_ 39 | 40 | -------------------------------------------------------------------------------- /dlib/array/array_tools.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ARRAY_tOOLS_H_ 4 | #define DLIB_ARRAY_tOOLS_H_ 5 | 6 | #include "../assert.h" 7 | #include "array_tools_abstract.h" 8 | 9 | namespace dlib 10 | { 11 | template 12 | void split_array ( 13 | T& a, 14 | T& b, 15 | double frac 16 | ) 17 | { 18 | // make sure requires clause is not broken 19 | DLIB_ASSERT(0 <= frac && frac <= 1, 20 | "\t void split_array()" 21 | << "\n\t frac must be between 0 and 1." 22 | << "\n\t frac: " << frac 23 | ); 24 | 25 | const unsigned long asize = static_cast(a.size()*frac); 26 | const unsigned long bsize = a.size()-asize; 27 | 28 | b.resize(bsize); 29 | for (unsigned long i = 0; i < b.size(); ++i) 30 | { 31 | swap(b[i], a[i+asize]); 32 | } 33 | a.resize(asize); 34 | } 35 | } 36 | 37 | #endif // DLIB_ARRAY_tOOLS_H_ 38 | 39 | -------------------------------------------------------------------------------- /dlib/test/cmd_line_parser.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "tester.h" 11 | 12 | #include "cmd_line_parser.h" 13 | namespace 14 | { 15 | 16 | class cmd_line_parser_tester : public tester 17 | { 18 | public: 19 | cmd_line_parser_tester ( 20 | ) : 21 | tester ("test_cmd_line_parser_char", 22 | "Runs tests on the cmd_line_parser component.") 23 | {} 24 | 25 | void perform_test ( 26 | ) 27 | { 28 | dlog << LINFO << "testing kernel_1a with char"; 29 | cmd_line_parser_kernel_test::kernel_1a>(); 30 | print_spinner(); 31 | 32 | dlog << LINFO << "testing kernel_1a_c with char"; 33 | cmd_line_parser_kernel_test::kernel_1a_c>(); 34 | print_spinner(); 35 | } 36 | } a; 37 | 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /dlib/cpp_tokenizer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_CPP_TOKENIZEr_ 4 | #define DLIB_CPP_TOKENIZEr_ 5 | 6 | #include 7 | #include "cpp_tokenizer/cpp_tokenizer_kernel_1.h" 8 | #include "cpp_tokenizer/cpp_tokenizer_kernel_c.h" 9 | #include "tokenizer.h" 10 | #include "queue.h" 11 | #include "set.h" 12 | 13 | namespace dlib 14 | { 15 | 16 | class cpp_tokenizer 17 | { 18 | cpp_tokenizer() {} 19 | 20 | 21 | typedef set::kernel_1a set; 22 | typedef queue::kernel_2a queue; 23 | typedef tokenizer::kernel_1a tok; 24 | 25 | public: 26 | 27 | //----------- kernels --------------- 28 | 29 | // kernel_1a 30 | typedef cpp_tokenizer_kernel_1 31 | kernel_1a; 32 | typedef cpp_tokenizer_kernel_c 33 | kernel_1a_c; 34 | 35 | 36 | }; 37 | } 38 | 39 | #endif // DLIB_CPP_TOKENIZEr_ 40 | 41 | -------------------------------------------------------------------------------- /dlib/dlib_include_path_tutorial.txt: -------------------------------------------------------------------------------- 1 | #error "Don't put the dlib folder in your include path" 2 | /* 3 | You are getting this error because you have added the dlib folder to your 4 | compiler's include search path. 5 | 6 | You should *NOT* add the dlib folder itself to your compiler's include path. 7 | Doing so will cause the build to fail because of name collisions (such as 8 | dlib/string.h and string.h from the standard library). Instead you should 9 | add the folder that contains the dlib folder to your include search path 10 | and then use include statements of the form #include or 11 | #include "dlib/queue.h". This will ensure that everything builds correctly. 12 | 13 | XCode: 14 | The XCode IDE often puts all folders that it knows about into 15 | the compiler search path. So if you are using XCode then either 16 | don't drag the whole dlib folder into the project or alternatively 17 | modify your XCode project settings to not auto-add all folders to 18 | the include path. Instead just make sure that the dlib folder is 19 | itself inside a folder in your include path. 20 | */ 21 | -------------------------------------------------------------------------------- /dlib/entropy_encoder.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ENTROPY_ENCODEr_ 4 | #define DLIB_ENTROPY_ENCODEr_ 5 | 6 | #include "entropy_encoder/entropy_encoder_kernel_1.h" 7 | #include "entropy_encoder/entropy_encoder_kernel_2.h" 8 | #include "entropy_encoder/entropy_encoder_kernel_c.h" 9 | 10 | 11 | 12 | 13 | namespace dlib 14 | { 15 | 16 | 17 | class entropy_encoder 18 | { 19 | entropy_encoder() {} 20 | 21 | 22 | public: 23 | 24 | //----------- kernels --------------- 25 | 26 | // kernel_1a 27 | typedef entropy_encoder_kernel_1 28 | kernel_1a; 29 | typedef entropy_encoder_kernel_c 30 | kernel_1a_c; 31 | 32 | 33 | // kernel_2a 34 | typedef entropy_encoder_kernel_2 35 | kernel_2a; 36 | typedef entropy_encoder_kernel_c 37 | kernel_2a_c; 38 | 39 | }; 40 | } 41 | 42 | #endif // DLIB_ENTROPY_ENCODEr_ 43 | 44 | -------------------------------------------------------------------------------- /dlib/test/cmd_line_parser_wchar_t.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | 4 | 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "tester.h" 11 | 12 | #include "cmd_line_parser.h" 13 | namespace 14 | { 15 | 16 | class cmd_line_parser_tester : public tester 17 | { 18 | public: 19 | cmd_line_parser_tester ( 20 | ) : 21 | tester ("test_cmd_line_parser_wchar_t", 22 | "Runs tests on the cmd_line_parser component.") 23 | {} 24 | 25 | void perform_test ( 26 | ) 27 | { 28 | dlog << LINFO << "testing kernel_1a with wchar_t"; 29 | cmd_line_parser_kernel_test::kernel_1a>(); 30 | print_spinner(); 31 | 32 | dlog << LINFO << "testing kernel_1a_c with wchar_t"; 33 | cmd_line_parser_kernel_test::kernel_1a_c>(); 34 | print_spinner(); 35 | } 36 | } a; 37 | 38 | } 39 | 40 | 41 | -------------------------------------------------------------------------------- /dlib/config_reader.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_CONFIG_READEr_ 4 | #define DLIB_CONFIG_READEr_ 5 | 6 | #include "config_reader/config_reader_kernel_1.h" 7 | #include "map.h" 8 | #include "tokenizer.h" 9 | #include "cmd_line_parser/get_option.h" 10 | 11 | #include "algs.h" 12 | #include "is_kind.h" 13 | 14 | 15 | namespace dlib 16 | { 17 | 18 | typedef config_reader_kernel_1< 19 | map::kernel_1b, 20 | map::kernel_1b, 21 | tokenizer::kernel_1a 22 | > config_reader; 23 | 24 | template <> struct is_config_reader { const static bool value = true; }; 25 | 26 | #ifndef DLIB_ISO_CPP_ONLY 27 | typedef config_reader_thread_safe_1< 28 | config_reader, 29 | map::kernel_1b 30 | > config_reader_thread_safe; 31 | 32 | template <> struct is_config_reader { const static bool value = true; }; 33 | #endif // DLIB_ISO_CPP_ONLY 34 | 35 | 36 | } 37 | 38 | #endif // DLIB_CONFIG_READEr_ 39 | 40 | -------------------------------------------------------------------------------- /dlib/entropy_decoder.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ENTROPY_DECODEr_ 4 | #define DLIB_ENTROPY_DECODEr_ 5 | 6 | #include "entropy_decoder/entropy_decoder_kernel_1.h" 7 | #include "entropy_decoder/entropy_decoder_kernel_2.h" 8 | #include "entropy_decoder/entropy_decoder_kernel_c.h" 9 | 10 | 11 | 12 | 13 | namespace dlib 14 | { 15 | 16 | 17 | class entropy_decoder 18 | { 19 | entropy_decoder() {} 20 | 21 | 22 | public: 23 | 24 | //----------- kernels --------------- 25 | 26 | // kernel_1a 27 | typedef entropy_decoder_kernel_1 28 | kernel_1a; 29 | typedef entropy_decoder_kernel_c 30 | kernel_1a_c; 31 | 32 | 33 | // kernel_2a 34 | typedef entropy_decoder_kernel_2 35 | kernel_2a; 36 | typedef entropy_decoder_kernel_c 37 | kernel_2a_c; 38 | 39 | 40 | }; 41 | } 42 | 43 | #endif // DLIB_ENTROPY_DECODEr_ 44 | 45 | -------------------------------------------------------------------------------- /dlib/lzp_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_LZP_BUFFEr_ 4 | #define DLIB_LZP_BUFFEr_ 5 | 6 | 7 | #include "lzp_buffer/lzp_buffer_kernel_1.h" 8 | #include "lzp_buffer/lzp_buffer_kernel_2.h" 9 | #include "lzp_buffer/lzp_buffer_kernel_c.h" 10 | 11 | #include "sliding_buffer.h" 12 | 13 | 14 | namespace dlib 15 | { 16 | 17 | 18 | class lzp_buffer 19 | { 20 | 21 | lzp_buffer() {} 22 | 23 | typedef sliding_buffer::kernel_1a sb1; 24 | 25 | public: 26 | 27 | //----------- kernels --------------- 28 | 29 | // kernel_1a 30 | typedef lzp_buffer_kernel_1 31 | kernel_1a; 32 | typedef lzp_buffer_kernel_c 33 | kernel_1a_c; 34 | 35 | // kernel_2a 36 | typedef lzp_buffer_kernel_2 37 | kernel_2a; 38 | typedef lzp_buffer_kernel_c 39 | kernel_2a_c; 40 | 41 | 42 | }; 43 | } 44 | 45 | #endif // DLIB_LZP_BUFFEr_ 46 | 47 | -------------------------------------------------------------------------------- /dlib/bit_stream.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BIT_STREAm_ 4 | #define DLIB_BIT_STREAm_ 5 | 6 | #include "bit_stream/bit_stream_kernel_1.h" 7 | #include "bit_stream/bit_stream_kernel_c.h" 8 | 9 | #include "bit_stream/bit_stream_multi_1.h" 10 | #include "bit_stream/bit_stream_multi_c.h" 11 | 12 | namespace dlib 13 | { 14 | 15 | 16 | class bit_stream 17 | { 18 | bit_stream() {} 19 | public: 20 | 21 | //----------- kernels --------------- 22 | 23 | // kernel_1a 24 | typedef bit_stream_kernel_1 25 | kernel_1a; 26 | typedef bit_stream_kernel_c 27 | kernel_1a_c; 28 | 29 | //---------- extensions ------------ 30 | 31 | 32 | // multi_1 extend kernel_1a 33 | typedef bit_stream_multi_1 34 | multi_1a; 35 | typedef bit_stream_multi_c > 36 | multi_1a_c; 37 | 38 | }; 39 | } 40 | 41 | #endif // DLIB_BIT_STREAm_ 42 | 43 | -------------------------------------------------------------------------------- /dlib/svm/null_df.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_NULL_DECISION_FUnCTION_Hh_ 4 | #define DLIB_NULL_DECISION_FUnCTION_Hh_ 5 | 6 | #include 7 | 8 | namespace dlib 9 | { 10 | 11 | // ---------------------------------------------------------------------------------------- 12 | 13 | struct null_df 14 | { 15 | /*! 16 | WHAT THIS OBJECT REPRESENTS 17 | This is a type used to represent an unused field in the list of template 18 | arguments of the one_vs_one_decision_function and one_vs_all_decision_function 19 | templates. As such, null_df doesn't actually do anything. 20 | !*/ 21 | template 22 | double operator() ( const T&) const { return 0; } 23 | }; 24 | 25 | inline void serialize(const null_df&, std::ostream&) {} 26 | inline void deserialize(null_df&, std::istream&) {} 27 | 28 | // ---------------------------------------------------------------------------------------- 29 | 30 | } 31 | 32 | #endif // DLIB_NULL_DECISION_FUnCTION_Hh_ 33 | 34 | -------------------------------------------------------------------------------- /dlib/config.h.in: -------------------------------------------------------------------------------- 1 | 2 | 3 | // If you are compiling dlib as a shared library and installing it somewhere on your system 4 | // then it is important that any programs that use dlib agree on the state of the 5 | // DLIB_ASSERT statements (i.e. they are either always on or always off). Therefore, 6 | // uncomment one of the following lines to force all DLIB_ASSERTs to either always on or 7 | // always off. If you don't define one of these two macros then DLIB_ASSERT will toggle 8 | // automatically depending on the state of certain other macros, which is not what you want 9 | // when creating a shared library. 10 | #cmakedefine ENABLE_ASSERTS // asserts always enabled 11 | #cmakedefine DLIB_DISABLE_ASSERTS // asserts always disabled 12 | 13 | #cmakedefine DLIB_ISO_CPP_ONLY 14 | #cmakedefine DLIB_NO_GUI_SUPPORT 15 | #cmakedefine DLIB_ENABLE_STACK_TRACE 16 | 17 | // You should also consider telling dlib to link against libjpeg, libpng, fftw, and a BLAS 18 | // and LAPACK library. To do this you need to uncomment the following #defines. 19 | #cmakedefine DLIB_JPEG_SUPPORT 20 | #cmakedefine DLIB_PNG_SUPPORT 21 | #cmakedefine DLIB_USE_FFTW 22 | #cmakedefine DLIB_USE_BLAS 23 | #cmakedefine DLIB_USE_LAPACK 24 | -------------------------------------------------------------------------------- /dlib/logger/extra_logger_headers.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_EXTRA_LOGGER_HEADERs_CPP_ 4 | #define DLIB_EXTRA_LOGGER_HEADERs_CPP_ 5 | 6 | #include "extra_logger_headers.h" 7 | #include 8 | #include 9 | 10 | // ---------------------------------------------------------------------------------------- 11 | 12 | namespace dlib 13 | { 14 | 15 | void print_datetime_logger_header ( 16 | std::ostream& out, 17 | const std::string& logger_name, 18 | const log_level& l, 19 | const uint64 thread_id 20 | ) 21 | { 22 | using namespace std; 23 | char* buf; 24 | 25 | time_t t = time(0); 26 | buf = ctime(&t); 27 | // remove the trailing '\n' 28 | size_t size = strlen(buf); 29 | buf[size-1] = '\0'; 30 | 31 | out << l.name << " (" << buf << ") [" << thread_id << "] " << logger_name << ": "; 32 | } 33 | 34 | } 35 | 36 | // ---------------------------------------------------------------------------------------- 37 | 38 | #endif // DLIB_EXTRA_LOGGER_HEADERs_CPP_ 39 | 40 | 41 | -------------------------------------------------------------------------------- /dlib/lz77_buffer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_LZ77_BUFFEr_ 4 | #define DLIB_LZ77_BUFFEr_ 5 | 6 | 7 | #include "lz77_buffer/lz77_buffer_kernel_1.h" 8 | #include "lz77_buffer/lz77_buffer_kernel_2.h" 9 | #include "lz77_buffer/lz77_buffer_kernel_c.h" 10 | 11 | #include "sliding_buffer.h" 12 | 13 | 14 | namespace dlib 15 | { 16 | 17 | 18 | class lz77_buffer 19 | { 20 | 21 | lz77_buffer() {} 22 | 23 | typedef sliding_buffer::kernel_1a sb1; 24 | 25 | public: 26 | 27 | //----------- kernels --------------- 28 | 29 | // kernel_1a 30 | typedef lz77_buffer_kernel_1 31 | kernel_1a; 32 | typedef lz77_buffer_kernel_c 33 | kernel_1a_c; 34 | 35 | 36 | // kernel_2a 37 | typedef lz77_buffer_kernel_2 38 | kernel_2a; 39 | typedef lz77_buffer_kernel_c 40 | kernel_2a_c; 41 | 42 | 43 | }; 44 | } 45 | 46 | #endif // DLIB_LZ77_BUFFEr_ 47 | 48 | -------------------------------------------------------------------------------- /dlib/opencv/to_open_cv_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_TO_OPEN_Cv_ABSTRACTh_ 4 | #ifdef DLIB_TO_OPEN_Cv_ABSTRACTh_ 5 | 6 | #include 7 | #include "../pixel.h" 8 | 9 | namespace dlib 10 | { 11 | template < 12 | typename image_type 13 | > 14 | cv::Mat toMat ( 15 | image_type& img 16 | ); 17 | /*! 18 | requires 19 | - image_type == an image object that implements the interface defined in 20 | dlib/image_processing/generic_image.h or a dlib::matrix object which uses a 21 | row_major_layout. 22 | - pixel_traits is defined for the contents of img. 23 | ensures 24 | - returns an OpenCV Mat object which represents the same image as img. This 25 | is done by setting up the Mat object to point to the same memory as img. 26 | Therefore, the returned Mat object is valid only as long as pointers 27 | to the pixels in img remain valid. 28 | !*/ 29 | } 30 | 31 | #endif // DLIB_TO_OPEN_Cv_ABSTRACTh_ 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /dlib/static_set.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2005 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_STATIC_SEt_ 4 | #define DLIB_STATIC_SEt_ 5 | 6 | #include "static_set/static_set_kernel_1.h" 7 | #include "static_set/static_set_kernel_c.h" 8 | #include "static_set/static_set_compare_1.h" 9 | 10 | #include 11 | 12 | namespace dlib 13 | { 14 | 15 | template < 16 | typename T, 17 | typename compare = std::less 18 | > 19 | class static_set 20 | { 21 | static_set() {} 22 | 23 | 24 | public: 25 | 26 | //----------- kernels --------------- 27 | 28 | // kernel_1a 29 | typedef static_set_kernel_1 30 | kernel_1a; 31 | typedef static_set_kernel_c 32 | kernel_1a_c; 33 | 34 | 35 | //----------- extensions ------------- 36 | 37 | typedef static_set_compare_1 38 | compare_1a; 39 | typedef static_set_compare_1 40 | compare_1a_c; 41 | 42 | 43 | 44 | 45 | }; 46 | } 47 | 48 | #endif // DLIB_STATIC_SEt_ 49 | 50 | -------------------------------------------------------------------------------- /dlib/array/array_tools_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_ARRAY_tOOLS_ABSTRACT_H_ 4 | #ifdef DLIB_ARRAY_tOOLS_ABSTRACT_H_ 5 | 6 | #include "array_kernel_abstract.h" 7 | 8 | namespace dlib 9 | { 10 | template 11 | void split_array ( 12 | T& a, 13 | T& b, 14 | double frac 15 | ); 16 | /*! 17 | requires 18 | - 0 <= frac <= 1 19 | - T must be an array type such as dlib::array or std::vector 20 | ensures 21 | - This function takes the elements of a and splits them into two groups. The 22 | first group remains in a and the second group is put into b. The ordering of 23 | elements in a is preserved. In particular, concatenating #a with #b will 24 | reproduce the original contents of a. 25 | - The elements in a are moved around using global swap(). So they must be 26 | swappable, but do not need to be copyable. 27 | - #a.size() == floor(a.size()*frac) 28 | - #b.size() == a.size()-#a.size() 29 | !*/ 30 | } 31 | 32 | #endif // DLIB_ARRAY_tOOLS_ABSTRACT_H_ 33 | 34 | -------------------------------------------------------------------------------- /dlib/svm_threaded.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SVm_THREADED_HEADER 4 | #define DLIB_SVm_THREADED_HEADER 5 | 6 | #include "svm.h" 7 | #include "svm/svm_threaded.h" 8 | #include "svm/structural_svm_problem_threaded.h" 9 | #include "svm/structural_svm_distributed.h" 10 | #include "svm/structural_svm_object_detection_problem.h" 11 | #include "svm/structural_object_detection_trainer.h" 12 | #include "svm/structural_svm_sequence_labeling_problem.h" 13 | #include "svm/structural_sequence_labeling_trainer.h" 14 | 15 | #include "svm/structural_svm_assignment_problem.h" 16 | #include "svm/structural_assignment_trainer.h" 17 | #include "svm/cross_validate_track_association_trainer.h" 18 | #include "svm/structural_track_association_trainer.h" 19 | 20 | #include "svm/structural_svm_graph_labeling_problem.h" 21 | #include "svm/structural_graph_labeling_trainer.h" 22 | #include "svm/cross_validate_graph_labeling_trainer.h" 23 | #include "svm/svm_multiclass_linear_trainer.h" 24 | #include "svm/one_vs_one_trainer.h" 25 | #include "svm/one_vs_all_trainer.h" 26 | #include "svm/structural_sequence_segmentation_trainer.h" 27 | 28 | #endif // DLIB_SVm_THREADED_HEADER 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /dlib/threads/create_new_thread_extension.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_CREATE_NEW_THREAD_EXTENSIOn_ 4 | #define DLIB_CREATE_NEW_THREAD_EXTENSIOn_ 5 | 6 | #include "threads_kernel_abstract.h" 7 | #include "create_new_thread_extension_abstract.h" 8 | #include "../threads.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | // ---------------------------------------------------------------------------------------- 14 | 15 | template < 16 | typename T, 17 | void (T::*funct)() 18 | > 19 | inline void dlib_create_new_thread_helper ( 20 | void* obj 21 | ) 22 | { 23 | T* o = static_cast(obj); 24 | (o->*funct)(); 25 | } 26 | 27 | // ---------------------------------------------------------------------------------------- 28 | 29 | template < 30 | typename T, 31 | void (T::*funct)() 32 | > 33 | inline bool create_new_thread ( 34 | T& obj 35 | ) 36 | { 37 | return create_new_thread(dlib_create_new_thread_helper,&obj); 38 | } 39 | 40 | // ---------------------------------------------------------------------------------------- 41 | 42 | } 43 | 44 | #endif // DLIB_CREATE_NEW_THREAD_EXTENSIOn_ 45 | 46 | 47 | -------------------------------------------------------------------------------- /dlib/general_hash/count_bits_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_COUNT_BiTS_ABSTRACT_Hh_ 4 | #ifdef DLIB_COUNT_BiTS_ABSTRACT_Hh_ 5 | 6 | 7 | namespace dlib 8 | { 9 | 10 | // ---------------------------------------------------------------------------------------- 11 | 12 | template < 13 | typename T 14 | > 15 | T count_bits ( 16 | T v 17 | ); 18 | /*! 19 | requires 20 | - T is an unsigned integral type 21 | ensures 22 | - returns the number of bits in v which are set to 1. 23 | !*/ 24 | 25 | // ---------------------------------------------------------------------------------------- 26 | 27 | template < 28 | typename T 29 | > 30 | T hamming_distance ( 31 | const T& a, 32 | const T& b 33 | ); 34 | /*! 35 | requires 36 | - T is an unsigned integral type 37 | ensures 38 | - returns the number of bits which differ between a and b. (I.e. returns 39 | count_bits(a^b).) 40 | !*/ 41 | 42 | // ---------------------------------------------------------------------------------------- 43 | 44 | } 45 | 46 | #endif // DLIB_COUNT_BiTS_ABSTRACT_Hh_ 47 | 48 | 49 | -------------------------------------------------------------------------------- /dlib/logger/extra_logger_headers.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_EXTRA_LOGGER_HEADERs_ 4 | #define DLIB_EXTRA_LOGGER_HEADERs_ 5 | 6 | #include "logger_kernel_abstract.h" 7 | #include "logger_kernel_1.h" 8 | #include 9 | #include 10 | #include "../uintn.h" 11 | 12 | // ---------------------------------------------------------------------------------------- 13 | 14 | namespace dlib 15 | { 16 | 17 | void print_datetime_logger_header ( 18 | std::ostream& out, 19 | const std::string& logger_name, 20 | const log_level& l, 21 | const uint64 thread_id 22 | ); 23 | /*! 24 | requires 25 | - is not called more than once at a time (i.e. is not called from multiple 26 | threads at the same time). 27 | ensures 28 | - let DATE be the current date and time (e.g. Thu Aug 31 16:41:52 2006). 29 | - prints a string to out in the form: "l.name (DATE) [thread_id] logger_name:" 30 | !*/ 31 | 32 | } 33 | 34 | // ---------------------------------------------------------------------------------------- 35 | 36 | #ifdef NO_MAKEFILE 37 | #include "extra_logger_headers.cpp" 38 | #endif 39 | 40 | #endif // DLIB_EXTRA_LOGGER_HEADERs_ 41 | 42 | -------------------------------------------------------------------------------- /dlib/image_loader/load_image_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net), Nils Labugt 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_LOAd_IMAGE_ABSTRACT_ 4 | #ifdef DLIB_LOAd_IMAGE_ABSTRACT_ 5 | 6 | #include "load_image_abstract.h" 7 | #include "../string.h" 8 | #include "../image_processing/generic_image.h" 9 | 10 | namespace dlib 11 | { 12 | template 13 | void load_image ( 14 | image_type& image, 15 | const std::string& file_name 16 | ); 17 | /*! 18 | requires 19 | - image_type == an image object that implements the interface defined in 20 | dlib/image_processing/generic_image.h 21 | ensures 22 | - This function looks at the file extensions and file headers to try and figure 23 | out what kind of image format is inside the given file. It then calls one of 24 | load_png(), load_jpeg(), load_bmp(), or load_dng() as appropriate and stores 25 | the resulting image into #image. 26 | throws 27 | - image_load_error 28 | This exception is thrown if there is some error that prevents 29 | us from loading the given image file. 30 | !*/ 31 | 32 | } 33 | 34 | #endif // DLIB_LOAd_IMAGE_ABSTRACT_ 35 | 36 | 37 | -------------------------------------------------------------------------------- /dlib/test/binary_search_tree_kernel_2a.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BINARY_SEARCH_TREE_KERNEl_TEST_ 4 | #define DLIB_BINARY_SEARCH_TREE_KERNEl_TEST_ 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include "tester.h" 16 | #include "binary_search_tree.h" 17 | 18 | namespace 19 | { 20 | 21 | class binary_search_tree_tester : public tester 22 | { 23 | public: 24 | binary_search_tree_tester ( 25 | ) : 26 | tester ("test_binary_search_tree_kernel_2a", 27 | "Runs tests on the binary_search_tree_kernel_2a component.") 28 | {} 29 | 30 | void perform_test ( 31 | ) 32 | { 33 | dlog << LINFO << "testing kernel_2a"; 34 | binary_search_tree_kernel_test::kernel_2a>(); 35 | print_spinner(); 36 | 37 | dlog << LINFO << "testing kernel_2a_c"; 38 | binary_search_tree_kernel_test::kernel_2a_c>(); 39 | print_spinner(); 40 | } 41 | } a; 42 | 43 | } 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /dlib/test/binary_search_tree_kernel_1a.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BINARY_SEARCH_TREE_KERNEl_TEST_ 4 | #define DLIB_BINARY_SEARCH_TREE_KERNEl_TEST_ 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include "tester.h" 16 | #include "binary_search_tree.h" 17 | 18 | namespace 19 | { 20 | 21 | 22 | class binary_search_tree_tester : public tester 23 | { 24 | 25 | public: 26 | binary_search_tree_tester ( 27 | ) : 28 | tester ("test_binary_search_tree_kernel_1a", 29 | "Runs tests on the binary_search_tree_kernel_1a component.") 30 | {} 31 | 32 | void perform_test ( 33 | ) 34 | { 35 | dlog << LINFO << "testing kernel_1a"; 36 | binary_search_tree_kernel_test::kernel_1a>(); 37 | print_spinner(); 38 | 39 | dlog << LINFO << "testing kernel_1a_c"; 40 | binary_search_tree_kernel_test::kernel_1a_c>(); 41 | print_spinner(); 42 | } 43 | } a; 44 | 45 | } 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /dlib/md5/md5_kernel_1.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MD5_KERNEl_1_ 4 | #define DLIB_MD5_KERNEl_1_ 5 | 6 | #include "md5_kernel_abstract.h" 7 | #include 8 | #include 9 | #include "../algs.h" 10 | 11 | namespace dlib 12 | { 13 | 14 | // ---------------------------------------------------------------------------------------- 15 | 16 | const std::string md5 ( 17 | const std::string& input 18 | ); 19 | 20 | // ---------------------------------------------------------------------------------------- 21 | 22 | void md5 ( 23 | const unsigned char* input, 24 | unsigned long len, 25 | unsigned char* output 26 | ); 27 | 28 | // ---------------------------------------------------------------------------------------- 29 | 30 | const std::string md5 ( 31 | std::istream& input 32 | ); 33 | 34 | // ---------------------------------------------------------------------------------------- 35 | 36 | void md5 ( 37 | std::istream& input, 38 | unsigned char* output 39 | ); 40 | 41 | // ---------------------------------------------------------------------------------------- 42 | 43 | } 44 | 45 | #ifdef NO_MAKEFILE 46 | #include "md5_kernel_1.cpp" 47 | #endif 48 | 49 | #endif // DLIB_MD5_KERNEl_1_ 50 | 51 | -------------------------------------------------------------------------------- /dlib/LICENSE.txt: -------------------------------------------------------------------------------- 1 | Boost Software License - Version 1.0 - August 17th, 2003 2 | 3 | Permission is hereby granted, free of charge, to any person or organization 4 | obtaining a copy of the software and accompanying documentation covered by 5 | this license (the "Software") to use, reproduce, display, distribute, 6 | execute, and transmit the Software, and to prepare derivative works of the 7 | Software, and to permit third-parties to whom the Software is furnished to 8 | do so, all subject to the following: 9 | 10 | The copyright notices in the Software and this entire statement, including 11 | the above license grant, this restriction and the following disclaimer, 12 | must be included in all copies of the Software, in whole or in part, and 13 | all derivative works of the Software, unless such copies or derivative 14 | works are solely in the form of machine-executable object code generated by 15 | a source language processor. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 20 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 21 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 22 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. -------------------------------------------------------------------------------- /dlib/numerical_integration/integrate_function_adapt_simpson_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Steve Taylor (steve98654@gmail.com) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_ABSTRACTh_ 4 | #ifdef DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_ABSTRACTh_ 5 | 6 | namespace dlib 7 | { 8 | 9 | template 10 | T integrate_function_adapt_simp( 11 | const funct& f, 12 | T a, 13 | T b, 14 | T tol = 1e-10 15 | ); 16 | /*! 17 | requires 18 | - b > a 19 | - tol > 0 20 | - T should be either float, double, or long double 21 | - The expression f(a) should be a valid expression that evaluates to a T. 22 | I.e. f() should be a real valued function of a single variable. 23 | ensures 24 | - returns an approximation of the integral of f over the domain [a,b] using the 25 | adaptive Simpson method outlined in Gander, W. and W. Gautshi, "Adaptive 26 | Quadrature -- Revisited" BIT, Vol. 40, (2000), pp.84-101 27 | - tol is a tolerance parameter that determines the overall accuracy of 28 | approximated integral. We suggest a default value of 1e-10 for tol. 29 | !*/ 30 | 31 | } 32 | 33 | #endif // DLIB_INTEGRATE_FUNCTION_ADAPT_SIMPSON_ABSTRACTh_ 34 | 35 | -------------------------------------------------------------------------------- /dlib/matrix/matrix_data_layout_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2008 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_MATRIx_DATA_LAYOUT_ABSTRACT_ 4 | #ifdef DLIB_MATRIx_DATA_LAYOUT_ABSTRACT_ 5 | 6 | #include "../algs.h" 7 | 8 | namespace dlib 9 | { 10 | 11 | // ---------------------------------------------------------------------------------------- 12 | 13 | struct row_major_layout 14 | { 15 | /*! 16 | This is the default matrix layout. Any matrix object that uses this 17 | layout will be laid out in memory in row major order. Additionally, 18 | all elements are contiguous (e.g. there isn't any padding at the ends of 19 | rows or anything like that) 20 | !*/ 21 | }; 22 | 23 | // ---------------------------------------------------------------------------------------- 24 | 25 | struct column_major_layout 26 | { 27 | /*! 28 | Any matrix object that uses this layout will be laid out in memory in 29 | column major order. Additionally, all elements are contiguous (e.g. 30 | there isn't any padding at the ends of rows or anything like that) 31 | !*/ 32 | }; 33 | 34 | // ---------------------------------------------------------------------------------------- 35 | 36 | } 37 | 38 | #endif // DLIB_MATRIx_DATA_LAYOUT_ABSTRACT_ 39 | 40 | 41 | -------------------------------------------------------------------------------- /dlib/external/libjpeg/jconfig.h: -------------------------------------------------------------------------------- 1 | /* jconfig.h. Generated automatically by configure. */ 2 | /* jconfig.cfg --- source file edited by configure script */ 3 | /* see jconfig.doc for explanations */ 4 | 5 | #define HAVE_PROTOTYPES 6 | #define HAVE_UNSIGNED_CHAR 7 | #define HAVE_UNSIGNED_SHORT 8 | #undef void 9 | #undef const 10 | #undef CHAR_IS_UNSIGNED 11 | #define HAVE_STDDEF_H 12 | #define HAVE_STDLIB_H 13 | #undef NEED_BSD_STRINGS 14 | #undef NEED_SYS_TYPES_H 15 | #undef NEED_FAR_POINTERS 16 | #undef NEED_SHORT_EXTERNAL_NAMES 17 | /* Define this if you get warnings about undefined structures. */ 18 | #undef INCOMPLETE_TYPES_BROKEN 19 | 20 | #ifdef JPEG_INTERNALS 21 | 22 | #undef RIGHT_SHIFT_IS_UNSIGNED 23 | #define INLINE __inline__ 24 | /* These are for configuring the JPEG memory manager. */ 25 | #undef DEFAULT_MAX_MEM 26 | #undef NO_MKTEMP 27 | 28 | #endif /* JPEG_INTERNALS */ 29 | 30 | #ifdef JPEG_CJPEG_DJPEG 31 | 32 | #define BMP_SUPPORTED /* BMP image file format */ 33 | #define GIF_SUPPORTED /* GIF image file format */ 34 | #define PPM_SUPPORTED /* PBMPLUS PPM/PGM image file format */ 35 | #undef RLE_SUPPORTED /* Utah RLE image file format */ 36 | #define TARGA_SUPPORTED /* Targa image file format */ 37 | 38 | #undef TWO_FILE_COMMANDLINE 39 | #undef NEED_SIGNAL_CATCHER 40 | #undef DONT_USE_B_MODE 41 | 42 | /* Define this if you want percent-done progress reports from cjpeg/djpeg. */ 43 | #undef PROGRESS_REPORT 44 | 45 | #endif /* JPEG_CJPEG_DJPEG */ 46 | -------------------------------------------------------------------------------- /dlib/misc_api/misc_api_shared.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MISC_API_ShARED_Hh_ 4 | #define DLIB_MISC_API_ShARED_Hh_ 5 | 6 | #include 7 | #include "../noncopyable.h" 8 | 9 | namespace dlib 10 | { 11 | 12 | // ---------------------------------------------------------------------------------------- 13 | 14 | class locally_change_current_dir : noncopyable 15 | { 16 | public: 17 | explicit locally_change_current_dir ( 18 | const std::string& new_dir 19 | ) 20 | { 21 | reverted = false; 22 | _old_dir = get_current_dir(); 23 | set_current_dir(new_dir); 24 | } 25 | 26 | ~locally_change_current_dir() 27 | { 28 | revert(); 29 | } 30 | 31 | const std::string& old_dir ( 32 | ) const 33 | { 34 | return _old_dir; 35 | } 36 | 37 | void revert ( 38 | ) 39 | { 40 | if (!reverted) 41 | { 42 | set_current_dir(_old_dir); 43 | reverted = true; 44 | } 45 | } 46 | 47 | private: 48 | bool reverted; 49 | std::string _old_dir; 50 | }; 51 | 52 | // ---------------------------------------------------------------------------------------- 53 | 54 | } 55 | 56 | #endif // DLIB_MISC_API_ShARED_Hh_ 57 | 58 | -------------------------------------------------------------------------------- /dlib/binary_search_tree.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BINARY_SEARCH_TREe_ 4 | #define DLIB_BINARY_SEARCH_TREe_ 5 | 6 | 7 | #include "binary_search_tree/binary_search_tree_kernel_1.h" 8 | #include "binary_search_tree/binary_search_tree_kernel_2.h" 9 | #include "binary_search_tree/binary_search_tree_kernel_c.h" 10 | 11 | 12 | #include "algs.h" 13 | #include 14 | 15 | 16 | namespace dlib 17 | { 18 | 19 | template < 20 | typename domain, 21 | typename range, 22 | typename mem_manager = default_memory_manager, 23 | typename compare = std::less 24 | > 25 | class binary_search_tree 26 | { 27 | binary_search_tree() {} 28 | 29 | public: 30 | 31 | //----------- kernels --------------- 32 | 33 | // kernel_1a 34 | typedef binary_search_tree_kernel_1 35 | kernel_1a; 36 | typedef binary_search_tree_kernel_c 37 | kernel_1a_c; 38 | 39 | 40 | // kernel_2a 41 | typedef binary_search_tree_kernel_2 42 | kernel_2a; 43 | typedef binary_search_tree_kernel_c 44 | kernel_2a_c; 45 | 46 | }; 47 | } 48 | 49 | #endif // DLIB_BINARY_SEARCH_TREe_ 50 | 51 | -------------------------------------------------------------------------------- /dlib/opencv/to_open_cv.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2012 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_TO_OPEN_Cv_Hh_ 4 | #define DLIB_TO_OPEN_Cv_Hh_ 5 | 6 | #include 7 | #include "to_open_cv_abstract.h" 8 | #include "../pixel.h" 9 | #include "../matrix/matrix.h" 10 | 11 | namespace dlib 12 | { 13 | 14 | // ---------------------------------------------------------------------------------------- 15 | 16 | template < 17 | typename image_type 18 | > 19 | cv::Mat toMat ( 20 | image_type& img 21 | ) 22 | { 23 | if (image_size(img) == 0) 24 | return cv::Mat(); 25 | 26 | typedef typename image_traits::pixel_type type; 27 | if (pixel_traits::num == 1) 28 | { 29 | return cv::Mat(num_rows(img), num_columns(img), cv::DataType::type, image_data(img), width_step(img)); 30 | } 31 | else 32 | { 33 | int depth = sizeof(typename pixel_traits::basic_pixel_type)*8; 34 | int channels = pixel_traits::num; 35 | int thetype = CV_MAKETYPE(depth, channels); 36 | return cv::Mat(num_rows(img), num_columns(img), thetype, image_data(img), width_step(img)); 37 | } 38 | } 39 | 40 | // ---------------------------------------------------------------------------------------- 41 | 42 | } 43 | 44 | #endif // DLIB_TO_OPEN_Cv_Hh_ 45 | 46 | -------------------------------------------------------------------------------- /src/FacialLandmark.cpp: -------------------------------------------------------------------------------- 1 | #include "header/FacialLandmark.h" 2 | 3 | using namespace std; 4 | using namespace dlib; 5 | 6 | featureExtractor::featureExtractor(int numberOfImage, char **imageList){ 7 | this->numberOfImage=numberOfImage; 8 | this->imageList=imageList; 9 | } 10 | void featureExtractor::faceShape(){ 11 | 12 | frontal_face_detector detector = get_frontal_face_detector(); 13 | shape_predictor sp; 14 | 15 | deserialize(this->imageList[1]) >> sp; 16 | 17 | image_window win, win_faces; 18 | array2d img2; 19 | 20 | // std::vector shapes[numberOfImage-2]; 21 | for (int i = 2; i < this->numberOfImage; ++i){ 22 | cout << "processing image " << this->imageList[i] << endl; 23 | array2d img; 24 | load_image(img, this->imageList[i]); 25 | // Make the image larger so we can detect small faces. 26 | pyramid_up(img); 27 | std::vector dets = detector(img); 28 | cout << "Number of faces detected: " << dets.size() << endl; 29 | 30 | std::vector shapes; 31 | for (unsigned long j = 0; j < dets.size(); ++j){ 32 | full_object_detection shape = sp(img, dets[j]); 33 | shapes.push_back(shape); 34 | } 35 | win.clear_overlay(); 36 | win.set_image(img); 37 | win.add_overlay(render_face_detections(shapes)); 38 | cout << "Hit enter to process the next image..." << endl; 39 | cin.get(); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /dlib/test/binary_search_tree_mm2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BINARY_SEARCH_TREE_KERNEl_TEST_ 4 | #define DLIB_BINARY_SEARCH_TREE_KERNEl_TEST_ 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include "tester.h" 16 | #include "binary_search_tree.h" 17 | 18 | namespace 19 | { 20 | 21 | class binary_search_tree_tester : public tester 22 | { 23 | 24 | public: 25 | binary_search_tree_tester ( 26 | ) : 27 | tester ("test_binary_search_tree_mm2", 28 | "Runs tests on the binary_search_tree component with memory managers.") 29 | {} 30 | 31 | void perform_test ( 32 | ) 33 | { 34 | dlog << LINFO << "testing kernel_1a /w memory_manager_stateless_2"; 35 | binary_search_tree_kernel_test::kernel_2_2c>::kernel_1a>(); 37 | print_spinner(); 38 | 39 | dlog << LINFO << "testing kernel_1a /w memory_manager_3"; 40 | binary_search_tree_kernel_test::kernel_3b>::kernel_1a>(); 42 | print_spinner(); 43 | } 44 | } a; 45 | 46 | } 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /dlib/windows_magic.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_WINDOWS_MAGIc_ 4 | #define DLIB_WINDOWS_MAGIc_ 5 | 6 | #include "platform.h" 7 | 8 | #ifdef WIN32 9 | 10 | // This file contains all the magical #defines you have to setup before you 11 | // include the windows header files. 12 | 13 | #ifndef NOMINMAX 14 | #define NOMINMAX // prevent windows from messing with std::min and std::max 15 | #endif 16 | 17 | // Prevent windows from #defining IN or OUT 18 | #ifndef _NO_W32_PSEUDO_MODIFIERS 19 | #define _NO_W32_PSEUDO_MODIFIERS 20 | #endif 21 | 22 | // now just for good measure undefine min and max if they are defined 23 | #ifdef min 24 | #undef min 25 | #endif 26 | 27 | #ifdef max 28 | #undef max 29 | #endif 30 | 31 | #ifdef NO_MAKEFILE 32 | // only define this if all the cpp files are going to be sucked into the headers 33 | // because otherwise we don't need it since everything is isolated in the sockets 34 | // cpp file and this declaration for _WINSOCKAPI_ appears there also. 35 | #ifndef _WINSOCKAPI_ 36 | #define _WINSOCKAPI_ /* Prevent inclusion of winsock.h in windows.h */ 37 | #endif 38 | #endif 39 | 40 | // This is something stupid you have to do to make visual studio include the right 41 | // stuff. I don't really know what the deal is with this. 42 | #if _WIN32_WINNT < 0x0500 43 | #undef _WIN32_WINNT 44 | #define _WIN32_WINNT 0x0500 45 | #endif 46 | 47 | #endif // WIN32 48 | 49 | #endif // DLIB_WINDOWS_MAGIc_ 50 | 51 | -------------------------------------------------------------------------------- /faces/training.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Training faces 5 | These are images from the PASCAL VOC 2011 dataset. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /dlib/image_keypoint/draw_surf_points.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_DRAW_SURf_POINTS_H_ 4 | #define DLIB_DRAW_SURf_POINTS_H_ 5 | 6 | #include "surf.h" 7 | #include "../gui_widgets.h" 8 | #include "draw_surf_points_abstract.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | // ---------------------------------------------------------------------------------------- 14 | inline void draw_surf_points ( 15 | image_window& win, 16 | const std::vector& sp 17 | ) 18 | { 19 | for (unsigned long i = 0; i < sp.size(); ++i) 20 | { 21 | const unsigned long radius = static_cast(sp[i].p.scale*3); 22 | const point center(sp[i].p.center); 23 | point direction = center + point(radius,0); 24 | // SURF descriptors are rotated by sp[i].angle. So we want to include a visual 25 | // indication of this rotation on our overlay. 26 | direction = rotate_point(center, direction, sp[i].angle); 27 | 28 | win.add_overlay(image_display::overlay_circle(center, radius, rgb_pixel(0,255,0))); 29 | // Draw a line showing the orientation of the SURF descriptor. 30 | win.add_overlay(center, direction, rgb_pixel(255,0,0)); 31 | } 32 | } 33 | 34 | // ---------------------------------------------------------------------------------------- 35 | 36 | } 37 | 38 | #endif // DLIB_DRAW_SURf_POINTS_H_ 39 | 40 | 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # AnimeAvataar 2 | [![Travis](https://img.shields.io/travis/rust-lang/rust.svg)]() 3 | [![CocoaPods](https://img.shields.io/cocoapods/l/AFNetworking.svg)]() 4 | [![Libraries.io for releases](https://img.shields.io/librariesio/release/hex/phoenix/1.0.3.svg)]() 5 | 6 | This application is build using dlib library in C++. 7 | ###### You : "Hey, what are you trying to do ? " 8 | Me : "I wanted to create an anime face from a normal face. like this one" 9 | ![alt tag](http://www.jailbreakmodo.com/wp-content/uploads/make-face-cartoon.jpg) 10 | 11 | reference: http://www.jailbreakmodo.com/ 12 | ###### You :"How are you gonna do this ? " 13 | Me : "Currently there is two way to achieve, one is by extracting the feature of the face like ``Face Shape``: ['round','square','oval' ,'etc',] ``Nose shape``: ['wide','long','small and wide'] " other feautes like colour, eye shape, forehead etc and with these features create an image. another way is to extract face shape from the landmark detected and then transform the shape to an anime image. " 14 | ###### You "cool, what library are you using" 15 | Me : "currently using [dlib](http://dlib.net) for facial landmark detection " 16 | ###### You "Can I contribute to your project ?" 17 | Me : "of course ! just hit the fork and start !" 18 | ###### You "Can you tell me how to setup this project" 19 | Me : "okay " 20 | ##Setup 21 | - `git clone $project` 22 | - `download dlib and setup in the project` 23 | - ` cmake ${project directory } ` 24 | - ` make ` 25 | - this will build an executable file in exec folder ! 26 | -------------------------------------------------------------------------------- /dlib/test/checkerboard.h: -------------------------------------------------------------------------------- 1 | #ifndef DLIB_CHECKERBOARD_TeST_H_ 2 | #define DLIB_CHECKERBOARD_TeST_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace dlib 9 | { 10 | 11 | template 12 | void get_checkerboard_problem ( 13 | std::vector >& x, 14 | std::vector& y, 15 | const long num_samples, 16 | const long board_dimension = 8 17 | ) 18 | /*! 19 | requires 20 | - num_samples > 0 21 | - board_dimension > 0 22 | ensures 23 | - #x.size() == y.size() == num_samples 24 | - is_binary_classification_problem(#x,#y) == true 25 | - #x will contain points and #y labels that were 26 | sampled randomly from a checkers board that has 27 | board_dimension squares on each side. 28 | !*/ 29 | { 30 | static dlib::rand rnd; 31 | 32 | x.clear(); 33 | y.clear(); 34 | 35 | matrix sample; 36 | for (long i = 0; i < num_samples; ++i) 37 | { 38 | sample(0) = rnd.get_random_double(); 39 | sample(1) = rnd.get_random_double(); 40 | sample *= board_dimension; 41 | 42 | x.push_back(sample); 43 | if (((int)sum(floor(sample)) %2) == 0) 44 | y.push_back(+1); 45 | else 46 | y.push_back(-1); 47 | 48 | } 49 | } 50 | 51 | 52 | } 53 | 54 | #endif // DLIB_CHECKERBOARD_TeST_H_ 55 | 56 | -------------------------------------------------------------------------------- /dlib/config_reader/config_reader_thread_safe_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_CONFIG_READER_THREAD_SAFe_ABSTRACT_ 4 | #ifdef DLIB_CONFIG_READER_THREAD_SAFe_ABSTRACT_ 5 | 6 | #include 7 | #include 8 | #include "config_reader_kernel_abstract.h" 9 | #include "../threads/threads_kernel_abstract.h" 10 | 11 | namespace dlib 12 | { 13 | 14 | class config_reader_thread_safe 15 | { 16 | 17 | /*! 18 | WHAT THIS EXTENSION DOES FOR config_reader 19 | This object extends a normal config_reader by simply wrapping all 20 | its member functions inside mutex locks to make it safe to use 21 | in a threaded program. 22 | 23 | So this object provides an interface identical to the one defined 24 | in the config_reader/config_reader_kernel_abstract.h file except that 25 | the rmutex returned by get_mutex() is always locked when this 26 | object's member functions are called. 27 | !*/ 28 | 29 | public: 30 | 31 | const rmutex& get_mutex ( 32 | ) const; 33 | /*! 34 | ensures 35 | - returns the rmutex used to make this object thread safe. i.e. returns 36 | the rmutex that is locked when this object's functions are called. 37 | !*/ 38 | 39 | }; 40 | 41 | } 42 | 43 | #endif // DLIB_CONFIG_READER_THREAD_SAFe_ABSTRACT_ 44 | 45 | 46 | -------------------------------------------------------------------------------- /dlib/platform.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_PLATFORm_ 4 | #define DLIB_PLATFORm_ 5 | 6 | 7 | /*! 8 | This file ensures that: 9 | - if (we are compiling under a posix platform) then 10 | - POSIX will be defined 11 | - if (this is also Mac OS X) then 12 | - MACOSX will be defined 13 | - if (this is also HP-UX) then 14 | - HPUX will be defined 15 | - if (we are compiling under an MS Windows platform) then 16 | - WIN32 will be defined 17 | !*/ 18 | 19 | 20 | /* 21 | A good reference for this sort of information is 22 | http://predef.sourceforge.net/ 23 | */ 24 | 25 | // Define WIN32 if this is MS Windows 26 | #ifndef WIN32 27 | #if defined( _MSC_VER) || defined(__BORLANDC__) || defined(_WIN32) || defined(__WIN32__) || defined(__TOS_WIN__) 28 | #define WIN32 29 | #endif 30 | #endif 31 | 32 | #ifndef WIN32 33 | // since this is the only other platform the library currently supports 34 | // just assume it is POSIX if it isn't WIN32 35 | #ifndef POSIX 36 | #define POSIX 37 | #endif 38 | 39 | #ifndef HPUX 40 | #if defined(__hpux ) || defined(hpux) || defined (_hpux) 41 | #define HPUX 42 | #endif 43 | #endif 44 | 45 | #ifndef MACOSX 46 | #ifdef __MACOSX__ 47 | #define MACOSX 48 | #endif 49 | #ifdef __APPLE__ 50 | #define MACOSX 51 | #endif 52 | #endif 53 | 54 | #endif 55 | 56 | 57 | 58 | 59 | #endif // DLIB_PLATFORm_ 60 | 61 | -------------------------------------------------------------------------------- /dlib/matlab/example_mex_callback.cpp: -------------------------------------------------------------------------------- 1 | // The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt 2 | 3 | #include "call_matlab.h" 4 | #include "dlib/matrix.h" 5 | 6 | using namespace dlib; 7 | using namespace std; 8 | 9 | /* 10 | This mex function takes a MATLAB function handle, calls it, and 11 | returns the results. 12 | 13 | For example, you can call this function in MATLAB like so: 14 | A = magic(3) 15 | y = example_mex_callback(A, @(x)x+x) 16 | 17 | This will result in y containing the value 2*A. 18 | */ 19 | 20 | void mex_function ( 21 | const matrix& A, 22 | const function_handle& f, 23 | matrix& result 24 | ) 25 | { 26 | // The f argument to this function is a function handle passed from MATLAB. To 27 | // call it we use the following syntax: 28 | call_matlab(f, A, returns(result)); 29 | // This is equivalent to result = f(A). Therefore, the returns(variable) syntax 30 | // is used to indicate which variables are outputs of the function. 31 | 32 | 33 | 34 | 35 | // Another thing we can do is call MATLAB functions based on their string name 36 | // rather than a function_handle. Here is an example of calling eigs(). 37 | matrix m(2,2); 38 | m = 1,2, 39 | 3,4; 40 | matrix v,d; 41 | 42 | // This is equivalent to [v,d] = eigs(m); 43 | call_matlab("eigs", m, returns(v), returns(d)); 44 | cout << "eigenvectors: \n" << v << endl; 45 | cout << "eigenvalues: \n" << d << endl; 46 | } 47 | 48 | 49 | 50 | // #including this brings in all the mex boiler plate needed by MATLAB. 51 | #include "mex_wrapper.cpp" 52 | 53 | -------------------------------------------------------------------------------- /dlib/map.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MAp_ 4 | #define DLIB_MAp_ 5 | 6 | #include "map/map_kernel_1.h" 7 | #include "map/map_kernel_c.h" 8 | 9 | #include "binary_search_tree.h" 10 | 11 | 12 | #include "algs.h" 13 | #include 14 | 15 | 16 | namespace dlib 17 | { 18 | 19 | template < 20 | typename domain, 21 | typename range, 22 | typename mem_manager = default_memory_manager, 23 | typename compare = std::less 24 | > 25 | class map 26 | { 27 | map() {} 28 | 29 | 30 | // a typedef for the binary search tree used by kernel_2 31 | typedef typename binary_search_tree::kernel_1a 32 | binary_search_tree_1; 33 | 34 | // a typedef for the binary search tree used by kernel_2 35 | typedef typename binary_search_tree::kernel_2a 36 | binary_search_tree_2; 37 | 38 | public: 39 | 40 | //----------- kernels --------------- 41 | 42 | // kernel_1a 43 | typedef map_kernel_1 44 | kernel_1a; 45 | typedef map_kernel_c 46 | kernel_1a_c; 47 | 48 | // kernel_1b 49 | typedef map_kernel_1 50 | kernel_1b; 51 | typedef map_kernel_c 52 | kernel_1b_c; 53 | 54 | 55 | }; 56 | } 57 | 58 | #endif // DLIB_MAp_ 59 | 60 | -------------------------------------------------------------------------------- /dlib/dlibConfig.cmake.in: -------------------------------------------------------------------------------- 1 | # =================================================================================== 2 | # The dlib CMake configuration file 3 | # 4 | # ** File generated automatically, do not modify ** 5 | # 6 | # Usage from an external project: 7 | # In your CMakeLists.txt, add these lines: 8 | # 9 | # FIND_PACKAGE(dlib REQUIRED) 10 | # TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${dlib_LIBRARIES}) 11 | # 12 | # This file will define the following variables: 13 | # - dlib_LIBRARIES : The list of all imported targets for dlib modules. 14 | # - dlib_INCLUDE_DIRS : The dlib include directories. 15 | # - dlib_VERSION : The version of this dlib build. 16 | # - dlib_VERSION_MAJOR : Major version part of this dlib revision. 17 | # - dlib_VERSION_MINOR : Minor version part of this dlib revision. 18 | # 19 | # =================================================================================== 20 | 21 | 22 | # Compute paths 23 | get_filename_component(dlib_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 24 | 25 | if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 2.8) 26 | get_filename_component(dlib_INSTALL_PATH "@CONF_INSTALL_PATH@" ABSOLUTE) 27 | else() 28 | get_filename_component(dlib_INSTALL_PATH "@CONF_INSTALL_PATH@" REALPATH) 29 | endif() 30 | 31 | set(dlib_INCLUDE_DIRS "${dlib_INSTALL_PATH}/include") 32 | 33 | # Our library dependencies (contains definitions for IMPORTED targets) 34 | if(NOT TARGET dlib-shared AND NOT dlib_BINARY_DIR) 35 | include("${dlib_CMAKE_DIR}/dlib.cmake") 36 | endif() 37 | 38 | find_library(dlib_LIBRARIES dlib HINTS ${dlib_INSTALL_PATH}/lib) 39 | set(dlib_LIBRARIES ${dlib_LIBRARIES} "@dlib_needed_libraries@") 40 | -------------------------------------------------------------------------------- /dlib/external/libjpeg/jchuff.h: -------------------------------------------------------------------------------- 1 | /* 2 | * jchuff.h 3 | * 4 | * Copyright (C) 1991-1997, Thomas G. Lane. 5 | * This file is part of the Independent JPEG Group's software. 6 | * For conditions of distribution and use, see the accompanying README file. 7 | * 8 | * This file contains declarations for Huffman entropy encoding routines 9 | * that are shared between the sequential encoder (jchuff.c) and the 10 | * progressive encoder (jcphuff.c). No other modules need to see these. 11 | */ 12 | 13 | /* The legal range of a DCT coefficient is 14 | * -1024 .. +1023 for 8-bit data; 15 | * -16384 .. +16383 for 12-bit data. 16 | * Hence the magnitude should always fit in 10 or 14 bits respectively. 17 | */ 18 | 19 | #if BITS_IN_JSAMPLE == 8 20 | #define MAX_COEF_BITS 10 21 | #else 22 | #define MAX_COEF_BITS 14 23 | #endif 24 | 25 | /* Derived data constructed for each Huffman table */ 26 | 27 | typedef struct { 28 | unsigned int ehufco[256]; /* code for each symbol */ 29 | char ehufsi[256]; /* length of code for each symbol */ 30 | /* If no code has been allocated for a symbol S, ehufsi[S] contains 0 */ 31 | } c_derived_tbl; 32 | 33 | /* Short forms of external names for systems with brain-damaged linkers. */ 34 | 35 | #ifdef NEED_SHORT_EXTERNAL_NAMES 36 | #define jpeg_make_c_derived_tbl jMkCDerived 37 | #define jpeg_gen_optimal_table jGenOptTbl 38 | #endif /* NEED_SHORT_EXTERNAL_NAMES */ 39 | 40 | /* Expand a Huffman table definition into the derived format */ 41 | EXTERN(void) jpeg_make_c_derived_tbl 42 | JPP((j_compress_ptr cinfo, int isDC, int tblno, 43 | c_derived_tbl ** pdtbl)); 44 | 45 | /* Generate an optimal table definition given the specified counts */ 46 | EXTERN(void) jpeg_gen_optimal_table 47 | JPP((j_compress_ptr cinfo, JHUFF_TBL * htbl, long freq[])); 48 | -------------------------------------------------------------------------------- /dlib/sync_extension/sync_extension_kernel_1.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SYNC_EXTENSION_KERNEl_1_ 4 | #define DLIB_SYNC_EXTENSION_KERNEl_1_ 5 | 6 | #include "../threads.h" 7 | #include "../algs.h" 8 | #include "sync_extension_kernel_abstract.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | template < 14 | typename base 15 | > 16 | class sync_extension_kernel_1 : public base 17 | { 18 | 19 | rmutex m; 20 | rsignaler s; 21 | 22 | public: 23 | 24 | sync_extension_kernel_1 () : s(m) {} 25 | 26 | template < typename T > 27 | sync_extension_kernel_1 (const T& one) : base(one),s(m) {} 28 | template < typename T, typename U > 29 | sync_extension_kernel_1 (const T& one, const U& two) : base(one,two),s(m) {} 30 | 31 | 32 | const rmutex& get_mutex( 33 | ) const { return m; } 34 | 35 | void lock ( 36 | ) const { m.lock(); } 37 | 38 | void unlock ( 39 | ) const { m.unlock(); } 40 | 41 | void wait ( 42 | ) const { s.wait(); } 43 | 44 | bool wait_or_timeout ( 45 | unsigned long milliseconds 46 | ) const { return s.wait_or_timeout(milliseconds); } 47 | 48 | void broadcast ( 49 | ) const { s.broadcast(); } 50 | 51 | void signal ( 52 | ) const { s.signal(); } 53 | 54 | }; 55 | 56 | template < 57 | typename base 58 | > 59 | inline void swap ( 60 | sync_extension_kernel_1& a, 61 | sync_extension_kernel_1& b 62 | ) { a.swap(b); } 63 | 64 | } 65 | 66 | #endif // DLIB_SYNC_EXTENSION_KERNEl_1_ 67 | 68 | -------------------------------------------------------------------------------- /dlib/svm/multiclass_tools_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_MULTICLASS_TOoLS_ABSTRACT_Hh_ 4 | #ifdef DLIB_MULTICLASS_TOoLS_ABSTRACT_Hh_ 5 | 6 | #include 7 | #include 8 | #include "../unordered_pair.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | // ---------------------------------------------------------------------------------------- 14 | 15 | template 16 | std::vector select_all_distinct_labels ( 17 | const std::vector& labels 18 | ); 19 | /*! 20 | ensures 21 | - Determines all distinct values present in labels and stores them 22 | into a sorted vector and returns it. They are sorted in ascending 23 | order. 24 | !*/ 25 | 26 | // ---------------------------------------------------------------------------------------- 27 | 28 | template 29 | std::vector > find_missing_pairs ( 30 | const std::map,U>& binary_decision_functions 31 | ); 32 | /*! 33 | ensures 34 | - Let L denote the set of all label_type values present in binary_decision_functions. 35 | - This function finds all the label pairs with both elements distinct and in L but 36 | not also in binary_decision_functions. All these missing pairs are stored 37 | in a sorted vector and returned. They are sorted in ascending order. 38 | !*/ 39 | 40 | // ---------------------------------------------------------------------------------------- 41 | 42 | } 43 | 44 | #endif // DLIB_MULTICLASS_TOoLS_ABSTRACT_Hh_ 45 | 46 | -------------------------------------------------------------------------------- /dlib/sequence/sequence_sort_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_SEQUENCE_SORt_ABSTRACT_ 4 | #ifdef DLIB_SEQUENCE_SORt_ABSTRACT_ 5 | 6 | #include "sequence_kernel_abstract.h" 7 | 8 | namespace dlib 9 | { 10 | 11 | template < 12 | typename seq_base 13 | > 14 | class sequence_sort : public seq_base 15 | { 16 | 17 | /*! 18 | REQUIREMENTS ON T 19 | T must implement operator< for its type 20 | 21 | REQUIREMENTS ON seq_base 22 | must be an implementation of sequence/sequence_kernel_abstract.h 23 | 24 | 25 | 26 | POINTERS AND REFERENCES TO INTERNAL DATA 27 | sort() may invalidate pointers and references to data members. 28 | 29 | WHAT THIS EXTENSION DOES FOR sequence 30 | this gives a sequence the ability to sort its contents by calling sort() 31 | !*/ 32 | 33 | 34 | public: 35 | 36 | void sort ( 37 | ); 38 | /*! 39 | ensures 40 | - for all elements in #*this the ith element is <= the i+1 element 41 | - #at_start() == true 42 | throws 43 | - std::bad_alloc or any exception thrown by T's constructor 44 | data may be lost if sort() throws 45 | !*/ 46 | 47 | 48 | }; 49 | 50 | 51 | template < 52 | typename seq_base 53 | > 54 | inline void swap ( 55 | sequence_sort& a, 56 | sequence_sort& b 57 | ) { a.swap(b); } 58 | /*! 59 | provides a global swap function 60 | !*/ 61 | 62 | } 63 | 64 | #endif // DLIB_SEQUENCE_SORt_ABSTRACT_ 65 | 66 | -------------------------------------------------------------------------------- /dlib/hash_set.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_HASH_SEt_ 4 | #define DLIB_HASH_SEt_ 5 | 6 | #include "hash_set/hash_set_kernel_1.h" 7 | #include "hash_set/hash_set_kernel_c.h" 8 | 9 | #include "hash_table.h" 10 | #include "algs.h" 11 | 12 | 13 | #include "algs.h" 14 | #include 15 | 16 | 17 | namespace dlib 18 | { 19 | 20 | template < 21 | typename T, 22 | unsigned long expnum, 23 | typename mem_manager = default_memory_manager, 24 | typename compare = std::less 25 | > 26 | class hash_set 27 | { 28 | hash_set() {} 29 | 30 | typedef typename hash_table::kernel_1a ht1a; 31 | typedef typename hash_table::kernel_1a ht2a; 32 | typedef typename hash_table::kernel_1a ht2b; 33 | 34 | public: 35 | 36 | //----------- kernels --------------- 37 | 38 | // kernel_1a 39 | typedef hash_set_kernel_1 40 | kernel_1a; 41 | typedef hash_set_kernel_c 42 | kernel_1a_c; 43 | 44 | // kernel_1b 45 | typedef hash_set_kernel_1 46 | kernel_1b; 47 | typedef hash_set_kernel_c 48 | kernel_1b_c; 49 | 50 | // kernel_1c 51 | typedef hash_set_kernel_1 52 | kernel_1c; 53 | typedef hash_set_kernel_c 54 | kernel_1c_c; 55 | 56 | 57 | 58 | 59 | }; 60 | } 61 | 62 | #endif // DLIB_HASH_SEt_ 63 | 64 | -------------------------------------------------------------------------------- /dlib/numeric_constants.h: -------------------------------------------------------------------------------- 1 | //Copyright (C) 2013 Steve Taylor (steve98654@gmail.com), Davis E. King 2 | //License: Boost Software License. See LICENSE.txt for full license. 3 | #ifndef DLIB_NUMERIC_CONSTANTs_H_ 4 | #define DLIB_NUMERIC_CONSTANTs_H_ 5 | 6 | namespace dlib 7 | { 8 | 9 | // pi -- Pi 10 | const double pi = 3.1415926535897932385; 11 | 12 | // e -- Euler's Constant 13 | const double e = 2.7182818284590452354; 14 | 15 | // sqrt_2 -- The square root of 2 16 | const double sqrt_2 = 1.4142135623730950488; 17 | 18 | // sqrt_3 -- The square root of 3 19 | const double sqrt_3 = 1.7320508075688772935; 20 | 21 | // log10_2 -- The logarithm base 10 of two 22 | const double log10_2 = 0.30102999566398119521; 23 | 24 | // light_spd -- The speed of light in vacuum in meters per second 25 | const double light_spd = 2.99792458e8; 26 | 27 | // newton_G -- Newton's gravitational constant (in metric units of m^3/(kg*s^2)) 28 | const double newton_G = 6.67384e-11; 29 | 30 | // planck_cst -- Planck's constant (in units of Joules * seconds) 31 | const double planck_cst = 6.62606957e-34; 32 | 33 | // golden_ratio -- The Golden Ratio 34 | const double golden_ratio = 1.6180339887498948482; 35 | 36 | // euler_gamma -- The Euler Mascheroni Constant 37 | const double euler_gamma = 0.5772156649015328606065; 38 | 39 | // catalan -- Catalan's Constant 40 | const double catalan = 0.91596559417721901505; 41 | 42 | // glaisher -- Glaisher Kinkelin constant 43 | const double glaisher = 1.2824271291006226369; 44 | 45 | // khinchin -- Khinchin's constant 46 | const double khinchin = 2.6854520010653064453; 47 | 48 | // apery -- Apery's constant 49 | const double apery = 1.2020569031595942854; 50 | } 51 | 52 | #endif //DLIB_NUMERIC_CONSTANTs_H_ 53 | 54 | -------------------------------------------------------------------------------- /dlib/sequence/sequence_sort_2.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SEQUENCE_SORt_2_ 4 | #define DLIB_SEQUENCE_SORt_2_ 5 | 6 | #include "sequence_sort_abstract.h" 7 | #include "../algs.h" 8 | #include "../sort.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | template < 14 | typename seq_base 15 | > 16 | class sequence_sort_2 : public seq_base 17 | { 18 | typedef typename seq_base::type T; 19 | 20 | public: 21 | 22 | /*! 23 | this is a version of the QuickSort algorithm 24 | this uses the dlib::qsort_array function 25 | !*/ 26 | 27 | void sort ( 28 | ); 29 | 30 | 31 | }; 32 | 33 | template < 34 | typename seq_base 35 | > 36 | inline void swap ( 37 | sequence_sort_2& a, 38 | sequence_sort_2& b 39 | ) { a.swap(b); } 40 | 41 | // ---------------------------------------------------------------------------------------- 42 | // ---------------------------------------------------------------------------------------- 43 | // member function definitions 44 | // ---------------------------------------------------------------------------------------- 45 | // ---------------------------------------------------------------------------------------- 46 | 47 | template < 48 | typename seq_base 49 | > 50 | void sequence_sort_2:: 51 | sort ( 52 | ) 53 | { 54 | if (this->size() > 1) 55 | { 56 | dlib::qsort_array(*this,0,this->size()-1); 57 | } 58 | } 59 | 60 | // ---------------------------------------------------------------------------------------- 61 | 62 | } 63 | 64 | #endif // DLIB_SEQUENCE_SORt_2_ 65 | 66 | -------------------------------------------------------------------------------- /dlib/enable_if.h: -------------------------------------------------------------------------------- 1 | // Copyright 2003 (C) The Trustees of Indiana University. 2 | // Use, modification, and distribution is subject to the Boost Software 3 | // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 4 | // http://www.boost.org/LICENSE_1_0.txt) 5 | // Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) 6 | // Jeremiah Willcock (jewillco at osl.iu.edu) 7 | // Andrew Lumsdaine (lums at osl.iu.edu) 8 | #ifndef DLIB_BOOST_UTILITY_ENABLE_IF_HPP 9 | #define DLIB_BOOST_UTILITY_ENABLE_IF_HPP 10 | 11 | namespace dlib 12 | { 13 | 14 | template 15 | struct enable_if_c { 16 | typedef T type; 17 | }; 18 | 19 | template 20 | struct enable_if_c {}; 21 | 22 | template 23 | struct enable_if : public enable_if_c {}; 24 | 25 | template 26 | struct lazy_enable_if_c { 27 | typedef typename T::type type; 28 | }; 29 | 30 | template 31 | struct lazy_enable_if_c {}; 32 | 33 | template 34 | struct lazy_enable_if : public lazy_enable_if_c {}; 35 | 36 | 37 | template 38 | struct disable_if_c { 39 | typedef T type; 40 | }; 41 | 42 | template 43 | struct disable_if_c {}; 44 | 45 | template 46 | struct disable_if : public disable_if_c {}; 47 | 48 | template 49 | struct lazy_disable_if_c { 50 | typedef typename T::type type; 51 | }; 52 | 53 | template 54 | struct lazy_disable_if_c {}; 55 | 56 | template 57 | struct lazy_disable_if : public lazy_disable_if_c {}; 58 | 59 | } // namespace dlib 60 | 61 | #endif // DLIB_BOOST_UTILITY_ENABLE_IF_HPP 62 | 63 | -------------------------------------------------------------------------------- /dlib/clustering/spectral_cluster_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_SPECTRAL_CLUSTEr_ABSTRACT_H_ 4 | #ifdef DLIB_SPECTRAL_CLUSTEr_ABSTRACT_H_ 5 | 6 | #include 7 | 8 | namespace dlib 9 | { 10 | template < 11 | typename kernel_type, 12 | typename vector_type 13 | > 14 | std::vector spectral_cluster ( 15 | const kernel_type& k, 16 | const vector_type& samples, 17 | const unsigned long num_clusters 18 | ); 19 | /*! 20 | requires 21 | - samples must be something with an interface compatible with std::vector. 22 | - The following expression must evaluate to a double or float: 23 | k(samples[i], samples[j]) 24 | - num_clusters > 0 25 | ensures 26 | - Performs the spectral clustering algorithm described in the paper: 27 | On spectral clustering: Analysis and an algorithm by Ng, Jordan, and Weiss. 28 | and returns the results. 29 | - This function clusters the input data samples into num_clusters clusters and 30 | returns a vector that indicates which cluster each sample falls into. In 31 | particular, we return an array A such that: 32 | - A.size() == samples.size() 33 | - A[i] == the cluster assignment of samples[i]. 34 | - for all valid i: 0 <= A[i] < num_clusters 35 | - The "similarity" of samples[i] with samples[j] is given by 36 | k(samples[i],samples[j]). This means that k() should output a number >= 0 37 | and the number should be larger for samples that are more similar. 38 | !*/ 39 | } 40 | 41 | #endif // DLIB_SPECTRAL_CLUSTEr_ABSTRACT_H_ 42 | 43 | 44 | -------------------------------------------------------------------------------- /dlib/general_hash/count_bits.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_COUNT_BiTS_Hh_ 4 | #define DLIB_COUNT_BiTS_Hh_ 5 | 6 | #include "../algs.h" 7 | #include 8 | 9 | namespace dlib 10 | { 11 | 12 | // ---------------------------------------------------------------------------------------- 13 | 14 | template < 15 | typename T 16 | > 17 | T count_bits ( 18 | T v 19 | ) 20 | /*! 21 | requires 22 | - T is an unsigned integral type 23 | ensures 24 | - returns the number of bits in v which are set to 1. 25 | !*/ 26 | { 27 | COMPILE_TIME_ASSERT(is_unsigned_type::value && sizeof(T) <= 8); 28 | 29 | // This bit of bit trickery is from: 30 | // http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSet64 31 | 32 | v = v - ((v >> 1) & (T)~(T)0/3); 33 | v = (v & (T)~(T)0/15*3) + ((v >> 2) & (T)~(T)0/15*3); 34 | v = (v + (v >> 4)) & (T)~(T)0/255*15; 35 | return (T)(v * ((T)~(T)0/255)) >> (sizeof(T) - 1) * CHAR_BIT; 36 | } 37 | 38 | // ---------------------------------------------------------------------------------------- 39 | 40 | template < 41 | typename T 42 | > 43 | T hamming_distance ( 44 | const T& a, 45 | const T& b 46 | ) 47 | /*! 48 | requires 49 | - T is an unsigned integral type 50 | ensures 51 | - returns the number of bits which differ between a and b. 52 | !*/ 53 | { 54 | return count_bits(a^b); 55 | } 56 | 57 | // ---------------------------------------------------------------------------------------- 58 | 59 | } 60 | 61 | #endif // DLIB_COUNT_BiTS_Hh_ 62 | 63 | -------------------------------------------------------------------------------- /dlib/array2d/array2d_generic_image.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ARRAY2D_GENERIC_iMAGE_Hh_ 4 | #define DLIB_ARRAY2D_GENERIC_iMAGE_Hh_ 5 | 6 | #include "array2d_kernel.h" 7 | #include "../image_processing/generic_image.h" 8 | 9 | namespace dlib 10 | { 11 | template 12 | struct image_traits > 13 | { 14 | typedef T pixel_type; 15 | }; 16 | template 17 | struct image_traits > 18 | { 19 | typedef T pixel_type; 20 | }; 21 | 22 | template 23 | inline long num_rows( const array2d& img) { return img.nr(); } 24 | template 25 | inline long num_columns( const array2d& img) { return img.nc(); } 26 | 27 | template 28 | inline void set_image_size( 29 | array2d& img, 30 | long rows, 31 | long cols 32 | ) { img.set_size(rows,cols); } 33 | 34 | template 35 | inline void* image_data( 36 | array2d& img 37 | ) 38 | { 39 | if (img.size() != 0) 40 | return &img[0][0]; 41 | else 42 | return 0; 43 | } 44 | 45 | template 46 | inline const void* image_data( 47 | const array2d& img 48 | ) 49 | { 50 | if (img.size() != 0) 51 | return &img[0][0]; 52 | else 53 | return 0; 54 | } 55 | 56 | template 57 | inline long width_step( 58 | const array2d& img 59 | ) 60 | { 61 | return img.width_step(); 62 | } 63 | 64 | } 65 | 66 | #endif // DLIB_ARRAY2D_GENERIC_iMAGE_Hh_ 67 | 68 | -------------------------------------------------------------------------------- /dlib/hash_table.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_HASH_TABLe_ 4 | #define DLIB_HASH_TABLe_ 5 | 6 | 7 | #include "hash_table/hash_table_kernel_1.h" 8 | #include "hash_table/hash_table_kernel_2.h" 9 | #include "hash_table/hash_table_kernel_c.h" 10 | #include "algs.h" 11 | 12 | #include "binary_search_tree.h" 13 | #include 14 | 15 | 16 | namespace dlib 17 | { 18 | 19 | template < 20 | typename domain, 21 | typename range, 22 | typename mem_manager = default_memory_manager, 23 | typename compare = std::less 24 | > 25 | class hash_table 26 | { 27 | hash_table() {} 28 | 29 | typedef typename binary_search_tree::kernel_1a 30 | bst_1; 31 | typedef typename binary_search_tree::kernel_2a 32 | bst_2; 33 | 34 | public: 35 | 36 | //----------- kernels --------------- 37 | 38 | // kernel_1a 39 | typedef hash_table_kernel_1 40 | kernel_1a; 41 | typedef hash_table_kernel_c 42 | kernel_1a_c; 43 | 44 | 45 | // kernel_2a 46 | typedef hash_table_kernel_2 47 | kernel_2a; 48 | typedef hash_table_kernel_c 49 | kernel_2a_c; 50 | 51 | // kernel_2b 52 | typedef hash_table_kernel_2 53 | kernel_2b; 54 | typedef hash_table_kernel_c 55 | kernel_2b_c; 56 | }; 57 | } 58 | 59 | #endif // DLIB_HASH_TABLe_ 60 | 61 | -------------------------------------------------------------------------------- /dlib/statistics/image_feature_sampling_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_IMAGE_FEATURE_SaMPLING_ABSTRACT_Hh_ 4 | #ifdef DLIB_IMAGE_FEATURE_SaMPLING_ABSTRACT_Hh_ 5 | 6 | #include "random_subset_selector_abstract.h" 7 | 8 | namespace dlib 9 | { 10 | 11 | // ---------------------------------------------------------------------------------------- 12 | 13 | template < 14 | typename image_array_type, 15 | typename feature_extractor_type, 16 | typename pyramid_type 17 | > 18 | random_subset_selector randomly_sample_image_features ( 19 | const image_array_type& images, 20 | const pyramid_type& pyr, 21 | const feature_extractor_type& fe, 22 | unsigned long num 23 | ); 24 | /*! 25 | requires 26 | - pyramid_type == a type compatible with the image pyramid objects defined 27 | in dlib/image_transforms/image_pyramid_abstract.h 28 | - feature_extractor_type == a local image feature extractor type such as the 29 | dlib::hog_image 30 | - image_array_type == an implementation of dlib/array/array_kernel_abstract.h 31 | and it must contain image objects which can be passed to pyr() and fe.load() 32 | and are swappable by global swap(). 33 | ensures 34 | - creates an image pyramid for each image in images and performs feature 35 | extraction on each pyramid level. Then selects a random subsample of at 36 | most num local feature vectors and returns it. 37 | !*/ 38 | 39 | // ---------------------------------------------------------------------------------------- 40 | 41 | } 42 | 43 | #endif // DLIB_IMAGE_FEATURE_SaMPLING_ABSTRACT_Hh_ 44 | 45 | 46 | -------------------------------------------------------------------------------- /dlib/any/any_function_impl2.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ANY_FUNCTION_ARG_LIST 4 | #error "You aren't supposed to directly #include this file. #include instead." 5 | #endif 6 | 7 | #ifdef DLIB_ANY_FUNCTION_ARG_LIST 8 | 9 | // The case where function_type has a non-void return type 10 | template 11 | class any_function 12 | { 13 | #define DLIB_ANY_FUNCTION_RETURN return 14 | #include "any_function_impl.h" 15 | #undef DLIB_ANY_FUNCTION_RETURN 16 | 17 | private: 18 | // You get a compiler error about this function being private if you try to assign 19 | // or copy between any_functions with different types. You must only copy between 20 | // any_functions that represent functions with the same signature. 21 | template any_function(const any_function&); 22 | }; 23 | 24 | // The case where function_type has a void return type 25 | template 26 | class any_function::type, DLIB_ANY_FUNCTION_NUM_ARGS> 27 | { 28 | #define DLIB_ANY_FUNCTION_RETURN 29 | #include "any_function_impl.h" 30 | #undef DLIB_ANY_FUNCTION_RETURN 31 | 32 | private: 33 | // You get a compiler error about this function being private if you try to assign 34 | // or copy between any_functions with different types. You must only copy between 35 | // any_functions that represent functions with the same signature. 36 | template any_function(const any_function&); 37 | }; 38 | 39 | #undef DLIB_ANY_FUNCTION_ARG_LIST 40 | #undef DLIB_ANY_FUNCTION_ARGS 41 | #undef DLIB_ANY_FUNCTION_NUM_ARGS 42 | 43 | #endif // DLIB_ANY_FUNCTION_ARG_LIST 44 | 45 | -------------------------------------------------------------------------------- /dlib/image_saver/save_png_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_SAVE_PnG_ABSTRACT_ 4 | #ifdef DLIB_SAVE_PnG_ABSTRACT_ 5 | 6 | #include "../pixel.h" 7 | #include "../image_processing/generic_image.h" 8 | 9 | namespace dlib 10 | { 11 | 12 | // ---------------------------------------------------------------------------------------- 13 | 14 | template < 15 | typename image_type 16 | > 17 | void save_png ( 18 | const image_type& image, 19 | const std::string& file_name 20 | ); 21 | /*! 22 | requires 23 | - image_type == an image object that implements the interface defined in 24 | dlib/image_processing/generic_image.h or a matrix expression 25 | - image.size() != 0 26 | ensures 27 | - writes the image to the file indicated by file_name in the PNG (Portable Network Graphics) 28 | format. 29 | - image[0][0] will be in the upper left corner of the image. 30 | - image[image.nr()-1][image.nc()-1] will be in the lower right 31 | corner of the image. 32 | - This routine can save images containing any type of pixel. However, save_png() can 33 | only natively store the following pixel types: rgb_pixel, rgb_alpha_pixel, uint8, 34 | and uint16. All other pixel types will be converted into one of these types as 35 | appropriate before being saved to disk. 36 | throws 37 | - image_save_error 38 | This exception is thrown if there is an error that prevents us from saving 39 | the image. 40 | - std::bad_alloc 41 | !*/ 42 | 43 | // ---------------------------------------------------------------------------------------- 44 | 45 | } 46 | 47 | #endif // DLIB_SAVE_PnG_ABSTRACT_ 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /dlib/set.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SEt_ 4 | #define DLIB_SEt_ 5 | 6 | #include "set/set_kernel_1.h" 7 | #include "set/set_kernel_c.h" 8 | 9 | 10 | 11 | #include "binary_search_tree.h" 12 | 13 | #include "set/set_compare_1.h" 14 | 15 | #include "algs.h" 16 | #include 17 | 18 | namespace dlib 19 | { 20 | 21 | template < 22 | typename T, 23 | typename mem_manager = default_memory_manager, 24 | typename compare = std::less 25 | > 26 | class set 27 | { 28 | set() {} 29 | 30 | 31 | 32 | 33 | 34 | typedef typename binary_search_tree::kernel_1a 35 | binary_search_tree_1; 36 | 37 | typedef typename binary_search_tree::kernel_2a 38 | binary_search_tree_2; 39 | 40 | public: 41 | 42 | //----------- kernels --------------- 43 | 44 | // kernel_1a 45 | typedef set_kernel_1 46 | kernel_1a; 47 | typedef set_kernel_c 48 | kernel_1a_c; 49 | 50 | // kernel_1b 51 | typedef set_kernel_1 52 | kernel_1b; 53 | typedef set_kernel_c 54 | kernel_1b_c; 55 | 56 | 57 | //---------- extensions ------------ 58 | 59 | // compare extensions 60 | typedef set_compare_1 61 | compare_1a; 62 | typedef set_compare_1 63 | compare_1a_c; 64 | 65 | typedef set_compare_1 66 | compare_1b; 67 | typedef set_compare_1 68 | compare_1b_c; 69 | 70 | }; 71 | } 72 | 73 | #endif // DLIB_SEt_ 74 | 75 | -------------------------------------------------------------------------------- /dlib/svm.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SVm_HEADER 4 | #define DLIB_SVm_HEADER 5 | 6 | #include "svm/svm_rank_trainer.h" 7 | #include "svm/svm.h" 8 | #include "svm/krls.h" 9 | #include "svm/rls.h" 10 | #include "svm/kcentroid.h" 11 | #include "svm/kcentroid_overloads.h" 12 | #include "svm/kkmeans.h" 13 | #include "svm/feature_ranking.h" 14 | #include "svm/rbf_network.h" 15 | #include "svm/linearly_independent_subset_finder.h" 16 | #include "svm/reduced.h" 17 | #include "svm/rvm.h" 18 | #include "svm/pegasos.h" 19 | #include "svm/sparse_kernel.h" 20 | #include "svm/null_trainer.h" 21 | #include "svm/roc_trainer.h" 22 | #include "svm/kernel_matrix.h" 23 | #include "svm/empirical_kernel_map.h" 24 | #include "svm/svm_c_linear_trainer.h" 25 | #include "svm/svm_c_linear_dcd_trainer.h" 26 | #include "svm/svm_c_ekm_trainer.h" 27 | #include "svm/simplify_linear_decision_function.h" 28 | #include "svm/krr_trainer.h" 29 | #include "svm/sort_basis_vectors.h" 30 | #include "svm/svm_c_trainer.h" 31 | #include "svm/svm_one_class_trainer.h" 32 | #include "svm/svr_trainer.h" 33 | 34 | #include "svm/one_vs_one_decision_function.h" 35 | #include "svm/multiclass_tools.h" 36 | #include "svm/cross_validate_multiclass_trainer.h" 37 | #include "svm/cross_validate_regression_trainer.h" 38 | #include "svm/cross_validate_object_detection_trainer.h" 39 | #include "svm/cross_validate_sequence_labeler.h" 40 | #include "svm/cross_validate_sequence_segmenter.h" 41 | #include "svm/cross_validate_assignment_trainer.h" 42 | 43 | #include "svm/one_vs_all_decision_function.h" 44 | 45 | #include "svm/structural_svm_problem.h" 46 | #include "svm/sequence_labeler.h" 47 | #include "svm/assignment_function.h" 48 | #include "svm/track_association_function.h" 49 | #include "svm/active_learning.h" 50 | #include "svm/svr_linear_trainer.h" 51 | #include "svm/sequence_segmenter.h" 52 | 53 | #endif // DLIB_SVm_HEADER 54 | 55 | 56 | -------------------------------------------------------------------------------- /dlib/hash_map.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_HASH_MAp_ 4 | #define DLIB_HASH_MAp_ 5 | 6 | #include "hash_map/hash_map_kernel_1.h" 7 | #include "hash_map/hash_map_kernel_c.h" 8 | 9 | #include "hash_table.h" 10 | #include "algs.h" 11 | 12 | #include "algs.h" 13 | #include 14 | 15 | namespace dlib 16 | { 17 | 18 | template < 19 | typename domain, 20 | typename range, 21 | unsigned long expnum, 22 | typename mem_manager = default_memory_manager, 23 | typename compare = std::less 24 | > 25 | class hash_map 26 | { 27 | hash_map() {} 28 | 29 | typedef typename hash_table::kernel_1a 30 | hash_table_1; 31 | typedef typename hash_table::kernel_2a 32 | hash_table_2; 33 | typedef typename hash_table::kernel_2b 34 | hash_table_3; 35 | 36 | public: 37 | 38 | //----------- kernels --------------- 39 | 40 | // kernel_1a 41 | typedef hash_map_kernel_1 42 | kernel_1a; 43 | typedef hash_map_kernel_c 44 | kernel_1a_c; 45 | 46 | // kernel_1b 47 | typedef hash_map_kernel_1 48 | kernel_1b; 49 | typedef hash_map_kernel_c 50 | kernel_1b_c; 51 | 52 | // kernel_1c 53 | typedef hash_map_kernel_1 54 | kernel_1c; 55 | typedef hash_map_kernel_c 56 | kernel_1c_c; 57 | 58 | 59 | }; 60 | } 61 | 62 | #endif // DLIB_HASH_MAp_ 63 | 64 | -------------------------------------------------------------------------------- /dlib/optimization/max_sum_submatrix_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_MAX_SUM_SUBMaTRIX_ABSTRACT_Hh_ 4 | #ifdef DLIB_MAX_SUM_SUBMaTRIX_ABSTRACT_Hh_ 5 | 6 | #include "../matrix.h" 7 | #include 8 | #include "../geometry.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | // ---------------------------------------------------------------------------------------- 14 | 15 | template < 16 | typename EXP 17 | > 18 | std::vector max_sum_submatrix( 19 | const matrix_exp& mat, 20 | unsigned long max_rects, 21 | double thresh = 0 22 | ); 23 | /*! 24 | requires 25 | - thresh >= 0 26 | - mat.size() != 0 27 | ensures 28 | - This function finds the submatrix within mat which has the largest sum. It then 29 | zeros out that submatrix and repeats the process until no more maximal submatrices can 30 | be found. The std::vector returned will be ordered so that the rectangles with the 31 | largest sum come first. 32 | - Each submatrix must have a sum greater than thresh. If no such submatrix exists then 33 | the algorithm terminates and returns an empty std::vector. 34 | - At most max_rects rectangles are returned. 35 | 36 | - This function is basically an implementation of the efficient subwindow search (I-ESS) 37 | algorithm presented in the following paper: 38 | Efficient Algorithms for Subwindow Search in Object Detection and Localization 39 | by Senjian An, Patrick Peursum, Wanquan Liu and Svetha Venkatesh 40 | In CVPR 2009 41 | !*/ 42 | 43 | // ---------------------------------------------------------------------------------------- 44 | 45 | } 46 | 47 | #endif // DLIB_MAX_SUM_SUBMaTRIX_ABSTRACT_Hh_ 48 | 49 | 50 | -------------------------------------------------------------------------------- /faces/testing.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Testing faces 5 | These are images from the PASCAL VOC 2011 dataset. 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | -------------------------------------------------------------------------------- /dlib/svm/null_trainer.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2009 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_NULL_TRAINERs_H_ 4 | #define DLIB_NULL_TRAINERs_H_ 5 | 6 | #include "null_trainer_abstract.h" 7 | #include "../algs.h" 8 | #include "function_abstract.h" 9 | 10 | namespace dlib 11 | { 12 | 13 | // ---------------------------------------------------------------------------------------- 14 | 15 | template < 16 | typename dec_funct_type 17 | > 18 | class null_trainer_type 19 | { 20 | public: 21 | typedef typename dec_funct_type::kernel_type kernel_type; 22 | typedef typename dec_funct_type::scalar_type scalar_type; 23 | typedef typename dec_funct_type::sample_type sample_type; 24 | typedef typename dec_funct_type::mem_manager_type mem_manager_type; 25 | typedef dec_funct_type trained_function_type; 26 | 27 | null_trainer_type ( 28 | ){} 29 | 30 | null_trainer_type ( 31 | const dec_funct_type& dec_funct_ 32 | ) : dec_funct(dec_funct_) {} 33 | 34 | template < 35 | typename in_sample_vector_type, 36 | typename in_scalar_vector_type 37 | > 38 | const dec_funct_type& train ( 39 | const in_sample_vector_type& , 40 | const in_scalar_vector_type& 41 | ) const { return dec_funct; } 42 | 43 | private: 44 | dec_funct_type dec_funct; 45 | }; 46 | 47 | // ---------------------------------------------------------------------------------------- 48 | 49 | template < 50 | typename dec_funct_type 51 | > 52 | const null_trainer_type null_trainer ( 53 | const dec_funct_type& dec_funct 54 | ) { return null_trainer_type(dec_funct); } 55 | 56 | // ---------------------------------------------------------------------------------------- 57 | 58 | } 59 | 60 | #endif // DLIB_NULL_TRAINERs_H_ 61 | 62 | -------------------------------------------------------------------------------- /dlib/threads/threads_kernel_2.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_THREADS_KERNEL_2_CPp_ 4 | #define DLIB_THREADS_KERNEL_2_CPp_ 5 | 6 | #include "../platform.h" 7 | 8 | #ifdef POSIX 9 | 10 | #include "threads_kernel_2.h" 11 | 12 | 13 | namespace dlib 14 | { 15 | namespace threads_kernel_shared_helpers 16 | { 17 | 18 | // ----------------------------------------------------------------------------------- 19 | 20 | struct info 21 | { 22 | void* param; 23 | void (*funct)(void*); 24 | }; 25 | 26 | // ----------------------------------------------------------------------------------- 27 | 28 | void* thread_starter ( 29 | void* param 30 | ) 31 | { 32 | info* alloc_p = static_cast(param); 33 | info p = *alloc_p; 34 | delete alloc_p; 35 | 36 | // detach self 37 | pthread_detach(pthread_self()); 38 | 39 | p.funct(p.param); 40 | return 0; 41 | } 42 | 43 | // ----------------------------------------------------------------------------------- 44 | 45 | bool spawn_thread ( 46 | void (*funct)(void*), 47 | void* param 48 | ) 49 | { 50 | info* p; 51 | try { p = new info; } 52 | catch (...) { return false; } 53 | 54 | p->funct = funct; 55 | p->param = param; 56 | 57 | pthread_t thread_id; 58 | if ( pthread_create (&thread_id, 0, thread_starter, p) ) 59 | { 60 | delete p; 61 | return false; 62 | } 63 | return true; 64 | } 65 | 66 | // ----------------------------------------------------------------------------------- 67 | 68 | } 69 | 70 | } 71 | 72 | #endif // POSIX 73 | 74 | #endif // DLIB_THREADS_KERNEL_2_CPp_ 75 | 76 | -------------------------------------------------------------------------------- /dlib/test/binary_search_tree_mm1.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BINARY_SEARCH_TREE_KERNEl_TEST_ 4 | #define DLIB_BINARY_SEARCH_TREE_KERNEl_TEST_ 5 | 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include 13 | #include 14 | #include 15 | #include "tester.h" 16 | #include "binary_search_tree.h" 17 | 18 | namespace 19 | { 20 | 21 | class binary_search_tree_tester : public tester 22 | { 23 | struct factory 24 | { 25 | template 26 | struct return_type { 27 | typedef typename memory_manager::kernel_1c type; 28 | }; 29 | 30 | template 31 | static typename return_type::type* get_instance ( 32 | ) 33 | { 34 | static typename return_type::type instance; 35 | return &instance; 36 | } 37 | 38 | }; 39 | 40 | 41 | public: 42 | binary_search_tree_tester ( 43 | ) : 44 | tester ("test_binary_search_tree_mm1", 45 | "Runs tests on the binary_search_tree component with memory managers.") 46 | {} 47 | 48 | void perform_test ( 49 | ) 50 | { 51 | dlog << LINFO << "testing kernel_1a /w memory_manager_global"; 52 | binary_search_tree_kernel_test::kernel_1a>::kernel_1a>(); 54 | print_spinner(); 55 | 56 | 57 | dlog << LINFO << "testing kernel_1a /w memory_manager_stateless"; 58 | binary_search_tree_kernel_test::kernel_1a>::kernel_1a>(); 60 | print_spinner(); 61 | } 62 | } a; 63 | 64 | } 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /dlib/test/md5.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2007 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | #include "tester.h" 12 | 13 | namespace 14 | { 15 | 16 | using namespace test; 17 | using namespace dlib; 18 | using namespace std; 19 | 20 | logger dlog("test.md5"); 21 | 22 | void md5_test ( 23 | ) 24 | /*! 25 | ensures 26 | - runs tests on the md5 stuff compliance with the specs 27 | !*/ 28 | { 29 | 30 | DLIB_TEST(md5 ("") == "d41d8cd98f00b204e9800998ecf8427e"); 31 | DLIB_TEST(md5 ("a") == "0cc175b9c0f1b6a831c399e269772661"); 32 | DLIB_TEST(md5 ("abc") == "900150983cd24fb0d6963f7d28e17f72"); 33 | DLIB_TEST(md5 ("message digest") == "f96b697d7cb7938d525a2f31aaf161d0"); 34 | DLIB_TEST(md5 ("abcdefghijklmnopqrstuvwxyz") == "c3fcd3d76192e4007dfb496cca67e13b"); 35 | DLIB_TEST(md5 ("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789") == "d174ab98d277d9f5a5611c2c9f419d9f"); 36 | DLIB_TEST(md5 ("12345678901234567890123456789012345678901234567890123456789012345678901234567890") == "57edf4a22be3c955ac49da2e2107b67a"); 37 | 38 | // make sure the two versions of md5() always agree 39 | for (int num = 0; num < 2000; ++num) 40 | { 41 | std::string temp; 42 | for (int i = 0; i < num; ++i) 43 | temp += 'a'; 44 | 45 | istringstream str(temp); 46 | DLIB_TEST(md5(temp) == md5(str)); 47 | } 48 | 49 | } 50 | 51 | 52 | class md5_tester : public tester 53 | { 54 | public: 55 | md5_tester ( 56 | ) : 57 | tester ("test_md5", 58 | "Runs tests on the md5 component.") 59 | {} 60 | 61 | void perform_test ( 62 | ) 63 | { 64 | md5_test(); 65 | } 66 | } a; 67 | 68 | } 69 | 70 | 71 | 72 | -------------------------------------------------------------------------------- /dlib/statistics/average_precision.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_AVERAGE_PREcISION_Hh_ 4 | #define DLIB_AVERAGE_PREcISION_Hh_ 5 | 6 | #include "average_precision_abstract.h" 7 | #include 8 | 9 | 10 | namespace dlib 11 | { 12 | namespace impl 13 | { 14 | inline bool get_bool_part ( 15 | const bool& b 16 | ) { return b; } 17 | 18 | template 19 | bool get_bool_part(const std::pair& item) { return item.second; } 20 | } 21 | 22 | // ---------------------------------------------------------------------------------------- 23 | 24 | template 25 | double average_precision ( 26 | const std::vector& items, 27 | unsigned long missing_relevant_items = 0 28 | ) 29 | { 30 | using namespace dlib::impl; 31 | double relevant_count = 0; 32 | // find the precision values 33 | std::vector precision; 34 | for (unsigned long i = 0; i < items.size(); ++i) 35 | { 36 | if (get_bool_part(items[i])) 37 | { 38 | ++relevant_count; 39 | precision.push_back(relevant_count / (i+1)); 40 | } 41 | } 42 | 43 | double precision_sum = 0; 44 | double max_val = 0; 45 | // now sum over the interpolated precision values 46 | for (std::vector::reverse_iterator i = precision.rbegin(); i != precision.rend(); ++i) 47 | { 48 | max_val = std::max(max_val, *i); 49 | precision_sum += max_val; 50 | } 51 | 52 | 53 | relevant_count += missing_relevant_items; 54 | 55 | if (relevant_count != 0) 56 | return precision_sum/relevant_count; 57 | else 58 | return 1; 59 | } 60 | 61 | // ---------------------------------------------------------------------------------------- 62 | 63 | } 64 | 65 | #endif // DLIB_AVERAGE_PREcISION_Hh_ 66 | 67 | -------------------------------------------------------------------------------- /dlib/test/crc32.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2011 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | 12 | #include "tester.h" 13 | 14 | namespace 15 | { 16 | 17 | using namespace test; 18 | using namespace dlib; 19 | using namespace std; 20 | 21 | logger dlog("test.crc32"); 22 | 23 | 24 | class crc32_tester : public tester 25 | { 26 | public: 27 | crc32_tester ( 28 | ) : 29 | tester ("test_crc32", 30 | "Runs tests on the crc32 component.") 31 | {} 32 | 33 | void perform_test ( 34 | ) 35 | { 36 | DLIB_TEST(crc32("davis").get_checksum() == 0x0445527C); 37 | 38 | crc32 c, c2; 39 | DLIB_TEST(c.get_checksum() == 0); 40 | c.add("davis"); 41 | DLIB_TEST(c.get_checksum() == 0x0445527C); 42 | DLIB_TEST(c2.get_checksum() == 0); 43 | c2 = c; 44 | DLIB_TEST(c2.get_checksum() == 0x0445527C); 45 | crc32 c3(c); 46 | DLIB_TEST(c3.get_checksum() == 0x0445527C); 47 | c.add('a'); 48 | c2.add('a'); 49 | c3.add('a'); 50 | DLIB_TEST(c.get_checksum() == 0xB100C606); 51 | DLIB_TEST(c2.get_checksum() == 0xB100C606); 52 | DLIB_TEST(c3.get_checksum() == 0xB100C606); 53 | 54 | 55 | crc32::kernel_1a cold; 56 | DLIB_TEST(cold.get_checksum() == 0); 57 | cold.add("davis"); 58 | DLIB_TEST(cold.get_checksum() == 0x0445527C); 59 | 60 | c.clear(); 61 | DLIB_TEST(c.get_checksum() == 0); 62 | c.add("davis"); 63 | DLIB_TEST(c.get_checksum() == 0x0445527C); 64 | 65 | std::vector buf; 66 | for (int i = 0; i < 4000; ++i) 67 | buf.push_back(i); 68 | DLIB_TEST(crc32(buf) == 492662731); 69 | } 70 | } a; 71 | 72 | } 73 | 74 | 75 | -------------------------------------------------------------------------------- /dlib/image_saver/save_jpeg_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_SAVE_JPEG_ABSTRACT_Hh_ 4 | #ifdef DLIB_SAVE_JPEG_ABSTRACT_Hh_ 5 | 6 | #include "../image_processing/generic_image.h" 7 | #include "../pixel.h" 8 | #include 9 | 10 | namespace dlib 11 | { 12 | 13 | // ---------------------------------------------------------------------------------------- 14 | 15 | template < 16 | typename image_type 17 | > 18 | void save_jpeg ( 19 | const image_type& img, 20 | const std::string& filename, 21 | int quality = 75 22 | ); 23 | /*! 24 | requires 25 | - image_type == an image object that implements the interface defined in 26 | dlib/image_processing/generic_image.h or a matrix expression 27 | - image.size() != 0 28 | - 0 <= quality <= 100 29 | ensures 30 | - writes the image to the file indicated by file_name in the JPEG format. 31 | - image[0][0] will be in the upper left corner of the image. 32 | - image[image.nr()-1][image.nc()-1] will be in the lower right corner of the 33 | image. 34 | - This routine can save images containing any type of pixel. However, 35 | save_jpeg() can only natively store rgb_pixel and uint8 pixel types. All 36 | other pixel types will be converted into one of these types as appropriate 37 | before being saved to disk. 38 | - The quality value determines how lossy the compression is. Larger quality 39 | values result in larger output images but the images will look better. 40 | throws 41 | - image_save_error 42 | This exception is thrown if there is an error that prevents us from saving 43 | the image. 44 | - std::bad_alloc 45 | !*/ 46 | 47 | // ---------------------------------------------------------------------------------------- 48 | 49 | } 50 | 51 | #endif // DLIB_SAVE_JPEG_ABSTRACT_Hh_ 52 | 53 | -------------------------------------------------------------------------------- /dlib/image_processing/render_face_detections_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2014 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_RENDER_FACE_DeTECTIONS_ABSTRACT_H_ 4 | #ifdef DLIB_RENDER_FACE_DeTECTIONS_ABSTRACT_H_ 5 | 6 | #include "full_object_detection_abstract.h" 7 | #include "../gui_widgets.h" 8 | 9 | namespace dlib 10 | { 11 | 12 | // ---------------------------------------------------------------------------------------- 13 | 14 | inline std::vector render_face_detections ( 15 | const std::vector& dets, 16 | const rgb_pixel color = rgb_pixel(0,255,0) 17 | ); 18 | /*! 19 | requires 20 | - for all valid i: 21 | - dets[i].num_parts() == 68 22 | ensures 23 | - Interprets the given objects as face detections with parts annotated using 24 | the iBUG face landmark scheme. We then return a set of overlay lines that 25 | will draw the objects onto the screen in a way that properly draws the 26 | outline of the face features defined by the part locations. 27 | - returns a vector with dets.size() elements, each containing the lines 28 | necessary to render a face detection from dets. 29 | !*/ 30 | 31 | // ---------------------------------------------------------------------------------------- 32 | 33 | inline std::vector render_face_detections ( 34 | const full_object_detection& det, 35 | const rgb_pixel color = rgb_pixel(0,255,0) 36 | ); 37 | /*! 38 | requires 39 | - det.num_parts() == 68 40 | ensures 41 | - This function is identical to the above render_face_detections() routine 42 | except that it takes just a single full_object_detection instead of a 43 | std::vector of them. 44 | !*/ 45 | 46 | // ---------------------------------------------------------------------------------------- 47 | 48 | } 49 | 50 | #endif // DLIB_RENDER_FACE_DeTECTIONS_ABSTRACT_H_ 51 | 52 | 53 | -------------------------------------------------------------------------------- /dlib/queue.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_QUEUe_ 4 | #define DLIB_QUEUe_ 5 | 6 | #include "queue/queue_kernel_1.h" 7 | #include "queue/queue_kernel_2.h" 8 | #include "queue/queue_kernel_c.h" 9 | 10 | #include "queue/queue_sort_1.h" 11 | 12 | 13 | #include "algs.h" 14 | 15 | namespace dlib 16 | { 17 | 18 | template < 19 | typename T, 20 | typename mem_manager = default_memory_manager 21 | > 22 | class queue 23 | { 24 | queue() {} 25 | public: 26 | 27 | 28 | //----------- kernels --------------- 29 | 30 | // kernel_1a 31 | typedef queue_kernel_1 32 | kernel_1a; 33 | typedef queue_kernel_c 34 | kernel_1a_c; 35 | 36 | 37 | // kernel_2a 38 | typedef queue_kernel_2 39 | kernel_2a; 40 | typedef queue_kernel_c 41 | kernel_2a_c; 42 | 43 | 44 | // kernel_2b 45 | typedef queue_kernel_2 46 | kernel_2b; 47 | typedef queue_kernel_c 48 | kernel_2b_c; 49 | 50 | 51 | 52 | 53 | //---------- extensions ------------ 54 | 55 | // sort_1 extend kernel_1a 56 | typedef queue_sort_1 57 | sort_1a; 58 | typedef queue_sort_1 59 | sort_1a_c; 60 | 61 | 62 | // sort_1 extend kernel_2a 63 | typedef queue_sort_1 64 | sort_1b; 65 | typedef queue_sort_1 66 | sort_1b_c; 67 | 68 | 69 | 70 | // sort_1 extend kernel_2b 71 | typedef queue_sort_1 72 | sort_1c; 73 | typedef queue_sort_1 74 | sort_1c_c; 75 | 76 | 77 | 78 | 79 | 80 | }; 81 | } 82 | 83 | #endif // DLIB_QUEUe_ 84 | 85 | -------------------------------------------------------------------------------- /dlib/clustering/bottom_up_cluster_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2015 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_BOTTOM_uP_CLUSTER_ABSTRACT_Hh_ 4 | #ifdef DLIB_BOTTOM_uP_CLUSTER_ABSTRACT_Hh_ 5 | 6 | #include "../matrix.h" 7 | 8 | namespace dlib 9 | { 10 | 11 | // ---------------------------------------------------------------------------------------- 12 | 13 | template < 14 | typename EXP 15 | > 16 | unsigned long bottom_up_cluster ( 17 | const matrix_exp& dists, 18 | std::vector& labels, 19 | unsigned long min_num_clusters, 20 | double max_dist = std::numeric_limits::infinity() 21 | ); 22 | /*! 23 | requires 24 | - dists.nr() == dists.nc() 25 | - min_num_clusters > 0 26 | - dists == trans(dists) 27 | (l.e. dists should be symmetric) 28 | ensures 29 | - Runs a bottom up agglomerative clustering algorithm. 30 | - Interprets dists as a matrix that gives the distances between dists.nr() 31 | items. In particular, we take dists(i,j) to be the distance between the ith 32 | and jth element of some set. This function clusters the elements of this set 33 | into at least min_num_clusters (or dists.nr() if there aren't enough 34 | elements). Additionally, within each cluster, the maximum pairwise distance 35 | between any two cluster elements is <= max_dist. 36 | - returns the number of clusters found. 37 | - #labels.size() == dists.nr() 38 | - for all valid i: 39 | - #labels[i] == the cluster ID of the node with index i (i.e. the node 40 | corresponding to the distances dists(i,*)). 41 | - 0 <= #labels[i] < the number of clusters found 42 | (i.e. cluster IDs are assigned contiguously and start at 0) 43 | !*/ 44 | 45 | // ---------------------------------------------------------------------------------------- 46 | 47 | } 48 | 49 | #endif // DLIB_BOTTOM_uP_CLUSTER_ABSTRACT_Hh_ 50 | 51 | 52 | -------------------------------------------------------------------------------- /dlib/external/zlib/uncompr.c: -------------------------------------------------------------------------------- 1 | /* uncompr.c -- decompress a memory buffer 2 | * Copyright (C) 1995-2003, 2010 Jean-loup Gailly. 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | /* @(#) $Id$ */ 7 | 8 | #define ZLIB_INTERNAL 9 | #include "zlib.h" 10 | 11 | /* =========================================================================== 12 | Decompresses the source buffer into the destination buffer. sourceLen is 13 | the byte length of the source buffer. Upon entry, destLen is the total 14 | size of the destination buffer, which must be large enough to hold the 15 | entire uncompressed data. (The size of the uncompressed data must have 16 | been saved previously by the compressor and transmitted to the decompressor 17 | by some mechanism outside the scope of this compression library.) 18 | Upon exit, destLen is the actual size of the compressed buffer. 19 | 20 | uncompress returns Z_OK if success, Z_MEM_ERROR if there was not 21 | enough memory, Z_BUF_ERROR if there was not enough room in the output 22 | buffer, or Z_DATA_ERROR if the input data was corrupted. 23 | */ 24 | int ZEXPORT uncompress (dest, destLen, source, sourceLen) 25 | Bytef *dest; 26 | uLongf *destLen; 27 | const Bytef *source; 28 | uLong sourceLen; 29 | { 30 | z_stream stream; 31 | int err; 32 | 33 | stream.next_in = (z_const Bytef *)source; 34 | stream.avail_in = (uInt)sourceLen; 35 | /* Check for source > 64K on 16-bit machine: */ 36 | if ((uLong)stream.avail_in != sourceLen) return Z_BUF_ERROR; 37 | 38 | stream.next_out = dest; 39 | stream.avail_out = (uInt)*destLen; 40 | if ((uLong)stream.avail_out != *destLen) return Z_BUF_ERROR; 41 | 42 | stream.zalloc = (alloc_func)0; 43 | stream.zfree = (free_func)0; 44 | 45 | err = inflateInit(&stream); 46 | if (err != Z_OK) return err; 47 | 48 | err = inflate(&stream, Z_FINISH); 49 | if (err != Z_STREAM_END) { 50 | inflateEnd(&stream); 51 | if (err == Z_NEED_DICT || (err == Z_BUF_ERROR && stream.avail_in == 0)) 52 | return Z_DATA_ERROR; 53 | return err; 54 | } 55 | *destLen = stream.total_out; 56 | 57 | err = inflateEnd(&stream); 58 | return err; 59 | } 60 | -------------------------------------------------------------------------------- /dlib/interfaces/map_pair.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MAP_PAIr_INTERFACE_ 4 | #define DLIB_MAP_PAIr_INTERFACE_ 5 | 6 | namespace dlib 7 | { 8 | 9 | // ---------------------------------------------------------------------------------------- 10 | 11 | template < 12 | typename T1, 13 | typename T2 14 | > 15 | class map_pair 16 | { 17 | /*! 18 | POINTERS AND REFERENCES TO INTERNAL DATA 19 | None of the functions in map_pair will invalidate 20 | pointers or references to internal data when called. 21 | 22 | WHAT THIS OBJECT REPRESENTS 23 | this object is used to return the key/value pair used in the 24 | map and hash_map containers when using the enumerable interface. 25 | 26 | note that the enumerable interface is defined in 27 | interfaces/enumerable.h 28 | !*/ 29 | 30 | public: 31 | typedef T1 key_type; 32 | typedef T2 value_type; 33 | 34 | virtual ~map_pair( 35 | )=0; 36 | 37 | virtual const T1& key( 38 | ) const =0; 39 | /*! 40 | ensures 41 | - returns a const reference to the key 42 | !*/ 43 | 44 | virtual const T2& value( 45 | ) const =0; 46 | /*! 47 | ensures 48 | - returns a const reference to the value associated with key 49 | !*/ 50 | 51 | virtual T2& value( 52 | )=0; 53 | /*! 54 | ensures 55 | - returns a non-const reference to the value associated with key 56 | !*/ 57 | 58 | protected: 59 | 60 | // restricted functions 61 | map_pair& operator=(const map_pair&) {return *this;} // no assignment operator 62 | 63 | }; 64 | 65 | // destructor does nothing 66 | template 67 | map_pair::~map_pair () {} 68 | 69 | // ---------------------------------------------------------------------------------------- 70 | 71 | } 72 | 73 | #endif // DLIB_MAP_PAIr_INTERFACE_ 74 | 75 | -------------------------------------------------------------------------------- /dlib/svm/multiclass_tools.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2010 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MULTICLASS_TOoLS_Hh_ 4 | #define DLIB_MULTICLASS_TOoLS_Hh_ 5 | 6 | #include "multiclass_tools_abstract.h" 7 | 8 | #include 9 | #include 10 | #include "../unordered_pair.h" 11 | 12 | namespace dlib 13 | { 14 | 15 | // ---------------------------------------------------------------------------------------- 16 | 17 | template 18 | std::vector select_all_distinct_labels ( 19 | const std::vector& labels 20 | ) 21 | { 22 | std::set temp; 23 | temp.insert(labels.begin(), labels.end()); 24 | return std::vector(temp.begin(), temp.end()); 25 | } 26 | 27 | // ---------------------------------------------------------------------------------------- 28 | 29 | template 30 | std::vector > find_missing_pairs ( 31 | const std::map,U>& bdfs 32 | ) 33 | { 34 | typedef std::map,U> map_type; 35 | 36 | // find all the labels 37 | std::set temp; 38 | for (typename map_type::const_iterator i = bdfs.begin(); i != bdfs.end(); ++i) 39 | { 40 | temp.insert(i->first.first); 41 | temp.insert(i->first.second); 42 | } 43 | 44 | std::vector > missing_pairs; 45 | 46 | // now make sure all label pairs are present 47 | typename std::set::const_iterator i, j; 48 | for (i = temp.begin(); i != temp.end(); ++i) 49 | { 50 | for (j = i, ++j; j != temp.end(); ++j) 51 | { 52 | const unordered_pair p(*i, *j); 53 | 54 | if (bdfs.count(p) == 0) 55 | missing_pairs.push_back(p); 56 | } 57 | } 58 | 59 | return missing_pairs; 60 | } 61 | 62 | // ---------------------------------------------------------------------------------------- 63 | 64 | } 65 | 66 | #endif // DLIB_MULTICLASS_TOoLS_Hh_ 67 | 68 | 69 | -------------------------------------------------------------------------------- /dlib/threads/threads_kernel_1.cpp: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_THREADS_KERNEL_1_CPp_ 4 | #define DLIB_THREADS_KERNEL_1_CPp_ 5 | 6 | #include "../platform.h" 7 | 8 | #ifdef WIN32 9 | 10 | #include "threads_kernel_1.h" 11 | 12 | #include 13 | 14 | 15 | namespace dlib 16 | { 17 | namespace threads_kernel_shared_helpers 18 | { 19 | 20 | // ----------------------------------------------------------------------------------- 21 | 22 | struct info 23 | { 24 | void* param; 25 | void (*funct)(void*); 26 | }; 27 | 28 | // ----------------------------------------------------------------------------------- 29 | 30 | unsigned int __stdcall thread_starter ( 31 | void* param 32 | ) 33 | { 34 | info* alloc_p = static_cast(param); 35 | info p = *alloc_p; 36 | delete alloc_p; 37 | 38 | p.funct(p.param); 39 | return 0; 40 | } 41 | 42 | // ----------------------------------------------------------------------------------- 43 | 44 | bool spawn_thread ( 45 | void (*funct)(void*), 46 | void* param 47 | ) 48 | { 49 | info* p; 50 | try { p = new info; } 51 | catch (...) { return false; } 52 | 53 | p->funct = funct; 54 | p->param = param; 55 | 56 | 57 | unsigned int garbage; 58 | 59 | HANDLE thandle = (HANDLE)_beginthreadex (NULL,0,thread_starter,p,0,&garbage); 60 | // make thread and add it to the pool 61 | 62 | // return false if _beginthreadex didn't work 63 | if ( thandle == 0) 64 | { 65 | delete p; 66 | return false; 67 | } 68 | 69 | // throw away the thread handle 70 | CloseHandle(thandle); 71 | return true; 72 | } 73 | 74 | // ----------------------------------------------------------------------------------- 75 | 76 | } 77 | 78 | } 79 | 80 | #endif // WIN32 81 | 82 | #endif // DLIB_THREADS_KERNEL_1_CPp_ 83 | 84 | -------------------------------------------------------------------------------- /dlib/misc_api/misc_api_kernel_2.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MISC_API_KERNEl_2_ 4 | #define DLIB_MISC_API_KERNEl_2_ 5 | 6 | #ifdef DLIB_ISO_CPP_ONLY 7 | #error "DLIB_ISO_CPP_ONLY is defined so you can't use this OS dependent code. Turn DLIB_ISO_CPP_ONLY off if you want to use it." 8 | #endif 9 | 10 | 11 | #include "misc_api_kernel_abstract.h" 12 | #include "../algs.h" 13 | #include 14 | #include "../uintn.h" 15 | 16 | namespace dlib 17 | { 18 | 19 | // ---------------------------------------------------------------------------------------- 20 | 21 | void sleep ( 22 | unsigned long milliseconds 23 | ); 24 | 25 | // ---------------------------------------------------------------------------------------- 26 | 27 | std::string get_current_dir ( 28 | ); 29 | 30 | // ---------------------------------------------------------------------------------------- 31 | 32 | class set_current_dir_error : public error 33 | { 34 | public: 35 | set_current_dir_error( 36 | const std::string& a 37 | ): error(a) {} 38 | }; 39 | 40 | void set_current_dir ( 41 | const std::string& new_dir 42 | ); 43 | 44 | // ---------------------------------------------------------------------------------------- 45 | 46 | class timestamper 47 | { 48 | public: 49 | uint64 get_timestamp ( 50 | ) const; 51 | }; 52 | 53 | // ---------------------------------------------------------------------------------------- 54 | 55 | class dir_create_error : public error 56 | { 57 | public: 58 | dir_create_error( 59 | const std::string& dir_name 60 | ) : 61 | error(EDIR_CREATE,"Error creating directory '" + dir_name + "'."), 62 | name(dir_name) 63 | {} 64 | const std::string& name; 65 | }; 66 | 67 | 68 | void create_directory ( 69 | const std::string& dir 70 | ); 71 | 72 | // ---------------------------------------------------------------------------------------- 73 | 74 | } 75 | 76 | #ifdef NO_MAKEFILE 77 | #include "misc_api_kernel_2.cpp" 78 | #endif 79 | 80 | #endif // DLIB_MISC_API_KERNEl_2_ 81 | 82 | -------------------------------------------------------------------------------- /dlib/sequence.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_SEQUENCe_ 4 | #define DLIB_SEQUENCe_ 5 | 6 | #include "sequence/sequence_kernel_1.h" 7 | #include "sequence/sequence_kernel_2.h" 8 | #include "sequence/sequence_kernel_c.h" 9 | 10 | #include "sequence/sequence_compare_1.h" 11 | #include "sequence/sequence_sort_1.h" 12 | #include "sequence/sequence_sort_2.h" 13 | #include "algs.h" 14 | 15 | 16 | 17 | 18 | namespace dlib 19 | { 20 | 21 | template < 22 | typename T, 23 | typename mem_manager = default_memory_manager 24 | > 25 | class sequence 26 | { 27 | 28 | sequence() {} 29 | public: 30 | 31 | //----------- kernels --------------- 32 | 33 | // kernel_1a 34 | typedef sequence_kernel_1 35 | kernel_1a; 36 | typedef sequence_kernel_c 37 | kernel_1a_c; 38 | 39 | // kernel_2a 40 | typedef sequence_kernel_2 41 | kernel_2a; 42 | typedef sequence_kernel_c 43 | kernel_2a_c; 44 | 45 | 46 | //---------- extensions ------------ 47 | 48 | // compare_1 extend kernel_1a 49 | typedef sequence_compare_1 50 | compare_1a; 51 | typedef sequence_compare_1 52 | compare_1a_c; 53 | 54 | // compare_1 extend kernel_2a 55 | typedef sequence_compare_1 56 | compare_1b; 57 | typedef sequence_compare_1 58 | compare_1b_c; 59 | 60 | 61 | 62 | // sort_1 extend kernel_2a 63 | typedef sequence_sort_1 64 | sort_1a; 65 | typedef sequence_sort_1 66 | sort_1a_c; 67 | 68 | // sort_2 extend kernel_1a 69 | typedef sequence_sort_2 70 | sort_2a; 71 | typedef sequence_sort_2 72 | sort_2a_c; 73 | 74 | 75 | 76 | 77 | 78 | 79 | }; 80 | } 81 | 82 | #endif // DLIB_SEQUENCe_ 83 | 84 | -------------------------------------------------------------------------------- /dlib/entropy_encoder_model/entropy_encoder_model_kernel_c.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2004 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_ENTROPY_ENCODER_MODEL_KERNEl_C_ 4 | #define DLIB_ENTROPY_ENCODER_MODEL_KERNEl_C_ 5 | 6 | #include "entropy_encoder_model_kernel_abstract.h" 7 | #include "../algs.h" 8 | #include "../assert.h" 9 | #include 10 | 11 | namespace dlib 12 | { 13 | 14 | template < 15 | typename eem_base 16 | > 17 | class entropy_encoder_model_kernel_c : public eem_base 18 | { 19 | const unsigned long alphabet_size; 20 | typedef typename eem_base::entropy_encoder_type entropy_encoder; 21 | 22 | public: 23 | 24 | entropy_encoder_model_kernel_c ( 25 | entropy_encoder& coder 26 | ) : eem_base(coder), alphabet_size(eem_base::get_alphabet_size()) {} 27 | 28 | void encode ( 29 | unsigned long symbol 30 | ); 31 | }; 32 | 33 | // ---------------------------------------------------------------------------------------- 34 | // ---------------------------------------------------------------------------------------- 35 | // member function definitions 36 | // ---------------------------------------------------------------------------------------- 37 | // ---------------------------------------------------------------------------------------- 38 | 39 | template < 40 | typename eem_base 41 | > 42 | void entropy_encoder_model_kernel_c:: 43 | encode ( 44 | unsigned long symbol 45 | ) 46 | { 47 | // make sure requires clause is not broken 48 | DLIB_CASSERT(symbol < alphabet_size, 49 | "\tvoid entropy_encoder_model::encode()" 50 | << "\n\tthe symbol must be in the range 0 to alphabet_size-1" 51 | << "\n\talphabet_size: " << alphabet_size 52 | << "\n\tsymbol: " << symbol 53 | << "\n\tthis: " << this 54 | ); 55 | 56 | // call the real function 57 | eem_base::encode(symbol); 58 | } 59 | 60 | // ---------------------------------------------------------------------------------------- 61 | 62 | } 63 | 64 | #endif // DLIB_ENTROPY_ENCODER_MODEL_KERNEl_C_ 65 | 66 | -------------------------------------------------------------------------------- /dlib/sequence/sequence_compare_abstract.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #undef DLIB_SEQUENCE_COMPARe_ABSTRACT_ 4 | #ifdef DLIB_SEQUENCE_COMPARe_ABSTRACT_ 5 | 6 | #include "sequence_kernel_abstract.h" 7 | 8 | #include "../algs.h" 9 | 10 | 11 | namespace dlib 12 | { 13 | 14 | template < 15 | typename seq_base 16 | > 17 | class sequence_compare : public seq_base 18 | { 19 | 20 | /*! 21 | REQUIREMENTS ON T 22 | T must implement operator< for its type and 23 | T must implement operator== for its type 24 | 25 | REQUIREMENTS ON SEQUENCE_BASE 26 | must be an implementation of sequence/sequence_kernel_abstract.h 27 | 28 | 29 | POINTERS AND REFERENCES TO INTERNAL DATA 30 | operator== and operator< do not invalidate pointers or references to 31 | data members 32 | 33 | WHAT THIS EXTENSION DOES FOR sequence 34 | This gives a sequence the ability to compare itself to other 35 | sequences using the < and == operators. 36 | !*/ 37 | 38 | public: 39 | 40 | bool operator< ( 41 | const sequence_compare& rhs 42 | ) const; 43 | /*! 44 | ensures 45 | - returns true if there exists an integer j such that 0 <= j < size() 46 | and for all integers i such that 0 <= i < j where it is true that 47 | (*this)[i] <= rhs[i] and (*this)[j] < rhs[j] 48 | - returns false if there is no j that will satisfy the above conditions 49 | !*/ 50 | 51 | bool operator== ( 52 | const sequence_compare& rhs 53 | ) const; 54 | /*! 55 | ensures 56 | - returns true if for all i: (*this)[i] == rhs[i] else returns false 57 | !*/ 58 | 59 | }; 60 | 61 | template < 62 | typename seq_base 63 | > 64 | inline void swap ( 65 | sequence_compare& a, 66 | sequence_compare& b 67 | ) { a.swap(b); } 68 | /*! 69 | provides a global swap function 70 | !*/ 71 | 72 | } 73 | 74 | #endif // DLIB_SEQUENCE_COMPARe_ABSTRACT_ 75 | 76 | -------------------------------------------------------------------------------- /dlib/memory_manager.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2003 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MEMORY_MANAGEr_ 4 | #define DLIB_MEMORY_MANAGEr_ 5 | 6 | #include "memory_manager/memory_manager_kernel_1.h" 7 | #include "memory_manager/memory_manager_kernel_2.h" 8 | #include "memory_manager/memory_manager_kernel_3.h" 9 | 10 | 11 | 12 | namespace dlib 13 | { 14 | 15 | template < 16 | typename T 17 | > 18 | class memory_manager 19 | { 20 | memory_manager() {} 21 | 22 | 23 | public: 24 | 25 | //----------- kernels --------------- 26 | 27 | // kernel_1 28 | typedef memory_manager_kernel_1 29 | kernel_1a; 30 | typedef memory_manager_kernel_1 31 | kernel_1b; 32 | typedef memory_manager_kernel_1 33 | kernel_1c; 34 | typedef memory_manager_kernel_1 35 | kernel_1d; 36 | typedef memory_manager_kernel_1 37 | kernel_1e; 38 | typedef memory_manager_kernel_1 39 | kernel_1f; 40 | 41 | // kernel_2 42 | typedef memory_manager_kernel_2 43 | kernel_2a; 44 | typedef memory_manager_kernel_2 45 | kernel_2b; 46 | typedef memory_manager_kernel_2 47 | kernel_2c; 48 | typedef memory_manager_kernel_2 49 | kernel_2d; 50 | typedef memory_manager_kernel_2 51 | kernel_2e; 52 | 53 | 54 | // kernel_3 55 | typedef memory_manager_kernel_3 56 | kernel_3a; 57 | typedef memory_manager_kernel_3 58 | kernel_3b; 59 | typedef memory_manager_kernel_3 60 | kernel_3c; 61 | typedef memory_manager_kernel_3 62 | kernel_3d; 63 | typedef memory_manager_kernel_3 64 | kernel_3e; 65 | 66 | 67 | 68 | 69 | }; 70 | } 71 | 72 | #endif // DLIB_MEMORY_MANAGEr_ 73 | 74 | -------------------------------------------------------------------------------- /dlib/python/boost_python_utils.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2013 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_BOOST_PYTHON_UtILS_Hh_ 4 | #define DLIB_BOOST_PYTHON_UtILS_Hh_ 5 | 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | inline bool hasattr( 12 | boost::python::object obj, 13 | const std::string& attr_name 14 | ) 15 | /*! 16 | ensures 17 | - if (obj has an attribute named attr_name) then 18 | - returns true 19 | - else 20 | - returns false 21 | !*/ 22 | { 23 | return PyObject_HasAttrString(obj.ptr(), attr_name.c_str()); 24 | } 25 | 26 | // ---------------------------------------------------------------------------------------- 27 | 28 | template 29 | std::vector python_list_to_vector ( 30 | const boost::python::object& obj 31 | ) 32 | /*! 33 | ensures 34 | - converts a python object into a std::vector and returns it. 35 | !*/ 36 | { 37 | std::vector vect(len(obj)); 38 | for (unsigned long i = 0; i < vect.size(); ++i) 39 | { 40 | vect[i] = boost::python::extract(obj[i]); 41 | } 42 | return vect; 43 | } 44 | 45 | template 46 | boost::python::list vector_to_python_list ( 47 | const std::vector& vect 48 | ) 49 | /*! 50 | ensures 51 | - converts a std::vector into a python list object. 52 | !*/ 53 | { 54 | boost::python::list obj; 55 | for (unsigned long i = 0; i < vect.size(); ++i) 56 | obj.append(vect[i]); 57 | return obj; 58 | } 59 | 60 | // ---------------------------------------------------------------------------------------- 61 | 62 | template 63 | boost::shared_ptr load_object_from_file ( 64 | const std::string& filename 65 | ) 66 | /*! 67 | ensures 68 | - deserializes an object of type T from the given file and returns it. 69 | !*/ 70 | { 71 | std::ifstream fin(filename.c_str(), std::ios::binary); 72 | if (!fin) 73 | throw dlib::error("Unable to open " + filename); 74 | boost::shared_ptr obj(new T()); 75 | deserialize(*obj, fin); 76 | return obj; 77 | } 78 | 79 | // ---------------------------------------------------------------------------------------- 80 | 81 | 82 | #endif // DLIB_BOOST_PYTHON_UtILS_Hh_ 83 | 84 | -------------------------------------------------------------------------------- /dlib/memory_manager_stateless/memory_manager_stateless_kernel_1.h: -------------------------------------------------------------------------------- 1 | // Copyright (C) 2006 Davis E. King (davis@dlib.net) 2 | // License: Boost Software License See LICENSE.txt for the full license. 3 | #ifndef DLIB_MEMORY_MANAGER_STATELESs_1_ 4 | #define DLIB_MEMORY_MANAGER_STATELESs_1_ 5 | 6 | #include "memory_manager_stateless_kernel_abstract.h" 7 | 8 | namespace dlib 9 | { 10 | template < 11 | typename T 12 | > 13 | class memory_manager_stateless_kernel_1 14 | { 15 | /*! 16 | this implementation just calls new and delete directly 17 | !*/ 18 | 19 | public: 20 | 21 | typedef T type; 22 | const static bool is_stateless = true; 23 | 24 | template 25 | struct rebind { 26 | typedef memory_manager_stateless_kernel_1 other; 27 | }; 28 | 29 | memory_manager_stateless_kernel_1( 30 | ) 31 | {} 32 | 33 | virtual ~memory_manager_stateless_kernel_1( 34 | ) {} 35 | 36 | T* allocate ( 37 | ) 38 | { 39 | return new T; 40 | } 41 | 42 | void deallocate ( 43 | T* item 44 | ) 45 | { 46 | delete item; 47 | } 48 | 49 | T* allocate_array ( 50 | unsigned long size 51 | ) 52 | { 53 | return new T[size]; 54 | } 55 | 56 | void deallocate_array ( 57 | T* item 58 | ) 59 | { 60 | delete [] item; 61 | } 62 | 63 | void swap (memory_manager_stateless_kernel_1&) 64 | {} 65 | 66 | private: 67 | 68 | // restricted functions 69 | memory_manager_stateless_kernel_1(memory_manager_stateless_kernel_1&); // copy constructor 70 | memory_manager_stateless_kernel_1& operator=(memory_manager_stateless_kernel_1&); // assignment operator 71 | }; 72 | 73 | template < 74 | typename T 75 | > 76 | inline void swap ( 77 | memory_manager_stateless_kernel_1& a, 78 | memory_manager_stateless_kernel_1& b 79 | ) { a.swap(b); } 80 | 81 | } 82 | 83 | #endif // DLIB_MEMORY_MANAGER_STATELESs_1_ 84 | 85 | 86 | 87 | --------------------------------------------------------------------------------