Skip to content

Commit

Permalink
Merge pull request #599 from Kicer86/third_party_apps
Browse files Browse the repository at this point in the history
* Format

* Prepare base for downloading and compiling align_image_stack tool

* Use base file as header

* Add OpenMP dependency

* Add hugin dependencies

* Add vcpkg vigra port

* Add overlays configuration

* Depend on Vigra

* Use include dirs only

* Prepare base for new, OpenCV based, aligner

* Introduce universal function for svg conversion

* Generate 32-bit pngs for comaptibility

* Use universal svg to png conversion function where applicable

* Move test image to top dir

* Fix parameters

* Handle missing width and height

* Handle default weight and height

* Drop Hugin references

* Replace xml.etree with defusedxml

xml.etree is considered unsafe

* Update expected filelist

* Introduce ImageAligner utility

* Extract more internals for unit testing

* Make photos a member

* Add test image

* Be explicit

* Add python dependencies

* Allow 1 pixel differences

* Build both Release and Debug for better logs from sanitizers

* Reorder entries for cleaner titles on GitHub

* Suppress gdal thread sanitizer errors

* Suppress new Qt errors

* Do not enable sanitizers for debug, it causes many errors in Qt libs

* Drop \

* Enable cmake warnings and turn them into errors

* Disable Debug as it causes unreproducible crashes :(

* Reorganize ImageAligner to be less unnatural

* Replace save() with more universal forEachImage()

* Add docs

* Be explicit

* Parametrize tests, add test for three same images

* Test second sample

* Improve results by switching to MOTION_HOMOGRAPHY

- increasing required eps precision
- using 3x3 transformation matrix (MOTION_HOMOGRAPHY)
- round crop towards center of image for better margins truncation
  (no more thin black lines)

* Log some data about transformations used

* Drop dead code

* Dump results for verification

* Use new Aligner for tests

* Loosen tests

* Move all local stuff into anonymous namespace

* Expand PrintTo for most Qt types with one simple trick

* Be more human triendly in case of errors

* Try a bit less strict eps

(OpenCV 4.6.0 crashes with current parameters)

* Fix for warnings

* Add link to knowledge

* Move image_aligner_tests to learning tests

* do not build core_learning_tests_for_opencv when BUILD_LEARNING_TESTS is OFF

* Remove dependencies required by Learning Tests

* Hide whole implementation in ImageAligner

* rename files and improve way of building IAlignedImages

* Handle progress properly

* Fix progress logic

* Fix dependencies - core unit tests need images too

* Fix tests' dependencies

* Revert "Remove dependencies required by Learning Tests"

This reverts commit 1df6c9b.

* Try better quality

* Remove all references to align_image_stack. More work needed to replace it

* Use extracted stabilization code

* Be more restrictive

* Enable PIC globally

* Add Exif.Photo.ShutterSpeedValue

* Remove redundant code

* Add experimental hdr assembler

* Drop experiments

* Introduce more generic variant

* Stabilize StLouisArch photos

* BugFix: possible property race

* Use new hdr generator

* Bump exiftool version

* Update package file list
  • Loading branch information
Kicer86 committed Mar 5, 2024
2 parents 51afcdd + fb01193 commit b00a2dc
Show file tree
Hide file tree
Showing 47 changed files with 7,617 additions and 421 deletions.
1 change: 1 addition & 0 deletions .github/aur/photobroom-git/.SRCINFO
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ pkgbase = photobroom-git
makedepends = libwebp
makedepends = cs-libguarded
makedepends = boost
makedepends = openmp
depends = exiv2
depends = qt6-base
depends = qt6-multimedia
Expand Down
2 changes: 1 addition & 1 deletion .github/aur/photobroom-git/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ url="https://github.com/Kicer86/photobroom"
license=('GPL3')
groups=()
depends=('exiv2' 'qt6-base' 'qt6-multimedia' 'qt6-declarative' 'qt6-svg' 'qt6-quick3d' 'dlib' 'opencv' 'jsoncpp')
makedepends=('cmake' 'magic_enum' 'qt6-tools' 'imagemagick' 'libwebp' 'cs-libguarded' 'boost')
makedepends=('cmake' 'magic_enum' 'qt6-tools' 'imagemagick' 'libwebp' 'cs-libguarded' 'boost' 'openmp')
optdepends=()
provides=('photobroom')
conflicts=('photobroom')
Expand Down
6 changes: 5 additions & 1 deletion .github/expected_file_list
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,15 @@ msvcrt.dll
ole32.dll
oleaut32.dll
openblas.dll
opencv_calib3d4.dll
opencv_core4.dll
opencv_features2d4.dll
opencv_flann4.dll
opencv_imgcodecs4.dll
opencv_img_hash4.dll
opencv_imgproc4.dll
opencv_photo4.dll
opencv_video4.dll
opencv_videoio4.dll
opengl32sw.dll
photo_broom.exe
Expand Down Expand Up @@ -624,7 +629,6 @@ shlwapi.dll
sql_backend_base.dll
system.dll
tools\ExifTool\exiftool.exe
tools\Hugin\align_image_stack.exe
translations\qt_ar.qm
translations\qt_bg.qm
translations\qt_ca.qm
Expand Down
82 changes: 46 additions & 36 deletions .github/workflows/linux-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ jobs:
strategy:
fail-fast: false
matrix:
os: [ubuntu-22.04]
shared: [TRUE, FALSE]
compiler:
- { compiler: GNU, CC: gcc, CXX: g++ }
- { compiler: LLVM, CC: clang-16, CXX: clang++-16 }
build: [Release]
shared: [TRUE, FALSE]
os: [ubuntu-22.04]

steps:
# switch to ubuntu 23.10
Expand All @@ -31,30 +32,33 @@ jobs:

- name: Install system dependencies
run: |
sudo apt-get update && \
sudo apt-get install \
gcc \
ninja-build \
qt6-base-dev \
qt6-declarative-dev \
qt6-declarative-dev-tools \
qt6-declarative-private-dev \
qt6-multimedia-dev \
qt6-quick3d-dev \
qt6-quick3d-dev-tools \
qt6-l10n-tools \
qml6-module-qtqml-workerscript \
qml6-module-qtquick-window \
libqt6shadertools6-dev \
libqt6svg6-dev \
libqt6quick3druntimerender6 \
libboost-dev \
libopencv-dev \
libdlib-dev \
libexiv2-dev \
libgmock-dev \
libgl1-mesa-dev \
libglvnd-dev \
sudo apt-get update && \
sudo apt-get install \
gcc \
ninja-build \
python3-cairosvg \
python3-defusedxml \
python3-pil \
qt6-base-dev \
qt6-declarative-dev \
qt6-declarative-dev-tools \
qt6-declarative-private-dev \
qt6-multimedia-dev \
qt6-quick3d-dev \
qt6-quick3d-dev-tools \
qt6-l10n-tools \
qml6-module-qtqml-workerscript \
qml6-module-qtquick-window \
libqt6shadertools6-dev \
libqt6svg6-dev \
libqt6quick3druntimerender6 \
libboost-dev \
libopencv-dev \
libdlib-dev \
libexiv2-dev \
libgmock-dev \
libgl1-mesa-dev \
libglvnd-dev \
libwebp-dev
# todo: this step will be redundant when github actions use ubuntu >= 23.10 by default
Expand Down Expand Up @@ -83,21 +87,27 @@ jobs:
with:
key: ${{ github.job }}-${{ matrix.compiler.compiler }}

- name: Setup environment
run: echo "ENABLE_SANITIZERS=$( test ${{ matrix.build }} == "Release" && echo "ON" || echo "OFF" )" >> $GITHUB_ENV

- name: Build
uses: ashutoshvarma/action-cmake-build@master
with:
build-dir: ${{ runner.workspace }}/build
build-type: Release
build-type: ${{ matrix.build }}
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 \
-DENABLE_SANITIZERS_FOR_TESTS=TRUE
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
-DENABLE_SANITIZERS_FOR_TESTS=${{ env.ENABLE_SANITIZERS }}
-Wdev -Werror=dev
run-test: true
ctest-options: \
--output-on-failure \
ctest-options:
--output-on-failure
--repeat until-fail:5
env:
TSAN_OPTIONS=suppressions: ${{ runner.workspace }}/photobroom/sanitizer-thread-suppressions.txt
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_STANDARD 20)

set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
set(CMAKE_POSITION_INDEPENDENT_CODE TRUE)

#check if git modules are setup
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/cmake_modules/FindEasyExif.cmake)
Expand Down
40 changes: 40 additions & 0 deletions cmake/functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,46 @@ function(stringify_file output_file input_file variable_with_type namespace)
endfunction(stringify_file)


function(convertSVG output_file input_file width height)
find_program(Magick magick)

if(Magick)
if(${width} EQUAL -1 AND ${height} EQUAL -1)
set(resize "")
elseif(${width} EQUAL -1 OR ${height} EQUAL -1)
message(FATAL_ERROR "Not handled")
else()
set(resize -resize ${width}x${height})
endif()

get_filename_component(output_file_ext ${output_file} EXT)
if(${output_file_ext} STREQUAL "png")
set(output_file "png32:${output_file}")
endif()

add_custom_command(OUTPUT ${output_file}
COMMAND ${Magick} convert ${input_file} ${resize} ${output_file}
DEPENDS ${input_file}
)
else()
find_program(Python python REQUIRED)

if(${width} EQUAL -1 AND ${height} EQUAL -1)
set(resize "")
elseif(${width} EQUAL -1 OR ${height} EQUAL -1)
message(FATAL_ERROR "Not handled")
else()
set(resize --width ${width} --height ${height})
endif()

add_custom_command(OUTPUT ${output_file}
COMMAND ${Python} ${PROJECT_SOURCE_DIR}/tools/svg2any.py ${input_file} ${output_file} ${resize}
DEPENDS ${input_file}
)
endif()
endfunction()


function(objdump_target target)

if(ENABLE_OBJDUMPING)
Expand Down
21 changes: 0 additions & 21 deletions cmake/system/win32.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,6 @@ function(download_tools)
RENAME exiftool.exe
)

if(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/tools/Hugin-2021.0.0-win64.msi)
message("Downloading Hugin")
file(DOWNLOAD
https://netix.dl.sourceforge.net/project/hugin/hugin/hugin-2021.0/Hugin-2021.0.0-win64.msi ${CMAKE_CURRENT_BINARY_DIR}/tools/Hugin-2021.0.0-win64.msi
SHOW_PROGRESS
)

find_program(APP_7Z 7z REQUIRED)
execute_process(
COMMAND
${APP_7Z} e
-o${CMAKE_CURRENT_BINARY_DIR}/tools/Hugin
${CMAKE_CURRENT_BINARY_DIR}/tools/Hugin-2021.0.0-win64.msi
)
endif()

install(FILES ${CMAKE_CURRENT_BINARY_DIR}/tools/Hugin/CM_FP_bin.align_image_stack.exe
DESTINATION tools/Hugin
RENAME align_image_stack.exe
)

endfunction(download_tools)


Expand Down
8 changes: 7 additions & 1 deletion sanitizer-thread-suppressions.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@

#Qt races
# Qt races
race:QMetaCallEvent::~QMetaCallEvent()
race:QCoreApplicationPrivate::cleanupThreadData()
race:libQt5Core.so

# Qt signals
signal:QByteArray::append()

# https://github.com/OSGeo/gdal/issues/1108
deadlock:libgdal.so
16 changes: 1 addition & 15 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,7 @@ add_executable(photo_broom

if(WIN32)

find_program(Magick magick)

if(Magick)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/main_ico.ico
COMMAND ${Magick} convert ${CMAKE_SOURCE_DIR}/images/photo_broom.svg -resize 32x32 ${CMAKE_CURRENT_BINARY_DIR}/main_ico.ico
DEPENDS ${CMAKE_SOURCE_DIR}/images/photo_broom.svg
)
else()
find_program(Python python REQUIRED)

add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/main_ico.ico
COMMAND ${Python} ${PROJECT_SOURCE_DIR}/tools/svg2any.py ${CMAKE_SOURCE_DIR}/images/photo_broom.svg ${CMAKE_CURRENT_BINARY_DIR}/main_ico.ico --width 32 --height 32
DEPENDS ${CMAKE_SOURCE_DIR}/images/photo_broom.svg
)
endif()
convertSVG(${CMAKE_CURRENT_BINARY_DIR}/main_ico.ico ${CMAKE_SOURCE_DIR}/images/photo_broom.svg 32 32)

set_target_properties(photo_broom PROPERTIES WIN32_EXECUTABLE TRUE)

Expand Down
4 changes: 4 additions & 0 deletions src/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ set(CORE_SOURCES
implementation/configuration_p.hpp
implementation/exiftool_video_details_reader.hpp implementation/exiftool_video_details_reader.cpp
implementation/exiv2_exif_reader.hpp implementation/exiv2_exif_reader.cpp
implementation/hdr_assembler.cpp
implementation/image_media_information.hpp implementation/image_media_information.cpp
implementation/init.cpp
implementation/log_file_rotator.hpp implementation/log_file_rotator.cpp
Expand Down Expand Up @@ -45,6 +46,7 @@ set(CORE_SOURCES
ilogger.hpp
ilogger.hpp
image_tools.hpp implementation/image_tools.cpp
implementation/image_aligner.cpp
imedia_information.hpp
imodel_compositor_data_source.hpp
itask_executor.hpp
Expand Down Expand Up @@ -101,7 +103,9 @@ target_link_libraries(core
${CMAKE_THREAD_LIBS_INIT}
CsLibGuarded::CsLibGuarded
${EXIV2_LIB}
opencv_photo
opencv_videoio
opencv_tracking
)

target_include_directories(core
Expand Down
1 change: 0 additions & 1 deletion src/core/constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ namespace ConfigConsts

namespace ExternalToolsConfigKeys
{
const char* const aisPath = "tool_path::align_image_stack";
const char* const exiftoolPath = "tool_path::exiftool";
}

Expand Down
Loading

0 comments on commit b00a2dc

Please sign in to comment.