mirror of
https://github.com/wassname/scikit-image.git
synced 2026-08-12 12:30:16 +08:00
Change OpenCV import to make it an optional dependency
This commit is contained in:
@@ -3,9 +3,9 @@
|
||||
import cython
|
||||
cimport numpy as np
|
||||
import numpy as np
|
||||
import cv
|
||||
from scipy.signal import fftconvolve
|
||||
|
||||
|
||||
cdef extern from "math.h":
|
||||
double sqrt(double x)
|
||||
double fabs(double x)
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
"""template.py - Template matching
|
||||
"""
|
||||
import numpy as np
|
||||
import cv
|
||||
import _template
|
||||
|
||||
try:
|
||||
import cv
|
||||
opencv_available = True
|
||||
except ImportError:
|
||||
opencv_available = False
|
||||
|
||||
|
||||
|
||||
#XXX add to opencv backend once backend system in place
|
||||
def match_template_cv(image, template, out=None, method="norm-coeff"):
|
||||
@@ -23,6 +29,8 @@ def match_template_cv(image, template, out=None, method="norm-coeff"):
|
||||
Correlation results between 0.0 and 1.0, maximum indicating the most
|
||||
probable match.
|
||||
"""
|
||||
if not opencv_available:
|
||||
raise ImportError("Opencv 2.0+ required")
|
||||
if out == None:
|
||||
out = np.empty((image.shape[0] - template.shape[0] + 1,
|
||||
image.shape[1] - template.shape[1] + 1),
|
||||
|
||||
Reference in New Issue
Block a user