Skip to content

Commit 77ab9ba

Browse files
authored
Merge pull request #5 from nasa/staging/v4.2
Release v4.2
2 parents 23d662c + 9f754af commit 77ab9ba

File tree

70 files changed

+1267215
-967
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

70 files changed

+1267215
-967
lines changed

.github/workflows/build-wheels.yml

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Build
1+
name: Build 🐍 📦 + Publish to PyPI
22

33
on:
44
push:
@@ -92,9 +92,11 @@ jobs:
9292
-DUPSP_BUILD_TESTING=OFF -DUPSP_BUILD_APPLICATIONS=OFF -DUPSP_BUILD_PYBIND11=ON'
9393
CIBW_BEFORE_ALL_LINUX: "yum install -y perl-IPC-Cmd zip ninja-build"
9494
CIBW_BEFORE_BUILD_WINDOWS: "pip install cmake"
95-
CIBW_BUILD: "cp39-win_amd64 cp39-macosx_x86_64 cp39-manylinux_x86_64"
95+
CIBW_BUILD: "cp*-win_amd64 cp*-macosx_x86_64 cp*-manylinux_x86_64"
9696
CIBW_SKIP: "*-win32 *-manylinux_i686"
9797
CIBW_BUILD_VERBOSITY: 1
98+
CIBW_TEST_REQUIRES: pytest
99+
CIBW_TEST_COMMAND: "pytest {project}/test/python"
98100
with:
99101
package-dir: .
100102
output-dir: wheelhouse
@@ -118,3 +120,24 @@ jobs:
118120
- uses: actions/upload-artifact@v3
119121
with:
120122
path: dist/*.tar.gz
123+
124+
pypi_publish:
125+
needs: [build_wheels, build_sdist]
126+
runs-on: ubuntu-latest
127+
environment: pypi
128+
permissions:
129+
id-token: write
130+
# Upload for any push of tag starting with 'v'
131+
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
132+
steps:
133+
- uses: actions/download-artifact@v3
134+
with:
135+
# unpacks default artifact into dist/
136+
# if `name: artifact` is omitted, the action will create extra parent dir
137+
name: artifact
138+
path: dist
139+
140+
- uses: pypa/gh-action-pypi-publish@release/v1
141+
# For testing
142+
# with:
143+
# repository_url: https://test.pypi.org/legacy/

.github/workflows/unit-tests.yml

Lines changed: 17 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
# Run the uPSP project build system and unit tests.
2-
# Artifacts are installed into the runner's system Python 3 environment.
1+
# Run the uPSP C++ build system and unit tests.
32
#
43
# Notes:
54
#
@@ -26,10 +25,9 @@
2625
# - On NAS HECC systems, we build the C/C++ code with dynamic linkage due
2726
# to the available system dependencies. This is *not* a default
2827
# target supported by vcpkg, but it has a lot of community interest and
29-
# "unofficial" testing support. Ref: https://github.com/microsoft/vcpkg/issues/15006
30-
# We patch up some of the RPATH quirks using 'patchelf'.
28+
# "unofficial" testing support.
3129
#
32-
name: unit-tests
30+
name: C/C++ unit tests
3331
on:
3432
push:
3533
workflow_dispatch:
@@ -51,6 +49,8 @@ jobs:
5149

5250
steps:
5351
- uses: actions/checkout@v3
52+
with:
53+
fetch-depth: 0
5454
- uses: lukka/get-cmake@latest
5555
- name: Install dependencies (Linux)
5656
run: |
@@ -82,33 +82,22 @@ jobs:
8282
runVcpkgInstall: true
8383
# Release 2023.04.15
8484
vcpkgGitCommitId: '501db0f17ef6df184fcdbfbe0f87cde2313b6ab1'
85-
- name: Patch vcpkg library headers with patchelf
86-
run: |
87-
cd vcpkg
88-
${{ github.workspace }}/.github/workflows/vcpkg-fix-rpaths
89-
cd ..
90-
- uses: actions/setup-python@v4
91-
with:
92-
python-version: ${{ matrix.python-version }}
93-
cache: 'pip'
94-
- name: Upgrade pip to v23+
95-
run: |
96-
pip install --upgrade pip
97-
pip --version
98-
python --version
99-
- name: Run build+install with pip
85+
- name: Run CMake build
10086
run: |
101-
SKBUILD_CONFIGURE_OPTIONS=\
102-
" -DCMAKE_TOOLCHAIN_FILE=${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"\
103-
" -DVCPKG_TARGET_TRIPLET=x64-linux-dynamic" pip install -v .
87+
mkdir build
88+
cd build
89+
cmake \
90+
-DCMAKE_TOOLCHAIN_FILE="${VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" \
91+
-DVCPKG_TARGET_TRIPLET="x64-linux-dynamic" \
92+
-DUPSP_BUILD_TESTING=ON \
93+
-DUPSP_BUILD_APPLICATIONS=ON \
94+
-DUPSP_BUILD_PYBIND11=ON \
95+
..
96+
make -j
10497
# - name: Setup upterm session
10598
# uses: lhotari/action-upterm@v1
10699
- name: Run C/C++ unit tests
107-
# TODO this should be made cross-platform. Currently works only for ubuntu-latest
108-
# TODO fix RUNPATH of built executables to avoid use of LD_LIBRARY_PATH
109100
run: |
110-
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:${{ env.VCPKG_INSTALLED_DIR }}/${{ env.VCPKG_DEFAULT_TRIPLET }}/lib"
111-
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
112101
cd cpp/test
113-
../../_skbuild/linux-x86_64-3.9/cmake-build/run_tests
102+
../../build/cpp/test/run_tests
114103

.github/workflows/vcpkg-fix-rpaths

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/vcpkg-triplets/x64-linux-dynamic.cmake

Lines changed: 0 additions & 32 deletions
This file was deleted.

.github/workflows/vcpkg.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,5 @@
1515
"ilmbase",
1616
"gtest",
1717
"pybind11"
18-
],
19-
"vcpkg-configuration": {
20-
"overlay-triplets": ["./vcpkg-triplets"]
21-
}
18+
]
2219
}

cpp/CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
include_directories(include)
22

3-
option(UPSP_BUILD_APPLICATIONS "Build applications" ON)
4-
option(UPSP_BUILD_PYBIND11 "Build Python bindings" ON)
5-
option(UPSP_BUILD_TESTING "Build unit tests" ON)
3+
option(UPSP_BUILD_APPLICATIONS "Build applications" OFF)
4+
option(UPSP_BUILD_PYBIND11 "Build Python bindings" OFF)
5+
option(UPSP_BUILD_TESTING "Build unit tests" OFF)
66

77
if (UPSP_BUILD_APPLICATIONS)
88
add_subdirectory(exec)

cpp/exec/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ target_link_libraries(upsp-extract-frames opencv_videoio)
2626
target_include_directories(upsp-extract-frames SYSTEM PRIVATE ${Boost_INCLUDE_DIR})
2727

2828
add_executable(add_field add_field.cpp)
29-
target_link_libraries(add_field upsp_video)
3029
target_link_libraries(add_field upsp_utils)
3130
target_link_libraries(add_field hdf5::hdf5_cpp-shared hdf5::hdf5_hl_cpp-shared)
3231

cpp/exec/psp_process.cpp

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,7 +1661,21 @@ int phase1(Phase1Settings& sett, P1Elems& elems) {
16611661
// register the image to the first frame
16621662
if (ifile.registration == upsp::RegistrationType::Pixel) {
16631663
cv::Mat warp_matrix;
1664-
img = upsp::register_pixel(first_frames_32f[c], img, warp_matrix);
1664+
const int max_iters = 50;
1665+
const double epsilon = 0.001;
1666+
int interpolation_flags = 0;
1667+
switch(ifile.pixel_interpolation) {
1668+
case upsp::PixelInterpolationType::Linear:
1669+
interpolation_flags = cv::INTER_LINEAR;
1670+
break;
1671+
case upsp::PixelInterpolationType::Nearest:
1672+
interpolation_flags = cv::INTER_NEAREST;
1673+
break;
1674+
}
1675+
img = upsp::register_pixel(
1676+
first_frames_32f[c], img, warp_matrix,
1677+
max_iters, epsilon, interpolation_flags
1678+
);
16651679
}
16661680

16671681
// patch frame
@@ -1762,7 +1776,21 @@ int phase1(Phase1Settings& sett, P1Elems& elems) {
17621776
// register the image to the first frame
17631777
if ((f > 0) && (ifile.registration == upsp::RegistrationType::Pixel)) {
17641778
cv::Mat warp_matrix;
1765-
img = upsp::register_pixel(elems.first_frames[c], img, warp_matrix);
1779+
const int max_iters = 50;
1780+
const double epsilon = 0.001;
1781+
int interpolation_flags = 0;
1782+
switch(ifile.pixel_interpolation) {
1783+
case upsp::PixelInterpolationType::Linear:
1784+
interpolation_flags = cv::INTER_LINEAR;
1785+
break;
1786+
case upsp::PixelInterpolationType::Nearest:
1787+
interpolation_flags = cv::INTER_NEAREST;
1788+
break;
1789+
}
1790+
img = upsp::register_pixel(
1791+
elems.first_frames[c], img, warp_matrix,
1792+
max_iters, epsilon, interpolation_flags
1793+
);
17661794
}
17671795

17681796
// patch frame

cpp/include/registration.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,16 @@ struct RegisterImage : std::unary_function<cv::Mat, cv::Mat> {
5353
* @param[in] max_iters maximum number of iterations for ECC algorithm
5454
* @param[in] epsilon threshold of the increment in correlation coefficient between
5555
* two iterations, criteria for ECC algorithm to stop
56+
* @param[in] interpolation_flags pixel interpolation method for image warping
57+
* two iterations, criteria for ECC algorithm to stop
5658
* @return @a inp_img warped to align with @a ref_img
5759
*
5860
* @pre @a ref_img and @a inp_img are grayscale images
5961
* @pre @a ref_img is CV_32F
6062
*/
6163
cv::Mat register_pixel(const cv::Mat& ref_img, const cv::Mat& inp_img,
62-
cv::Mat& warp_matrix, int max_iters=50, double epsilon=0.001);
64+
cv::Mat& warp_matrix, int max_iters=50, double epsilon=0.001,
65+
int interpolation_flags=cv::INTER_LINEAR);
6366

6467
/** Remove match pairs where the distance between the points is significantly large
6568
*

cpp/include/upsp_inputs.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ enum class TargetPatchType { None, Polynomial };
2626

2727
/** Registration method */
2828
enum class RegistrationType { None, Point, Pixel };
29+
enum class PixelInterpolationType { Linear, Nearest };
2930

3031
/** Type of spatial filter */
3132
enum class FilterType { None, Gaussian, Box };
@@ -78,6 +79,7 @@ class FileInputs {
7879
GridType grid_type;
7980
TargetPatchType target_patcher;
8081
RegistrationType registration;
82+
PixelInterpolationType pixel_interpolation;
8183
FilterType filter;
8284
OverlapType overlap;
8385
unsigned int filter_size;
@@ -174,6 +176,9 @@ std::ostream& operator<<(std::ostream& os, const upsp::TargetPatchType& tpt);
174176
/** Add registration type string to stream */
175177
std::ostream& operator<<(std::ostream& os, const upsp::RegistrationType& rt);
176178

179+
/** Add pixel interpolation type string to stream */
180+
std::ostream& operator<<(std::ostream& os, const upsp::PixelInterpolationType& pt);
181+
177182
/** Add filter type string to stream */
178183
std::ostream& operator<<(std::ostream& os, const upsp::FilterType& ft);
179184

cpp/lib/P3DModel.ipp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
*/
66
#include "logging.h"
77
#include "plot3d.h"
8+
#include "utils/pspError.h"
89

910
namespace upsp {
1011

cpp/lib/registration.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ cv::Mat RegisterImage::operator()(cv::Mat inp) {
3030

3131
/*****************************************************************************/
3232
cv::Mat register_pixel(const cv::Mat& ref_img, const cv::Mat& inp_img,
33-
cv::Mat& warp_matrix, int max_iters/*=50*/, double epsilon/*=0.001*/) {
33+
cv::Mat& warp_matrix, int max_iters/*=50*/, double epsilon/*=0.001*/,
34+
int interpolation_flags/*=cv::INTER_LINEAR*/) {
3435

3536
// grayscale and ref CV_32F
3637
assert(ref_img.channels() == 1);
@@ -65,11 +66,15 @@ cv::Mat register_pixel(const cv::Mat& ref_img, const cv::Mat& inp_img,
6566
// get the warped image
6667
cv::Mat warp_img;
6768
if (warp_mode != cv::MOTION_HOMOGRAPHY) {
68-
cv::warpAffine(inp_img, warp_img, warp_matrix, ref_img.size(), cv::INTER_LINEAR +
69-
cv::WARP_INVERSE_MAP);
69+
cv::warpAffine(
70+
inp_img, warp_img, warp_matrix, ref_img.size(),
71+
interpolation_flags | cv::WARP_INVERSE_MAP
72+
);
7073
} else {
71-
cv::warpPerspective(inp_img, warp_img, warp_matrix, ref_img.size(), cv::INTER_LINEAR +
72-
cv::WARP_INVERSE_MAP);
74+
cv::warpPerspective(
75+
inp_img, warp_img, warp_matrix, ref_img.size(),
76+
interpolation_flags | cv::WARP_INVERSE_MAP
77+
);
7378
}
7479

7580
return warp_img;

0 commit comments

Comments
 (0)