Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 0 additions & 62 deletions .github/workflows/ubuntu-2004-cmake.yml

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/ubuntu-2204-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ jobs:
cmake cmake-data build-essential libmagick++-dev qtbase5-dev qtmultimedia5-dev
ffmpeg git libv4l-dev libgphoto2-dev"

- name: Install patched vidstab
- name: Install upstream vidstab
shell: bash
working-directory: /tmp
run: "git clone -b improvements https://github.com/Karry/vid.stab.git vidstab &&
run: "git clone https://github.com/georgmartius/vid.stab.git vidstab &&
cd vidstab &&
cmake . &&
make -j $(nproc) &&
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu-2404-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ jobs:
shell: bash
run: "sudo apt-get update && sudo apt-get -y install
cmake cmake-data build-essential libmagick++-dev qtbase5-dev qtmultimedia5-dev
ffmpeg git libv4l-dev libgphoto2-dev"
ffmpeg git libv4l-dev libgphoto2-dev catch2"

- name: Install patched vidstab
- name: Install upstream vidstab
shell: bash
working-directory: /tmp
run: "git clone -b improvements https://github.com/Karry/vid.stab.git vidstab &&
run: "git clone https://github.com/georgmartius/vid.stab.git vidstab &&
cd vidstab &&
cmake . &&
make -j $(nproc) &&
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/ubuntu-2604-cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ jobs:
shell: bash
run: "sudo apt-get update && sudo apt-get -y install
cmake cmake-data build-essential libmagick++-dev qtbase5-dev qtmultimedia5-dev
ffmpeg git libv4l-dev libgphoto2-dev"
ffmpeg git libv4l-dev libgphoto2-dev catch2"

- name: Install patched vidstab
- name: Install upstream vidstab
shell: bash
working-directory: /tmp
run: "git clone -b improvements https://github.com/Karry/vid.stab.git vidstab &&
run: "git clone https://github.com/georgmartius/vid.stab.git vidstab &&
cd vidstab &&
cmake . &&
make -j $(nproc) &&
Expand Down
54 changes: 54 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,61 @@ cmake_minimum_required(VERSION 3.10)

project(timelapse)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/CMakeMod")
list(APPEND CMAKE_MODULE_PATH "CMakeMod")

FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Multimedia)
FIND_PACKAGE(ImageMagick REQUIRED COMPONENTS Magick++ MagickCore)
FIND_PACKAGE(VidStab REQUIRED)
FIND_PACKAGE(V4L REQUIRED)
FIND_PACKAGE(GPHOTO2 REQUIRED)

# enable warnings
ADD_DEFINITIONS( -Wall -Wextra -pedantic -fPIC)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX OR CMAKE_COMPILER_IS_GNUCC)
set(TIMELAPS_WARNING_FLAGS "-Wall -pedantic -Winit-self -Wno-overloaded-virtual -Wcast-qual -Wwrite-strings -Wextra -Wno-long-long")
if(EMSCRIPTEN)
set(TIMELAPS_WARNING_FLAGS "${TIMELAPS_WARNING_FLAGS} -Wno-warn-absolute-paths")
elseif(NOT APPLE)
set(TIMELAPS_WARNING_FLAGS "${TIMELAPS_WARNING_FLAGS} -Wno-unused-but-set-parameter")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TIMELAPS_WARNING_FLAGS}")
endif()

# QT5 definitions
ADD_DEFINITIONS(${Qt5Core_DEFINITIONS})

# read and setup ImageMagick cflags (these flags are not setup by FindImageMagick.cmake)
FIND_PACKAGE(PkgConfig REQUIRED)
pkg_check_modules(IM "ImageMagick")
# ImageMagick compile time configuration
# ADD_DEFINITIONS(-DMAGICKCORE_QUANTUM_DEPTH=16) # Number of bits in a pixel Quantum (8/16/32/64)
# ADD_DEFINITIONS(-DMAGICKCORE_HDRI_SUPPORT=0) # colorHistogram fails with SIGSEGV when this option is enabled
ADD_DEFINITIONS(${IM_CFLAGS})

find_package(Catch2 3 QUIET)


add_subdirectory(src)

enable_testing()
add_subdirectory(test)

## for debug
message(STATUS "Module path: ${CMAKE_MODULE_PATH}")
message(STATUS "Qt5Core_INCLUDE_DIRS: ${Qt5Core_INCLUDE_DIRS}")
message(STATUS "Qt5Core_DEFINITIONS: ${Qt5Core_DEFINITIONS}")
message(STATUS "ImageMagick_INCLUDE_DIRS: ${ImageMagick_INCLUDE_DIRS}")
message(STATUS "ImageMagick_LIBRARIES: ${ImageMagick_LIBRARIES}")
message(STATUS "IM_CFLAGS: ${IM_CFLAGS}")
message(STATUS "VIDSTAB_INCLUDE_DIRS: ${VIDSTAB_INCLUDE_DIRS}")
message(STATUS "VIDSTAB_LIBRARIES: ${VIDSTAB_LIBRARIES}")
message(STATUS "VIDSTAB_FOUND: ${VIDSTAB_FOUND}")
message(STATUS "V4L_INCLUDE_DIRS: ${V4L_INCLUDE_DIRS}")
message(STATUS "V4L_LIBRARIES: ${V4L_LIBRARIES}")
message(STATUS "V4L_FOUND: ${V4L_FOUND}")
message(STATUS "V4L_DEFINITIONS: ${V4L_DEFINITIONS}")
message(STATUS "GPHOTO2_FOUND: ${GPHOTO2_FOUND}")
message(STATUS "GPHOTO2_INCLUDE_DIR: ${GPHOTO2_INCLUDE_DIR}")
message(STATUS "GPHOTO2_LIBRARIES: ${GPHOTO2_LIBRARIES}")
message(STATUS "Catch2_FOUND: ${Catch2_FOUND}")
4 changes: 1 addition & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,14 @@ sudo apt-get install cmake cmake-data build-essential libmagick++-dev qtbase5-de

build & install libvidstab*:
```
git clone -b improvements https://github.com/Karry/vid.stab.git vidstab
git clone https://github.com/georgmartius/vid.stab.git vidstab
cd vidstab
cmake .
make -j `nproc`
sudo make install
sudo ldconfig
cd ..
```
* This fork of vid.stab contains some fixes for processing RGB image that are not merged to
to upstream yet ( https://github.com/georgmartius/vid.stab )

build & install TimeLapse tools:

Expand Down
60 changes: 5 additions & 55 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,6 @@
# Find includes in corresponding build directories
set(CMAKE_INCLUDE_CURRENT_DIR ON)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_HOME_DIRECTORY}/CMakeMod")
list(APPEND CMAKE_MODULE_PATH "../CMakeMod")

FIND_PACKAGE(Qt5 REQUIRED COMPONENTS Core Multimedia)
FIND_PACKAGE(ImageMagick REQUIRED COMPONENTS Magick++ MagickCore)
FIND_PACKAGE(VidStab REQUIRED)
FIND_PACKAGE(V4L REQUIRED)
FIND_PACKAGE(GPHOTO2 REQUIRED)

set(DESCRIBE_CMD "git describe --tags --dirty=+dirty --match 'v[0-9]*' | sed -E 's/^v//' ")
execute_process(
COMMAND bash -c "${DESCRIBE_CMD}"
Expand All @@ -35,47 +26,6 @@ include_directories(
${V4L_INCLUDE_DIRS}
${GPHOTO2_INCLUDE_DIR})

# enable warnings
ADD_DEFINITIONS( -Wall -Wextra -pedantic -fPIC)
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX OR CMAKE_COMPILER_IS_GNUCC)
set(TIMELAPS_WARNING_FLAGS "-Wall -pedantic -Winit-self -Wno-overloaded-virtual -Wcast-qual -Wwrite-strings -Wextra -Wno-long-long")
if(EMSCRIPTEN)
set(TIMELAPS_WARNING_FLAGS "${TIMELAPS_WARNING_FLAGS} -Wno-warn-absolute-paths")
elseif(NOT APPLE)
set(TIMELAPS_WARNING_FLAGS "${TIMELAPS_WARNING_FLAGS} -Wno-unused-but-set-parameter")
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${TIMELAPS_WARNING_FLAGS}")
endif()

# QT5 definitions
ADD_DEFINITIONS(${Qt5Core_DEFINITIONS})

# read and setup ImageMagick cflags (these flags are not setup by FindImageMagick.cmake)
FIND_PACKAGE(PkgConfig REQUIRED)
pkg_check_modules(IM "ImageMagick")
# ImageMagick compile time configuration
# ADD_DEFINITIONS(-DMAGICKCORE_QUANTUM_DEPTH=16) # Number of bits in a pixel Quantum (8/16/32/64)
# ADD_DEFINITIONS(-DMAGICKCORE_HDRI_SUPPORT=0) # colorHistogram fails with SIGSEGV when this option is enabled
ADD_DEFINITIONS(${IM_CFLAGS})

## for debug
message(STATUS "Module path: ${CMAKE_MODULE_PATH}")
message(STATUS "Qt5Core_INCLUDE_DIRS: ${Qt5Core_INCLUDE_DIRS}")
message(STATUS "Qt5Core_DEFINITIONS: ${Qt5Core_DEFINITIONS}")
message(STATUS "ImageMagick_INCLUDE_DIRS: ${ImageMagick_INCLUDE_DIRS}")
message(STATUS "ImageMagick_LIBRARIES: ${ImageMagick_LIBRARIES}")
message(STATUS "IM_CFLAGS: ${IM_CFLAGS}")
message(STATUS "VIDSTAB_INCLUDE_DIRS: ${VIDSTAB_INCLUDE_DIRS}")
message(STATUS "VIDSTAB_LIBRARIES: ${VIDSTAB_LIBRARIES}")
message(STATUS "VIDSTAB_FOUND: ${VIDSTAB_FOUND}")
message(STATUS "V4L_INCLUDE_DIRS: ${V4L_INCLUDE_DIRS}")
message(STATUS "V4L_LIBRARIES: ${V4L_LIBRARIES}")
message(STATUS "V4L_FOUND: ${V4L_FOUND}")
message(STATUS "V4L_DEFINITIONS: ${V4L_DEFINITIONS}")
message(STATUS "GPHOTO2_FOUND: ${GPHOTO2_FOUND}")
message(STATUS "GPHOTO2_INCLUDE_DIR: ${GPHOTO2_INCLUDE_DIR}")
message(STATUS "GPHOTO2_LIBRARIES: ${GPHOTO2_LIBRARIES}")

set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)

Expand Down Expand Up @@ -162,33 +112,33 @@ set_property(TARGET timelapse_capture PROPERTY CXX_STANDARD 17)
target_link_libraries(timelapse
Qt5::Core
Qt5::Multimedia
${ImageMagick_LIBRARIES} # Magick++-6.Q16
${ImageMagick_LIBRARIES} # Magick++
${VIDSTAB_LIBRARIES}
${V4L_LIBRARIES}
${GPHOTO2_LIBRARIES})

target_link_libraries(timelapse_assembly
timelapse
Qt5::Core
${ImageMagick_LIBRARIES} # Magick++-6.Q16
${ImageMagick_LIBRARIES} # Magick++
${GPHOTO2_LIBRARIES})

target_link_libraries(timelapse_deflicker
timelapse
Qt5::Core
${ImageMagick_LIBRARIES} # Magick++-6.Q16
${ImageMagick_LIBRARIES} # Magick++
)

target_link_libraries(timelapse_stabilize
timelapse
Qt5::Core
${ImageMagick_LIBRARIES} # Magick++-6.Q16
${ImageMagick_LIBRARIES} # Magick++
${VIDSTAB_LIBRARIES})

target_link_libraries(timelapse_capture
timelapse
Qt5::Core
${ImageMagick_LIBRARIES} # Magick++-6.Q16
${ImageMagick_LIBRARIES} # Magick++
${V4L_LIBRARIES}
${GPHOTO2_LIBRARIES})

Expand Down
79 changes: 79 additions & 0 deletions src/TimeLapse/magick_utils.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
/*
* Copyright (C) 2022 Lukáš Karas <lukas.karas@centrum.cz>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the
* Free Software Foundation, Inc.,
* 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/

#pragma once

#include <Magick++.h>
#include <Magick++/Color.h>
#include <Magick++/Image.h>

namespace timelapse {
// methods for Magick++ 6 vs. 7 compatibility

inline Magick::Quantum scaleDoubleToQuantum(double d) {
#if MagickLibVersion < 0x700
return Magick::Color::scaleDoubleToQuantum(d);
#else
using Magick::Quantum; // QuantumRange expands to an unqualified Quantum cast.
return static_cast<Magick::Quantum>(d*QuantumRange);
#endif
}

inline double scaleQuantumToDouble(Magick::Quantum q) {
#if MagickLibVersion < 0x700
return Magick::Color::scaleQuantumToDouble(q);
#else
using Magick::Quantum;
return static_cast<double>(q)/QuantumRange;
#endif
}

inline double redDouble(const Magick::Color &color) {
#if MagickLibVersion < 0x700
return scaleQuantumToDouble(color.redQuantum());
#else
return scaleQuantumToDouble(color.quantumRed());
#endif
}

inline double greenDouble(const Magick::Color &color) {
#if MagickLibVersion < 0x700
return scaleQuantumToDouble(color.greenQuantum());
#else
return scaleQuantumToDouble(color.quantumGreen());
#endif
}

inline double blueDouble(const Magick::Color &color) {
#if MagickLibVersion < 0x700
return scaleQuantumToDouble(color.blueQuantum());
#else
return scaleQuantumToDouble(color.quantumBlue());
#endif
}

inline void imageOpacity(Magick::Image &image, double opacity) {
#if MagickLibVersion < 0x700
image.opacity(scaleDoubleToQuantum(opacity));
#else
image.alpha(static_cast<unsigned int>(scaleDoubleToQuantum(opacity)));
#endif
}

}
9 changes: 5 additions & 4 deletions src/capture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,10 @@
*/

#include <TimeLapse/capture.h>
#include <TimeLapse/magick_utils.h>

#include <Magick++.h>
#include <ImageMagick-6/Magick++/Color.h>
#include <Magick++/Color.h>

#include <exception>
#include <vector>
Expand Down Expand Up @@ -94,9 +95,9 @@ void MatrixMeteringAlg::update(Magick::Image img) {

// compute grey-scale histogram
for (std::pair<Magick::Color, size_t> p : histogram) {
double r = Magick::Color::scaleQuantumToDouble(p.first.redQuantum());
double g = Magick::Color::scaleQuantumToDouble(p.first.greenQuantum());
double b = Magick::Color::scaleQuantumToDouble(p.first.blueQuantum());
double r = redDouble(p.first);
double g = greenDouble(p.first);
double b = blueDouble(p.first);
double grey = 0.299 * r + 0.587 * g + 0.114 * b;
int i = std::max(
std::min(GREY_HISTOGRAM_RESOLUTION, (int) (grey * ((double) GREY_HISTOGRAM_RESOLUTION))),
Expand Down
Loading
Loading