Skip to content

Commit

Permalink
Merge pull request #535 from Kicer86/faces_detection_improvements
Browse files Browse the repository at this point in the history
Faces detection improvements
  • Loading branch information
Kicer86 committed Dec 26, 2023
2 parents 28b41c5 + 6f14052 commit 947e548
Show file tree
Hide file tree
Showing 105 changed files with 2,859 additions and 1,093 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,14 @@ jobs:
submodules: true

- name: Load llvm keys
if: matrix.compiler.compiler == 'LLVM'
run: wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key|sudo apt-key add -

- name: Update clang
if: matrix.compiler.compiler == 'LLVM'
uses: myci-actions/add-deb-repo@10
with:
repo: deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-16 main
repo-name: llvm-toolchain-focal-16
update: false
install: clang-16

- name: Install system dependencies
run: |
Expand All @@ -47,6 +44,9 @@ jobs:
qt6-multimedia-dev \
libqt6svg6-dev \
qt6-l10n-tools \
clang-16 \
libboost-dev \
libclang-16-dev \
libopencv-dev \
libdlib-dev \
libexiv2-dev \
Expand Down Expand Up @@ -81,4 +81,4 @@ jobs:
build-type: Release
cc: ${{ matrix.compiler.CC }}
cxx: ${{ matrix.compiler.CXX }}
configure-options: -DBUILD_SHARED_LIBS=${{ matrix.shared }} -DLUPDATE=/usr/lib/qt6/bin/lupdate -DLRELEASE:FILEPATH=/usr/lib/qt6/bin/lrelease -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache
configure-options: -DBUILD_SHARED_LIBS=${{ matrix.shared }} -DLUPDATE=/usr/lib/qt6/bin/lupdate -DLRELEASE:FILEPATH=/usr/lib/qt6/bin/lrelease -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DClang_DIR=/usr/lib/llvm-16/lib/cmake/clang
2 changes: 1 addition & 1 deletion .github/workflows/macos-build.yml.bak
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
with:
build-dir: ${{ runner.workspace }}/build
build-type: Release
configure-options: -DBUILD_TESTING=OFF
configure-options: -DBUILD_TESTING=OFF -DClang_DIR=/usr/local/opt/llvm/lib/cmake/clang
cc: /usr/local/opt/llvm/bin/clang
cxx: /usr/local/opt/llvm/bin/clang++
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/windows-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ jobs:
- name: Prepare build dir
run: |
New-Item -ItemType directory -Path "c:\" -Name "build"
compact.exe /C "c:\build\"
New-Item -ItemType Junction -Path "out" -Target "c:\build"
Move-Item -Path vcpkg -Destination c:\build
New-Item -ItemType Junction -Path "vcpkg" -Target "c:\build\vcpkg"
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@
[submodule "src/gui/desktop/utils/animated_webp"]
path = src/gui/desktop/utils/animated_webp
url = https://github.com/Kicer86/AnimatedWebP.git
[submodule "tools/reflex++"]
path = tools/reflect++
url = https://github.com/Kicer86/reflexpp.git
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)

#check if git modules are setup
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/cmake_modules/FindEasyExif.cmake)
message(FATAL_ERROR "Git submodules were not updated. See docs/build.txt for instructions.")
Expand Down Expand Up @@ -126,6 +128,7 @@ endif(UNIX OR CYGWIN)

#subdirs
add_subdirectory(src)
add_subdirectory(tools)
add_subdirectory(tr)

#documentation
Expand Down
30 changes: 30 additions & 0 deletions src/core/cast.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

#ifndef DOWN_CAST_HPP
#define DOWN_CAST_HPP

#include <cassert>
#include <type_traits>


template<typename T, typename R>
T down_cast(R* base)
{
assert(dynamic_cast<T>(base) != nullptr);

return static_cast<T>(base);
}


template<typename T, typename F>
T safe_cast(const F& from)
{
static_assert(sizeof(F) <= sizeof(T)); // TODO: handle size conversion when needed
static_assert(std::is_nothrow_convertible_v<F, T>);

if constexpr (std::is_signed_v<F> && std::is_unsigned_v<T>) // cast from signed to unsigned
assert(from >= 0);

return static_cast<T>(from);
}

#endif
7 changes: 7 additions & 0 deletions src/core/containers_utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,11 @@ ForwardIt remove_unique(ForwardIt first, ForwardIt last)
return remove_unique(first, last, std::equal_to{});
}


template<typename CT, typename R>
CT range_to(R&& range)
{
return CT(range.begin(), range.end());
}

#endif
12 changes: 12 additions & 0 deletions src/core/core_test.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,15 @@ find_package(GTest REQUIRED CONFIG)
find_package(Qt6 REQUIRED COMPONENTS Core Gui)
find_package(Qt6Test REQUIRED)

include(${PROJECT_SOURCE_DIR}/tools/reflect++/Reflect++.cmake)

ReflectFiles(
ReflectionFiles
TARGET
core
SOURCES
unit_tests/json_serializer_tests.hpp
)

addTestTarget(core
SOURCES
Expand All @@ -23,6 +32,7 @@ addTestTarget(core
unit_tests/data_from_path_extractor_tests.cpp
unit_tests/exiftool_video_details_reader_tests.cpp
unit_tests/function_wrappers_tests.cpp
unit_tests/json_serializer_tests.cpp
unit_tests/lazy_ptr_tests.cpp
unit_tests/model_compositor_tests.cpp
#unit_tests/oriented_image_tests.cpp
Expand All @@ -31,6 +41,8 @@ addTestTarget(core
unit_tests/status_tests.cpp
unit_tests/tag_value_tests.cpp

${ReflectionFiles}

LIBRARIES
GTest::gtest
GTest::gmock
Expand Down
15 changes: 0 additions & 15 deletions src/core/down_cast.hpp

This file was deleted.

27 changes: 25 additions & 2 deletions src/core/function_wrappers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@
#include <stop_token>

#include <QPointer>
#include <QPromise>
#include <QThread>


// Internal struct with data shared between safe_callback and safe_callback_ctrl
struct safe_callback_data
{
Expand Down Expand Up @@ -129,13 +131,34 @@ class safe_callback_ctrl final
template<typename Obj, typename F, typename... Args>
void invokeMethod(Obj* object, const F& method, Args&&... args) requires std::is_base_of<QObject, Obj>::value
{
QMetaObject::invokeMethod(object, [object, method, args...]()
QMetaObject::invokeMethod(object, [object, method, ...args = std::forward<Args>(args)]() mutable
{
(object->*method)(args...);
(object->*method)(std::forward<Args>(args)...);
});
}


// Works as extended invokeMethod but waits for results
template<typename T, typename ObjT, typename F, typename... Args>
requires std::is_base_of_v<QObject, ObjT>
auto invoke_and_wait(QPointer<ObjT> object, const F& function, Args&&... args)
{
QPromise<T> promise;
QFuture<T> future = promise.future();

call_from_object_thread(object, [&promise, &function, &args...]()
{
promise.start();
promise.addResult(function(args...));
promise.finish();
});

future.waitForFinished();

return future.result();
}


// call_from_object_thread uses Qt mechanisms to invoke function in another thread
// (thread of 'object' object)
template<typename F, typename ObjT, typename... Args>
Expand Down
2 changes: 1 addition & 1 deletion src/core/id.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,4 +121,4 @@ class Id
bool m_valid = false;
};

#endif // ID_HPP
#endif

0 comments on commit 947e548

Please sign in to comment.