From 9025c5d3b0dc030c342a7e9eee37309da8f8f6a0 Mon Sep 17 00:00:00 2001 From: Stefan van der Walt Date: Sat, 17 Oct 2009 12:28:33 +0200 Subject: [PATCH] Clean up opencv namespace and imports. --- scikits/image/opencv/__init__.py | 14 ++++++++------ scikits/image/opencv/tests/test_opencv_cv.py | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scikits/image/opencv/__init__.py b/scikits/image/opencv/__init__.py index e466417c..c886a88e 100644 --- a/scikits/image/opencv/__init__.py +++ b/scikits/image/opencv/__init__.py @@ -1,14 +1,11 @@ -import ctypes -import sys - from opencv_constants import * # Note: users should be able to import this module even if # the extensions are uncompiled or the opencv libraries unavailable. # In that case, the opencv functionality is simply unavailable. -cv = None -cxcore = None +loaded = False + try: from opencv_cv import * except ImportError: @@ -18,7 +15,12 @@ python setup.py build_ext -i in the source directory to build in-place. Please refer to INSTALL.txt for further detail.""" - except RuntimeError: # Libraries could not be loaded print "*** Skipping import of OpenCV functions." + del (opencv_backend, opencv_cv) +else: + loaded = True + +del opencv_constants + diff --git a/scikits/image/opencv/tests/test_opencv_cv.py b/scikits/image/opencv/tests/test_opencv_cv.py index 0ef12394..d4cc3c20 100644 --- a/scikits/image/opencv/tests/test_opencv_cv.py +++ b/scikits/image/opencv/tests/test_opencv_cv.py @@ -11,13 +11,13 @@ with warnings.catch_warnings(): warnings.simplefilter("ignore") from scikits.image.opencv import * -opencv_skip = dec.skipif(cv is None, +opencv_skip = dec.skipif(not loaded, 'OpenCV libraries not found') class OpenCVTest: lena_RGB_U8 = np.load(os.path.join(data_dir, 'lena_RGB_U8.npy')) lena_GRAY_U8 = np.load(os.path.join(data_dir, 'lena_GRAY_U8.npy')) - + class TestSobel(OpenCVTest): @opencv_skip