测试通过环境:
采用anaconda3+python3.9安装,模块版本如下
mkl-fft 1.3.1
mkl-random 1.2.2
mkl-service 2.4.0
numpy 1.22.4
Pillow 10.0.0
pip 24.2
pycolmap 0.3.0
setuptools 75.1.0
six 1.16.0
wheel 0.44.0
pycolmap安装后测试代码:
import numpy as np
import pycolmap
from PIL import Image, ImageOps
# Input should be grayscale image with range [0, 1].
img = Image.open('D:/test.jpg').convert('RGB')
img = ImageOps.grayscale(img)
img = np.array(img).astype(np.float32) / 255.
# Optional parameters:
# - options: dict or pycolmap.SiftExtractionOptions
# - device: default pycolmap.Device.auto uses the GPU if available
sift = pycolmap.Sift()
# Parameters:
# - image: HxW float array
keypoints, descriptors,_ = sift.extract(img)
# Returns:
# - keypoints: Nx4 array; format: x (j), y (i), scale, orientation
# - descriptors: Nx128 array; L2-normalized descriptors