Python bindings for SPHORB feature detector
Project description
PySPHORB
Python bindings for SPHORB (Spherical ORB), a fast and robust binary feature detector optimized for spherical and panoramic images.
About
SPHORB is a feature detection and description method designed specifically for 360° panoramic images using a geodesic grid representation. It provides scale and rotation invariance while avoiding expensive spherical harmonics calculations.
This package provides Python bindings for the original C++ implementation, enabling easy integration with modern computer vision workflows using NumPy and OpenCV.
Installation
Requirements
- Python >= 3.11
- NumPy >= 2.0
- OpenCV >= 4.0
- CMake >= 3.15
- C++17 compatible compiler
From Source
pip install git+https://github.com/cshyundev/py_sphorb.git
Or clone and install locally:
git clone https://github.com/cshyundev/py_sphorb.git
cd py_sphorb
pip install .
Quick Start
import cv2
import pysphorb
# Initialize detector
detector = pysphorb.SPHORB()
# Load panoramic image
img = cv2.imread("panorama.jpg")
# Detect keypoints and compute descriptors
keypoints, descriptors = detector.detectAndCompute(img)
print(f"Detected {len(keypoints)} keypoints")
print(f"Descriptor shape: {descriptors.shape}") # (N, 32)
Usage Example
Feature Matching
import cv2
import pysphorb
# Initialize detector with custom parameters
detector = pysphorb.SPHORB(nfeatures=500, nlevels=7, b=20)
# Load two panoramic images
img1 = cv2.imread("pano1.jpg")
img2 = cv2.imread("pano2.jpg")
# Detect and compute descriptors
kp1, desc1 = detector.detectAndCompute(img1)
kp2, desc2 = detector.detectAndCompute(img2)
# Match using BFMatcher with Hamming distance
matcher = cv2.BFMatcher(cv2.NORM_HAMMING, crossCheck=False)
matches = matcher.knnMatch(desc1, desc2, k=2)
# Apply Lowe's ratio test
good_matches = []
for m_n in matches:
if len(m_n) == 2:
m, n = m_n
if m.distance < 0.75 * n.distance:
good_matches.append(m)
print(f"Found {len(good_matches)} good matches")
Visualization
# Convert keypoints to cv2.KeyPoint format for visualization
cv_kp1 = [cv2.KeyPoint(x=kp[0], y=kp[1], size=kp[2], angle=kp[3],
response=kp[4], octave=kp[5]) for kp in kp1]
cv_kp2 = [cv2.KeyPoint(x=kp[0], y=kp[1], size=kp[2], angle=kp[3],
response=kp[4], octave=kp[5]) for kp in kp2]
# Draw matches
result = cv2.drawMatches(img1, cv_kp1, img2, cv_kp2, good_matches, None,
flags=cv2.DrawMatchesFlags_NOT_DRAW_SINGLE_POINTS)
cv2.imwrite("matches.jpg", result)
API Reference
SPHORB(nfeatures=500, nlevels=7, b=20)
Initialize SPHORB detector.
Parameters:
nfeatures(int): Maximum number of features to detect (default: 500)nlevels(int): Number of pyramid levels (default: 7)b(int): Barrier threshold for feature detection (default: 20)
detectAndCompute(image)
Detect keypoints and compute descriptors.
Parameters:
image(numpy.ndarray): Input image (grayscale or BGR)
Returns:
keypoints(list): List of tuples(x, y, size, angle, response, octave)descriptors(numpy.ndarray): Binary descriptors of shape(N, 32)
detect(image)
Detect keypoints only (no descriptors).
Parameters:
image(numpy.ndarray): Input image (grayscale or BGR)
Returns:
keypoints(list): List of tuples(x, y, size, angle, response, octave)
descriptorSize()
Returns the descriptor size in bytes (always 32 for SPHORB).
descriptorType()
Returns the OpenCV descriptor type code.
Original Paper
This implementation is based on the following paper:
SPHORB: A Fast and Robust Binary Feature on the Sphere Qiang Zhao, Wei Feng, Liang Wan, Jiawan Zhang International Journal of Computer Vision, Volume 113, Number 2, Pages 143-159, June 2015
Links:
- Paper: https://cic.tju.edu.cn/faculty/lwan/paper/SPHORB/SPHORB.html
- Original C++ Code: Copyright (C) 2015 Tianjin University
Citation
If you use this code in your research, please cite:
@article{zhao2015sphorb,
title={SPHORB: A Fast and Robust Binary Feature on the Sphere},
author={Zhao, Qiang and Feng, Wei and Wan, Liang and Zhang, Jiawan},
journal={International Journal of Computer Vision},
volume={113},
number={2},
pages={143--159},
year={2015},
publisher={Springer}
}
License
This project inherits the GNU General Public License from the original SPHORB implementation. For commercial licensing inquiries, please contact the original authors.
Credits
- Original Algorithm & C++ Implementation: Qiang Zhao (qiangzhao@tju.edu.cn), Tianjin University
- Python Bindings: Created using pybind11
- Contributors: Your contributions are welcome!
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pysphorb-0.1.3.tar.gz.
File metadata
- Download URL: pysphorb-0.1.3.tar.gz
- Upload date:
- Size: 22.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9be3b0b5bd807d39f973d15a6c287c5e20dba485e2fa0461fe6db4a622854d5f
|
|
| MD5 |
aba7ba1bf3d05108e036cca0d2dc1b8a
|
|
| BLAKE2b-256 |
b403b38141a3bed00723ca0c193d6b59afcadeb3b84f1ff084c881e930119bbc
|
File details
Details for the file pysphorb-0.1.3-cp314-cp314-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: pysphorb-0.1.3-cp314-cp314-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 88.4 MB
- Tags: CPython 3.14, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
459e8670f047c7487ad2fe09ec427f3359c926ab4fd2d1abae18d60276e2b8de
|
|
| MD5 |
6060486e1a8d4322a9789ccc04c9ddbc
|
|
| BLAKE2b-256 |
f01937d76c35dd1d3a7e0e30e5c46c44caf71a9595dc05d01f2f36722f7e814f
|
File details
Details for the file pysphorb-0.1.3-cp313-cp313-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: pysphorb-0.1.3-cp313-cp313-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 88.4 MB
- Tags: CPython 3.13, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e36654dd1cf216c834a6a7db321611679875bc685b08c9554d2d9b5e56891c48
|
|
| MD5 |
524379c71341e8e88b59141cfa521081
|
|
| BLAKE2b-256 |
947c66df533c9af16f4fc6b7424a97bfcc939c785fd36fff055b46b49e617257
|
File details
Details for the file pysphorb-0.1.3-cp312-cp312-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: pysphorb-0.1.3-cp312-cp312-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 88.4 MB
- Tags: CPython 3.12, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
809aaa0479b633531ade45f3a952529bde42145c2cba07b934bde61c822f60fa
|
|
| MD5 |
1030b5bdce1c2d808393ff28d21dc491
|
|
| BLAKE2b-256 |
10cd5404bda470edb96929d99c133aaf6773f9b1e7d106bb9aed3399207ff8bb
|
File details
Details for the file pysphorb-0.1.3-cp311-cp311-manylinux_2_35_x86_64.whl.
File metadata
- Download URL: pysphorb-0.1.3-cp311-cp311-manylinux_2_35_x86_64.whl
- Upload date:
- Size: 88.4 MB
- Tags: CPython 3.11, manylinux: glibc 2.35+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.11
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1f18ab0b1977d0607d8ea9f521099f8670d4ebce08437aaaef363d66414c2266
|
|
| MD5 |
bff2bf1d36e581f18aff39167074128b
|
|
| BLAKE2b-256 |
6e6ac645c5938660fa06d7576fcb2c9e9d5594fdbc29d14fa95f3ab7bc173210
|