You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
dlib/examples/CMakeLists.txt

253 lines
9.4 KiB

#
# _______ _ _ _____ _____ _____ _____
# |__ __| | | |_ _|/ ____| |_ _|/ ____| /\
# | | | |__| | | | | (___ | | | (___ / \
# | | | __ | | | \___ \ | | \___ \ / /\ \
# | | | | | |_| |_ ____) | _| |_ ____) | / ____ \
# |_|__|_|_ |_|_____|_____/__ |_____|_____/ /_/ _ \_\
# |__ __| | | |__ __/ __ \| __ \|_ _| /\ | |
# | | | | | | | | | | | | |__) | | | / \ | |
# | | | | | | | | | | | | _ / | | / /\ \ | |
# | | | |__| | | | | |__| | | \ \ _| |_ / ____ \| |____
# |_| \____/ |_| \____/|_| \_\_____/_/ \_\______|
#
#
# _____ ______ _____ _______ _ _ ______
# | __ \| ____| /\ | __ \ |__ __| | | | ____|
# | |__) | |__ / \ | | | | | | | |__| | |__
# | _ /| __| / /\ \ | | | | | | | __ | __|
# | | \ \| |____ / ____ \| |__| | | | | | | | |____
# |_|__\_\______/_/_ __\_\_____/__ _ |_|__|_|_ |_|______|_ _ _
# / ____/ __ \| \/ | \/ | ____| \ | |__ __/ ____| | | | | |
# | | | | | | \ / | \ / | |__ | \| | | | | (___ | | | | |
# | | | | | | |\/| | |\/| | __| | . ` | | | \___ \ | | | | |
# | |___| |__| | | | | | | | |____| |\ | | | ____) | |_|_|_|_|
# \_____\____/|_| |_|_| |_|______|_| \_| |_| |_____/ (_|_|_|_)
#
#
#
# This is a CMake makefile. CMake is a tool that helps you build C++ programs.
# You can download CMake from http://www.cmake.org. This CMakeLists.txt file
# you are reading builds dlib's example programs.
#
cmake_minimum_required(VERSION 3.8.0)
# Every project needs a name. We call this the "examples" project.
project(examples)
# Tell cmake we will need dlib. This command will pull in dlib and compile it
# into your project. Note that you don't need to compile or install dlib. All
# cmake needs is the dlib source code folder and it will take care of everything.
add_subdirectory(../dlib dlib_build)
5 years ago
# If you have cmake 3.14 or newer you can even use FetchContent instead of
# add_subdirectory() to pull in dlib as a dependency. So instead of using the
# above add_subdirectory() command, you could use the following three commands
# to make dlib available:
# include(FetchContent)
# FetchContent_Declare(dlib
# GIT_REPOSITORY https://github.com/davisking/dlib.git
# GIT_TAG v19.24
# )
# FetchContent_MakeAvailable(dlib)
# The next thing we need to do is tell CMake about the code you want to
# compile. We do this with the add_executable() statement which takes the name
# of the output executable and then a list of .cpp files to compile. Here we
# are going to compile one of the dlib example programs which has only one .cpp
# file, assignment_learning_ex.cpp. If your program consisted of multiple .cpp
# files you would simply list them here in the add_executable() statement.
add_executable(assignment_learning_ex assignment_learning_ex.cpp)
# Finally, you need to tell CMake that this program, assignment_learning_ex,
# depends on dlib. You do that with this statement:
target_link_libraries(assignment_learning_ex dlib::dlib)
# To compile this program all you need to do is ask cmake. You would type
# these commands from within the directory containing this CMakeLists.txt
# file:
# mkdir build
# cd build
# cmake ..
# cmake --build . --config Release
#
# The cmake .. command looks in the parent folder for a file named
7 years ago
# CMakeLists.txt, reads it, and sets up everything needed to build program.
# Also, note that CMake can generate Visual Studio or XCode project files. So
# if instead you had written:
# cd build
# cmake .. -G Xcode
#
# You would be able to open the resulting Xcode project and compile and edit
# the example programs within the Xcode IDE. CMake can generate a lot of
# different types of IDE projects. Run the cmake -h command to see a list of
# arguments to -G to see what kinds of projects cmake can generate for you. It
# probably includes your favorite IDE in the list.
#################################################################################
#################################################################################
# A CMakeLists.txt file can compile more than just one program. So below we
# tell it to compile the other dlib example programs using pretty much the
# same CMake commands we used above.
#################################################################################
#################################################################################
# Since there are a lot of examples I'm going to use a macro to simplify this
# CMakeLists.txt file. However, usually you will create only one executable in
# your cmake projects and use the syntax shown above.
macro(add_example name)
add_executable(${name} ${name}.cpp)
target_link_libraries(${name} dlib::dlib )
# And strip symbols to make your binary smaller if you like. Certainly not required though.
target_link_options(${name} PRIVATE $<$<CONFIG:RELEASE>:-s>)
endmacro()
# if an example requires GUI, call this macro to check DLIB_NO_GUI_SUPPORT to include or exclude
macro(add_gui_example name)
if (DLIB_NO_GUI_SUPPORT)
message("No GUI support, so we won't build the ${name} example.")
else()
add_example(${name})
endif()
endmacro()
add_example(dnn_metric_learning_ex)
add_gui_example(dnn_face_recognition_ex)
add_example(dnn_introduction_ex)
add_example(dnn_introduction2_ex)
add_example(dnn_introduction3_ex)
add_example(dnn_inception_ex)
add_gui_example(dnn_mmod_ex)
add_gui_example(dnn_mmod_face_detection_ex)
add_gui_example(random_cropper_ex)
add_gui_example(dnn_mmod_dog_hipsterizer)
add_gui_example(dnn_imagenet_ex)
add_gui_example(dnn_mmod_find_cars_ex)
add_gui_example(dnn_mmod_find_cars2_ex)
add_example(dnn_mmod_train_find_cars_ex)
add_gui_example(dnn_semantic_segmentation_ex)
add_gui_example(dnn_instance_segmentation_ex)
add_example(dnn_imagenet_train_ex)
add_example(dnn_semantic_segmentation_train_ex)
add_example(dnn_instance_segmentation_train_ex)
add_example(dnn_metric_learning_on_images_ex)
add_gui_example(dnn_dcgan_train_ex)
add_gui_example(dnn_yolo_train_ex)
add_gui_example(dnn_self_supervised_learning_ex)
add_gui_example(3d_point_cloud_ex)
add_example(bayes_net_ex)
add_example(bayes_net_from_disk_ex)
add_gui_example(bayes_net_gui_ex)
add_example(bridge_ex)
add_example(bsp_ex)
add_example(compress_stream_ex)
add_example(config_reader_ex)
add_example(custom_trainer_ex)
add_example(dir_nav_ex)
add_example(empirical_kernel_map_ex)
add_gui_example(face_detection_ex)
add_gui_example(face_landmark_detection_ex)
add_gui_example(fhog_ex)
add_gui_example(fhog_object_detector_ex)
add_example(file_to_code_ex)
add_example(graph_labeling_ex)
add_gui_example(gui_api_ex)
add_gui_example(hough_transform_ex)
add_gui_example(image_ex)
add_example(integrate_function_adapt_simp_ex)
add_example(iosockstream_ex)
add_example(kcentroid_ex)
add_example(kkmeans_ex)
add_example(krls_ex)
add_example(krls_filter_ex)
add_example(krr_classification_ex)
add_example(krr_regression_ex)
add_example(learning_to_track_ex)
add_example(least_squares_ex)
add_example(linear_manifold_regularizer_ex)
add_example(logger_custom_output_ex)
add_example(logger_ex)
add_example(logger_ex_2)
add_example(matrix_ex)
add_example(matrix_expressions_ex)
add_example(max_cost_assignment_ex)
add_example(member_function_pointer_ex)
add_example(mlp_ex)
add_example(model_selection_ex)
add_gui_example(mpc_ex)
add_example(multiclass_classification_ex)
add_example(multithreaded_object_ex)
add_gui_example(object_detector_advanced_ex)
add_gui_example(object_detector_ex)
add_gui_example(one_class_classifiers_ex)
add_example(optimization_ex)
add_example(parallel_for_ex)
add_example(pipe_ex)
add_example(pipe_ex_2)
add_example(quantum_computing_ex)
add_example(queue_ex)
add_example(rank_features_ex)
add_example(running_stats_ex)
add_example(rvm_ex)
add_example(rvm_regression_ex)
add_example(sequence_labeler_ex)
add_example(sequence_segmenter_ex)
add_example(server_http_ex)
add_example(server_iostream_ex)
add_example(sockets_ex)
add_example(sockstreambuf_ex)
add_example(std_allocator_ex)
add_gui_example(surf_ex)
add_example(svm_c_ex)
add_example(svm_ex)
add_example(svm_pegasos_ex)
add_example(svm_rank_ex)
add_example(svm_sparse_ex)
add_example(svm_struct_ex)
add_example(svr_ex)
add_example(thread_function_ex)
add_example(thread_pool_ex)
add_example(threaded_object_ex)
add_example(threads_ex)
add_example(timer_ex)
add_gui_example(train_object_detector)
add_example(train_shape_predictor_ex)
add_example(using_custom_kernels_ex)
add_gui_example(video_tracking_ex)
add_example(xml_parser_ex)
if (DLIB_LINK_WITH_SQLITE3)
add_example(sqlite_ex)
endif()
FFMPEG wrappers: dlib::ffmpeg::decoder and dlib::ffmpeg::demuxer (#2707) * - added ffmpeg stuff to cmake * - added observer_ptr * ffmpeg utils * WIP * - added ffmpeg_decoder * config file for test data * another test file * install ffmpeg * added ffmpeg_demuxer * install all ffmpeg libraries * support older version of ffmpeg * simplified loop * - test converting to dlib object - added docs - support older ffmpeg * added convert() overload * added comment * only register stuff when API not deprecated * - fixed version issues - fixed decoding * added tests for ffmpeg_demuxer * removed unused code * test GIF * added docs * added audio test * test for audio * more tests * review changes * don't need observer_ptr * made deps public. I could be wrong but just in case. * - added some static asserts. Some areas of the code might do memcpy's on arrays of pixels. This requires the structures to be packed. Check this. - added convert() functions - changed default decoder options. By default, always decode to RGB and S16 audio - added convenience constructor to demuxer * - no longer need opencv * oops. I let that slip * - made a few functions public - more precise requires clauses * enhanced example * - avoid FFMPEG_INITIALIZED being optimized away at link time - added decoding example * - avoid -Wunused-parameter error * constexpr and noexcept correctness. This probably makes no difference to performance, BUT, it's what the core guidelines tell you to do. It does however demonstrate how complicated and unecessarily verbose C++ is becoming. Sigh, maybe one day i'll make the switch to something that doesn't make my eyes twitch. * - simplified metadata structure * hopefully more educational * added another example * ditto * typo * screen grab example * whoops * avoid -Wunused-parameter errors * ditto * - added methods to av_dict - print the demuxer format options that were not used - enhanced webcam_face_pose_ex.cpp so you can set webcam options * if height and width are specified, attempt to set video_size in format_options. Otherwise set the bilinear resizer. * updated docs * once again, the ffmpeg APIs do a lot for you. It's a matter of knowing which APIs to call. * made header-only * - some Werror thing * don't use type_safe_union * - templated sample type - reverted deep copy of AVFrame for frame copy constructor * - added is_pixel_type and is_pixel_check * unit tests for pixel traits * enhanced is_image_type type trait and added is_image_check * added unit tests for is_image_type * added pix_traits, improved convert() functions * bug fix * get rid of -Werror=unused-variable error * added a type alias * that's the last of the manual memcpys gone. We'using ffmpeg API everywhere now for copying frames to buffers and back * missing doc * set framerate for webcam * list input devices * oops. I was trying to make ffmpeg 5 happy but i've given up on ffmpeg v5 compatibility in this PR. Future PR. * enhanced the information provided by list_input_devices and list_output_devices * removed vscode settings.json file * - added a type trait for checking whether a type is complete. This is useful for writing type traits that check other types have type trait specializations. But also other useful things. For example, std::unique_ptr uses something similar to this. * Davis was keen to simply check pixel_traits is specialised. That's equivalent to checking pixel_traits<> is complete for some type * code review * juse use the void_t in dlib/type_traits.h * one liners * just need is_image_check * more tests for is_image_type * i think this is correct * removed printf * better docs * Keep opencv out of it * keep old face pose example, then add new one which uses dlib's ffmpeg wrappers * revert * revert * better docs * better docs --------- Co-authored-by: pf <pf@me>
2 years ago
if (DLIB_USE_FFMPEG AND NOT DLIB_NO_GUI_SUPPORT)
add_example(ffmpeg_webcam_face_pose_ex)
add_example(ffmpeg_video_demuxing)
add_example(ffmpeg_video_decoding)
add_example(ffmpeg_info)
add_example(ffmpeg_screen_grab)
endif()
if (DLIB_NO_GUI_SUPPORT)
message("No GUI support, so we won't build the webcam_face_pose_ex example.")
else()
find_package(OpenCV QUIET)
if (OpenCV_FOUND)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(webcam_face_pose_ex webcam_face_pose_ex.cpp)
target_link_libraries(webcam_face_pose_ex dlib::dlib ${OpenCV_LIBS} )
else()
message("OpenCV not found, so we won't build the webcam_face_pose_ex example.")
endif()
endif()