Skip to content

Commit

Permalink
add github actions (#133)
Browse files Browse the repository at this point in the history
* add github actions

* fix command

* fix path

* Fix pybind11 build

* fix re matching

* get rid of pybind in CI

---------

Co-authored-by: Yuxin Wu <[email protected]>
  • Loading branch information
ppwwyyxx and ppwwyyxx authored Oct 6, 2023
1 parent ed7f73d commit f9b2469
Show file tree
Hide file tree
Showing 24 changed files with 78 additions and 8,147 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: UnitTest

on:
- push
- pull_request
- workflow_call

jobs:
test:
name: Test on ${{ matrix.os }}, ${{ matrix.install_from }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest] #, windows-latest, macos-latest]
install_from: [make, cmake]

steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: "3.x"

- name: Cache files
uses: actions/cache@v3
with:
path: |
example-data/
key: ${{ runner.os }}-20231096

- name: Install dependency
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install --yes libeigen3-dev libjpeg-dev
# Didn't test pybind11. Seems to be old and incompatible with the python version.

- name: Build with make
if: matrix.install_from == 'make'
run: |
make -j -C src
- name: Build with cmake
if: matrix.install_from == 'cmake'
run: |
cmake -B build && make -j -C build
cp build/src/image-stitching ./src/
- name: Run Unittests
run: cd src && python run_test.py
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,6 @@ Debug
cmake_install.cmake
src/cmake_install.cmake
.vs/

example-data
example-data.tgz
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ On Ubuntu, install dependencies by: `sudo apt install build-essential sed cmake
#### Linux / OSX / WSL (bash on windows)
Use cmake (a good default to try):
```
$ mkdir build && cd build && cmake .. && make
$ cmake -B build && make -C build
# Binary will be found at ./build/src/image-stitching
```
or, use make (more customizable. You can modify Makefile when you run into problems.):
```
$ make -C src
# Binary will be found at ./src/image-stitching
```
The default clang on OSX doesn't contain openmp support.
You may need gcc or different clang. See [#16](https://github.com/ppwwyyxx/OpenPano/issues/16).
Expand Down Expand Up @@ -63,7 +65,8 @@ In cylinder/translation mode, the input file names need to have the correct orde

### Configuration:

Three modes are available (set/unset the options in ``config.cfg``):
The program expects to find the config file `config.cfg` in the working directory.
Three modes are available (set/unset them in the top of the config file):
+ __cylinder__ mode. Requirements:
+ You stay at the same spot and __only__ turn left (or right) when taking the images (as is usually done), no
translations or other type of rotations allowed.
Expand Down Expand Up @@ -150,6 +153,7 @@ To get the best stitching quality:
parameters are needed to undistort the images.

## TODOs
+ Github Actions for macOS and Windows
+ apply pairwise matching for translation mode as well
+ run bundle adjustment on sphere lens instead of perspective lens
+ improve feature detector and matching
Expand Down
12 changes: 5 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,9 @@ if (NOT JPEG_FOUND)
target_compile_definitions(image-stitching PUBLIC DISABLE_JPEG)
endif()

find_package(Python3 COMPONENTS Development)
if(Python3_Development_FOUND AND BUILD_SHARED_LIBS)
add_library(pyopenpano SHARED python/pybind.cc)
target_link_libraries(pyopenpano openpano pybind11)
target_include_directories(pyopenpano SYSTEM
PRIVATE ${Python3_INCLUDE_DIRS}
)
find_package(Python3 COMPONENTS Interpreter Development)
find_package(pybind11 CONFIG)
if(Python3_Development_FOUND AND BUILD_SHARED_LIBS AND pybind11_FOUND)
pybind11_add_module(pyopenpano python/pybind.cc)
target_link_libraries(pyopenpano PRIVATE openpano)
endif()
2 changes: 1 addition & 1 deletion src/lib/timer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ std::map<std::string, std::pair<int, double>> TotalTimer::rst;

void TotalTimer::print() {
for (auto& itr : rst)
print_debug("%s spent %lf secs in total, called %d times.\n",
print_debug("%s spent %.2lf secs in total, called %d times.\n",
itr.first.c_str(), itr.second.second, itr.second.first);
}

Expand Down
3 changes: 2 additions & 1 deletion src/lib/timer.hh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include <chrono>
#include <functional>
#include <map>
#include <iomanip>
#include <iostream>
#include <string>

Expand Down Expand Up @@ -35,7 +36,7 @@ class GuardedTimer: public Timer {
public:
GuardedTimer(const std::string& msg, bool enabled=true):
GuardedTimer([msg](double duration){
std::cout << msg << ": " << std::to_string(duration * 1000.) << " milliseconds." << std::endl;
std::cout << msg << ": " << std::fixed << std::setprecision(1) << duration * 1000. << " milliseconds." << std::endl;
})
{ enabled_ = enabled; }

Expand Down
24 changes: 14 additions & 10 deletions src/run_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import re

EXEC = './image-stitching'
THRESHOLD = 0.8
THRESHOLD = 0.8 # Actual size should be within (0.8, 1/0.8) of the truth

def good_size(x_test, x_truth):
ratio = x_test * 1.0 / x_truth
Expand All @@ -21,25 +21,29 @@ def test_final_size(image_globs, w, h):
print ("Testing with {}".format(image_globs))
images = sorted(glob.glob(image_globs))
cmd = [EXEC] + images
outputs = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
outputs = outputs.split(b'\n')
print (b'\n'.join(outputs))
for line in outputs:
if b'Final Image Size' in line:
m = re.match(rb'.*\(([0-9]+), ([0-9]+)\)', line)
try:
outputs = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
print("ERROR:\n", e.output.decode('utf-8'))
raise
outputs = outputs.decode('utf-8')
print(outputs)
for line in outputs.split('\n'):
if 'Final Image Size' in line:
m = re.match(r'.*\(([0-9]+), ([0-9]+)\)', line)
ww, hh = map(int, m.group(1, 2))
if good_size(ww, w) and good_size(hh, h):
return
break
print ("Test Failed!")
print("Test Failed!")
sys.exit(1)

if __name__ == '__main__':
if not os.path.isdir('example-data'):
ret = os.system('wget https://github.com/ppwwyyxx/OpenPano/releases/download/0.1/example-data.tgz')
ret = os.system('wget --progress=dot https://github.com/ppwwyyxx/OpenPano/releases/download/0.1/example-data.tgz')
assert ret == 0
ret = os.system('tar xzf example-data.tgz')
assert ret == 0
test_final_size('example-data/zijing/*', 6488, 1100)
test_final_size('example-data/CMU1/*', 8000, 1449)
print ("Tests Passed")
print("Tests Passed")
Loading

0 comments on commit f9b2469

Please sign in to comment.