Skip to content

Commit

Permalink
Fix pybind11 build
Browse files Browse the repository at this point in the history
  • Loading branch information
ppwwyyxx committed Oct 6, 2023
1 parent ca1898d commit 6a24b5a
Show file tree
Hide file tree
Showing 21 changed files with 21 additions and 8,144 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:

- name: Install dependency
if: matrix.os == 'ubuntu-latest'
run: sudo apt-get install --yes libeigen3-dev libjpeg-dev
run: sudo apt-get install --yes libeigen3-dev libjpeg-dev python3-pybind11

- name: Build with make
if: matrix.install_from == 'make'
Expand All @@ -39,7 +39,7 @@ jobs:
- name: Build with cmake
if: matrix.install_from == 'cmake'
run: |
mkdir build && cmake -B build && make -C build
cmake -B build && make -j -C build
cp build/src/image-stitching ./src/
- name: Run Unittests
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ 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 && cmake -B build && make -C build
$ 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.):
Expand Down Expand Up @@ -153,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
16 changes: 9 additions & 7 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,13 @@ 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)
#add_library(pyopenpano SHARED python/pybind.cc)
#target_include_directories(pyopenpano SYSTEM
#PRIVATE ${Python3_INCLUDE_DIRS}
#)
endif()
16 changes: 8 additions & 8 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 @@ -26,24 +26,24 @@ def test_final_size(image_globs, w, h):
except subprocess.CalledProcessError as e:
print("ERROR:\n", e.output.decode('utf-8'))
raise
outputs = outputs.split(b'\n')
print (b'\n'.join(outputs))
for line in outputs:
if b'Final Image Size' in line:
outputs = outputs.decode('utf-8')
print(outputs)
for line in outputs.split('\n'):
if 'Final Image Size' in line:
m = re.match(rb'.*\(([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 6a24b5a

Please sign in to comment.