Aging_MouthReplace / dlibs /docs /examples /CMakeLists.txt.html
AshanGimhana's picture
Upload folder using huggingface_hub
9375c9a verified
<html><head><title>
examples/CMakeLists.txt
</title></head><body bgcolor='white'><pre>
<font color='#009900'>#</font>
<font color='#009900'># _______ _ _ _____ _____ _____ _____ </font>
<font color='#009900'># |__ __| | | |_ _|/ ____| |_ _|/ ____| /\ </font>
<font color='#009900'># | | | |__| | | | | (___ | | | (___ / \ </font>
<font color='#009900'># | | | __ | | | \___ \ | | \___ \ / /\ \ </font>
<font color='#009900'># | | | | | |_| |_ ____) | _| |_ ____) | / ____ \ </font>
<font color='#009900'># |_|__|_|_ |_|_____|_____/__ |_____|_____/ /_/ _ \_\ </font>
<font color='#009900'># |__ __| | | |__ __/ __ \| __ \|_ _| /\ | | </font>
<font color='#009900'># | | | | | | | | | | | | |__) | | | / \ | | </font>
<font color='#009900'># | | | | | | | | | | | | _ / | | / /\ \ | | </font>
<font color='#009900'># | | | |__| | | | | |__| | | \ \ _| |_ / ____ \| |____ </font>
<font color='#009900'># |_| \____/ |_| \____/|_| \_\_____/_/ \_\______| </font>
<font color='#009900'>#</font>
<font color='#009900'>#</font>
<font color='#009900'># _____ ______ _____ _______ _ _ ______ </font>
<font color='#009900'># | __ \| ____| /\ | __ \ |__ __| | | | ____| </font>
<font color='#009900'># | |__) | |__ / \ | | | | | | | |__| | |__ </font>
<font color='#009900'># | _ /| __| / /\ \ | | | | | | | __ | __| </font>
<font color='#009900'># | | \ \| |____ / ____ \| |__| | | | | | | | |____ </font>
<font color='#009900'># |_|__\_\______/_/_ __\_\_____/__ _ |_|__|_|_ |_|______|_ _ _ </font>
<font color='#009900'># / ____/ __ \| \/ | \/ | ____| \ | |__ __/ ____| | | | | |</font>
<font color='#009900'># | | | | | | \ / | \ / | |__ | \| | | | | (___ | | | | |</font>
<font color='#009900'># | | | | | | |\/| | |\/| | __| | . ` | | | \___ \ | | | | |</font>
<font color='#009900'># | |___| |__| | | | | | | | |____| |\ | | | ____) | |_|_|_|_|</font>
<font color='#009900'># \_____\____/|_| |_|_| |_|______|_| \_| |_| |_____/ (_|_|_|_)</font>
<font color='#009900'># </font>
<font color='#009900'>#</font>
<font color='#009900'>#</font>
<font color='#009900'># This is a CMake makefile. CMake is a tool that helps you build C++ programs.</font>
<font color='#009900'># You can download CMake from http://www.cmake.org. This CMakeLists.txt file</font>
<font color='#009900'># you are reading builds dlib's example programs. </font>
<font color='#009900'>#</font>
<font color='blue'>cmake_minimum_required</font>(VERSION 2.8.12)
<font color='#009900'># Every project needs a name. We call this the "<font color='#CC0000'>examples</font>" project.</font>
<font color='blue'>project</font>(examples)
<font color='#009900'># Tell cmake we will need dlib. This command will pull in dlib and compile it</font>
<font color='#009900'># into your project. Note that you don't need to compile or install dlib. All</font>
<font color='#009900'># cmake needs is the dlib source code folder and it will take care of everything.</font>
<font color='blue'>add_subdirectory</font>(../dlib <a href='../dlib/CMakeLists.txt.html'>dlib_build</a>)
<font color='#009900'># If you have cmake 3.14 or newer you can even use FetchContent instead of</font>
<font color='#009900'># add_subdirectory() <a href=')/CMakeLists.txt.html'>to</a> pull in dlib as a dependency. So instead of using the</font>
<font color='#009900'># above add_subdirectory() <a href=')/CMakeLists.txt.html'>command,</a> you could use the following three commands</font>
<font color='#009900'># to make dlib available:</font>
<font color='#009900'># include(FetchContent)</font>
<font color='#009900'># FetchContent_Declare(dlib</font>
<font color='#009900'># GIT_REPOSITORY https://github.com/davisking/dlib.git</font>
<font color='#009900'># GIT_TAG v19.18</font>
<font color='#009900'># )</font>
<font color='#009900'># FetchContent_MakeAvailable(dlib)</font>
<font color='#009900'># The next thing we need to do is tell CMake about the code you want to</font>
<font color='#009900'># compile. We do this with the add_executable() statement which takes the name</font>
<font color='#009900'># of the output executable and then a list of .cpp files to compile. Here we</font>
<font color='#009900'># are going to compile one of the dlib example programs which has only one .cpp</font>
<font color='#009900'># file, assignment_learning_ex.cpp. If your program consisted of multiple .cpp</font>
<font color='#009900'># files you would simply list them here in the add_executable() statement. </font>
<font color='blue'>add_executable</font>(assignment_learning_ex assignment_learning_ex.cpp)
<font color='#009900'># Finally, you need to tell CMake that this program, assignment_learning_ex,</font>
<font color='#009900'># depends on dlib. You do that with this statement: </font>
<font color='blue'>target_link_libraries</font>(assignment_learning_ex dlib::dlib)
<font color='#009900'># To compile this program all you need to do is ask cmake. You would type</font>
<font color='#009900'># these commands from within the directory containing this CMakeLists.txt</font>
<font color='#009900'># file:</font>
<font color='#009900'># mkdir build</font>
<font color='#009900'># cd build</font>
<font color='#009900'># cmake ..</font>
<font color='#009900'># cmake --build . --config Release</font>
<font color='#009900'>#</font>
<font color='#009900'># The cmake .. command looks in the parent folder for a file named</font>
<font color='#009900'># CMakeLists.txt, reads it, and sets up everything needed to build program.</font>
<font color='#009900'># Also, note that CMake can generate Visual Studio or XCode project files. So</font>
<font color='#009900'># if instead you had written:</font>
<font color='#009900'># cd build</font>
<font color='#009900'># cmake .. -G Xcode</font>
<font color='#009900'>#</font>
<font color='#009900'># You would be able to open the resulting Xcode project and compile and edit</font>
<font color='#009900'># the example programs within the Xcode IDE. CMake can generate a lot of</font>
<font color='#009900'># different types of IDE projects. Run the cmake -h command to see a list of</font>
<font color='#009900'># arguments to -G to see what kinds of projects cmake can generate for you. It</font>
<font color='#009900'># probably includes your favorite IDE in the list.</font>
<font color='#009900'>#################################################################################</font>
<font color='#009900'>#################################################################################</font>
<font color='#009900'># A CMakeLists.txt file can compile more than just one program. So below we</font>
<font color='#009900'># tell it to compile the other dlib example programs using pretty much the</font>
<font color='#009900'># same CMake commands we used above.</font>
<font color='#009900'>#################################################################################</font>
<font color='#009900'>#################################################################################</font>
<font color='#009900'># Since there are a lot of examples I'm going to use a macro to simplify this</font>
<font color='#009900'># CMakeLists.txt file. However, usually you will create only one executable in</font>
<font color='#009900'># your cmake projects and use the syntax shown above.</font>
<font color='blue'>macro</font>(add_example name)
<font color='blue'> add_executable</font>(${<font color='#BB00BB'>name</font>} ${<font color='#BB00BB'>name</font>}.cpp)
<font color='blue'> target_link_libraries</font>(${<font color='#BB00BB'>name</font>} dlib::dlib )
<font color='blue'>endmacro</font>()
<font color='#009900'># if an example requires GUI, call this macro to check DLIB_NO_GUI_SUPPORT to include or exclude</font>
<font color='blue'>macro</font>(add_gui_example name)
<font color='blue'> if </font>(DLIB_NO_GUI_SUPPORT)
<font color='blue'> message</font>("<font color='#CC0000'>No GUI support, so we won't build the ${<font color='#BB00BB'>name</font>} example.</font>")
<font color='blue'> else</font>()
<font color='blue'> add_example</font>(${<font color='#BB00BB'>name</font>})
<font color='blue'> endif</font>()
<font color='blue'>endmacro</font>()
<font color='#009900'># The deep learning toolkit requires a compiler with essentially complete C++11</font>
<font color='#009900'># support. However, versions of Visual Studio prior to October 2016 didn't</font>
<font color='#009900'># provide enough C++11 support to compile the DNN tooling, but were good enough</font>
<font color='#009900'># to compile the rest of dlib. So new versions of Visual Studio 2015 will</font>
<font color='#009900'># work. However, Visual Studio 2017 had some C++11 support regressions, so it</font>
<font color='#009900'># wasn't until December 2017 that Visual Studio 2017 had good enough C++11</font>
<font color='#009900'># support to compile the DNN examples. So if you are using Visual Studio, make</font>
<font color='#009900'># sure you have an updated version if you want to compile the DNN code.</font>
<font color='#009900'>#</font>
<font color='#009900'># Also note that Visual Studio users should give the -T host=x64 option so that</font>
<font color='#009900'># CMake will instruct Visual Studio to use its 64bit toolchain. If you don't</font>
<font color='#009900'># do this then by default Visual Studio uses a 32bit toolchain, WHICH RESTRICTS</font>
<font color='#009900'># THE COMPILER TO ONLY 2GB OF RAM, causing it to run out of RAM and crash when</font>
<font color='#009900'># compiling some of the DNN examples. So generate your project with a statement</font>
<font color='#009900'># like this:</font>
<font color='#009900'># cmake .. -G "<font color='#CC0000'>Visual Studio 14 2015 Win64</font>" -T host=x64 </font>
<font color='blue'>if </font>(NOT USING_OLD_VISUAL_STUDIO_COMPILER)
<font color='blue'> add_example</font>(dnn_metric_learning_ex)
<font color='blue'> add_gui_example</font>(dnn_face_recognition_ex)
<font color='blue'> add_example</font>(dnn_introduction_ex)
<font color='blue'> add_example</font>(dnn_introduction2_ex)
<font color='blue'> add_example</font>(dnn_introduction3_ex)
<font color='blue'> add_example</font>(dnn_inception_ex)
<font color='blue'> add_gui_example</font>(dnn_mmod_ex)
<font color='blue'> add_gui_example</font>(dnn_mmod_face_detection_ex)
<font color='blue'> add_gui_example</font>(random_cropper_ex)
<font color='blue'> add_gui_example</font>(dnn_mmod_dog_hipsterizer)
<font color='blue'> add_gui_example</font>(dnn_imagenet_ex)
<font color='blue'> add_gui_example</font>(dnn_mmod_find_cars_ex)
<font color='blue'> add_gui_example</font>(dnn_mmod_find_cars2_ex)
<font color='blue'> add_example</font>(dnn_mmod_train_find_cars_ex)
<font color='blue'> add_gui_example</font>(dnn_semantic_segmentation_ex)
<font color='blue'> add_gui_example</font>(dnn_instance_segmentation_ex)
<font color='blue'> add_example</font>(dnn_imagenet_train_ex)
<font color='blue'> add_example</font>(dnn_semantic_segmentation_train_ex)
<font color='blue'> add_example</font>(dnn_instance_segmentation_train_ex)
<font color='blue'> add_example</font>(dnn_metric_learning_on_images_ex)
<font color='blue'> add_gui_example</font>(dnn_dcgan_train_ex)
<font color='blue'>endif</font>()
<font color='blue'>if </font>(DLIB_NO_GUI_SUPPORT)
<font color='blue'> message</font>("<font color='#CC0000'>No GUI support, so we won't build the webcam_face_pose_ex example.</font>")
<font color='blue'>else</font>()
<font color='blue'> find_package</font>(OpenCV QUIET)
<font color='blue'> if </font>(OpenCV_FOUND)
<font color='blue'> include_directories</font>(${<font color='#BB00BB'>OpenCV_INCLUDE_DIRS</font>})
<font color='blue'> add_executable</font>(webcam_face_pose_ex webcam_face_pose_ex.cpp)
<font color='blue'> target_link_libraries</font>(webcam_face_pose_ex dlib::dlib ${<font color='#BB00BB'>OpenCV_LIBS</font>} )
<font color='blue'> else</font>()
<font color='blue'> message</font>("<font color='#CC0000'>OpenCV not found, so we won't build the webcam_face_pose_ex example.</font>")
<font color='blue'> endif</font>()
<font color='blue'>endif</font>()
<font color='#009900'>#here we apply our macros </font>
<font color='blue'>add_gui_example</font>(3d_point_cloud_ex)
<font color='blue'>add_example</font>(bayes_net_ex)
<font color='blue'>add_example</font>(bayes_net_from_disk_ex)
<font color='blue'>add_gui_example</font>(bayes_net_gui_ex)
<font color='blue'>add_example</font>(bridge_ex)
<font color='blue'>add_example</font>(bsp_ex)
<font color='blue'>add_example</font>(compress_stream_ex)
<font color='blue'>add_example</font>(config_reader_ex)
<font color='blue'>add_example</font>(custom_trainer_ex)
<font color='blue'>add_example</font>(dir_nav_ex)
<font color='blue'>add_example</font>(empirical_kernel_map_ex)
<font color='blue'>add_gui_example</font>(face_detection_ex)
<font color='blue'>add_gui_example</font>(face_landmark_detection_ex)
<font color='blue'>add_gui_example</font>(fhog_ex)
<font color='blue'>add_gui_example</font>(fhog_object_detector_ex)
<font color='blue'>add_example</font>(file_to_code_ex)
<font color='blue'>add_example</font>(graph_labeling_ex)
<font color='blue'>add_gui_example</font>(gui_api_ex)
<font color='blue'>add_gui_example</font>(hough_transform_ex)
<font color='blue'>add_gui_example</font>(image_ex)
<font color='blue'>add_example</font>(integrate_function_adapt_simp_ex)
<font color='blue'>add_example</font>(iosockstream_ex)
<font color='blue'>add_example</font>(kcentroid_ex)
<font color='blue'>add_example</font>(kkmeans_ex)
<font color='blue'>add_example</font>(krls_ex)
<font color='blue'>add_example</font>(krls_filter_ex)
<font color='blue'>add_example</font>(krr_classification_ex)
<font color='blue'>add_example</font>(krr_regression_ex)
<font color='blue'>add_example</font>(learning_to_track_ex)
<font color='blue'>add_example</font>(least_squares_ex)
<font color='blue'>add_example</font>(linear_manifold_regularizer_ex)
<font color='blue'>add_example</font>(logger_custom_output_ex)
<font color='blue'>add_example</font>(logger_ex)
<font color='blue'>add_example</font>(logger_ex_2)
<font color='blue'>add_example</font>(matrix_ex)
<font color='blue'>add_example</font>(matrix_expressions_ex)
<font color='blue'>add_example</font>(max_cost_assignment_ex)
<font color='blue'>add_example</font>(member_function_pointer_ex)
<font color='blue'>add_example</font>(mlp_ex)
<font color='blue'>add_example</font>(model_selection_ex)
<font color='blue'>add_gui_example</font>(mpc_ex)
<font color='blue'>add_example</font>(multiclass_classification_ex)
<font color='blue'>add_example</font>(multithreaded_object_ex)
<font color='blue'>add_gui_example</font>(object_detector_advanced_ex)
<font color='blue'>add_gui_example</font>(object_detector_ex)
<font color='blue'>add_gui_example</font>(one_class_classifiers_ex)
<font color='blue'>add_example</font>(optimization_ex)
<font color='blue'>add_example</font>(parallel_for_ex)
<font color='blue'>add_example</font>(pipe_ex)
<font color='blue'>add_example</font>(pipe_ex_2)
<font color='blue'>add_example</font>(quantum_computing_ex)
<font color='blue'>add_example</font>(queue_ex)
<font color='blue'>add_example</font>(rank_features_ex)
<font color='blue'>add_example</font>(running_stats_ex)
<font color='blue'>add_example</font>(rvm_ex)
<font color='blue'>add_example</font>(rvm_regression_ex)
<font color='blue'>add_example</font>(sequence_labeler_ex)
<font color='blue'>add_example</font>(sequence_segmenter_ex)
<font color='blue'>add_example</font>(server_http_ex)
<font color='blue'>add_example</font>(server_iostream_ex)
<font color='blue'>add_example</font>(sockets_ex)
<font color='blue'>add_example</font>(sockstreambuf_ex)
<font color='blue'>add_example</font>(std_allocator_ex)
<font color='blue'>add_gui_example</font>(surf_ex)
<font color='blue'>add_example</font>(svm_c_ex)
<font color='blue'>add_example</font>(svm_ex)
<font color='blue'>add_example</font>(svm_pegasos_ex)
<font color='blue'>add_example</font>(svm_rank_ex)
<font color='blue'>add_example</font>(svm_sparse_ex)
<font color='blue'>add_example</font>(svm_struct_ex)
<font color='blue'>add_example</font>(svr_ex)
<font color='blue'>add_example</font>(thread_function_ex)
<font color='blue'>add_example</font>(thread_pool_ex)
<font color='blue'>add_example</font>(threaded_object_ex)
<font color='blue'>add_example</font>(threads_ex)
<font color='blue'>add_example</font>(timer_ex)
<font color='blue'>add_gui_example</font>(train_object_detector)
<font color='blue'>add_example</font>(train_shape_predictor_ex)
<font color='blue'>add_example</font>(using_custom_kernels_ex)
<font color='blue'>add_gui_example</font>(video_tracking_ex)
<font color='blue'>add_example</font>(xml_parser_ex)
<font color='blue'>if </font>(DLIB_LINK_WITH_SQLITE3)
<font color='blue'> add_example</font>(sqlite_ex)
<font color='blue'>endif</font>()
</pre></body></html>