mirror of
https://github.com/wassname/scikit-image.git
synced 2026-06-29 03:54:28 +08:00
added unit-tests for existing functions. and prelimenary docstrings
This commit is contained in:
@@ -5,14 +5,18 @@ import ctypes
|
||||
|
||||
# linux
|
||||
try:
|
||||
ctypes.CDLL('libcv.so')
|
||||
ctypes.CDLL('libcv.so')
|
||||
except:
|
||||
# windows
|
||||
try:
|
||||
ctypes.CDLL('cv.dll')
|
||||
except:
|
||||
except:
|
||||
raise RuntimeError('The opencv libraries were not found. Please make sure they are installed and available on the system path.')
|
||||
|
||||
from opencv_constants import *
|
||||
from opencv_cv import *
|
||||
|
||||
#def test(level=1, verbosity=1):
|
||||
# from numpy.testing import Tester
|
||||
# return Tester().test(level, verbosity)
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Generated by Cython 0.11.3 on Sat Oct 10 21:52:16 2009 */
|
||||
/* Generated by Cython 0.11.3 on Sun Oct 11 23:48:22 2009 */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
@@ -622,8 +622,8 @@ typedef npy_clongdouble __pyx_t_5numpy_clongdouble_t;
|
||||
|
||||
typedef npy_cdouble __pyx_t_5numpy_complex_t;
|
||||
|
||||
/* "/home/brucewayne/scikits_image/scikits.image/scikits/image/opencv/opencv_type.pxd":3
|
||||
* # a reimplementation of the opencv IplImage type.
|
||||
/* "/home/brucewayne/scikits_image/scikits.image/scikits/image/opencv/opencv_type.pxd":5
|
||||
* # available at build time.
|
||||
*
|
||||
* cdef struct _IplImage: # <<<<<<<<<<<<<<
|
||||
* int nSize # sizeof(_IplImage)
|
||||
@@ -657,6 +657,32 @@ struct __pyx_t_7scikits_5image_6opencv_11opencv_type__IplImage {
|
||||
|
||||
typedef struct __pyx_t_7scikits_5image_6opencv_11opencv_type__IplImage __pyx_t_7scikits_5image_6opencv_11opencv_type_IplImage;
|
||||
|
||||
/* "/home/brucewayne/scikits_image/scikits.image/scikits/image/opencv/opencv_type.pxd":38
|
||||
* ctypedef _IplImage IplImage
|
||||
*
|
||||
* ctypedef struct CvPoint2D32f: # <<<<<<<<<<<<<<
|
||||
* float x
|
||||
* float y
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
float x;
|
||||
float y;
|
||||
} __pyx_t_7scikits_5image_6opencv_11opencv_type_CvPoint2D32f;
|
||||
|
||||
/* "/home/brucewayne/scikits_image/scikits.image/scikits/image/opencv/opencv_type.pxd":42
|
||||
* float y
|
||||
*
|
||||
* ctypedef struct CvSize: # <<<<<<<<<<<<<<
|
||||
* int width
|
||||
* int height
|
||||
*/
|
||||
|
||||
typedef struct {
|
||||
int width;
|
||||
int height;
|
||||
} __pyx_t_7scikits_5image_6opencv_11opencv_type_CvSize;
|
||||
|
||||
typedef __pyx_t_5numpy_uint8_t __pyx_t_7scikits_5image_6opencv_14opencv_backend_UINT8_t;
|
||||
|
||||
typedef __pyx_t_5numpy_int8_t __pyx_t_7scikits_5image_6opencv_14opencv_backend_INT8_t;
|
||||
@@ -708,6 +734,7 @@ static int __pyx_f_7scikits_5image_6opencv_14opencv_backend_assert_not_sharing_d
|
||||
static PyArrayObject *__pyx_f_7scikits_5image_6opencv_14opencv_backend_new_array(int, npy_intp *, PyObject *); /*proto*/
|
||||
static PyArrayObject *__pyx_f_7scikits_5image_6opencv_14opencv_backend_new_array_like(PyArrayObject *); /*proto*/
|
||||
static PyArrayObject *__pyx_f_7scikits_5image_6opencv_14opencv_backend_new_array_like_diff_dtype(PyArrayObject *, PyObject *); /*proto*/
|
||||
static __pyx_t_7scikits_5image_6opencv_11opencv_type_CvPoint2D32f *__pyx_f_7scikits_5image_6opencv_14opencv_backend_as_2Dpoint_array(PyArrayObject *); /*proto*/
|
||||
#define __Pyx_MODULE_NAME "scikits.image.opencv.opencv_backend"
|
||||
int __pyx_module_is_main_scikits__image__opencv__opencv_backend = 0;
|
||||
|
||||
@@ -1977,7 +2004,7 @@ static PyArrayObject *__pyx_f_7scikits_5image_6opencv_14opencv_backend_new_arra
|
||||
* Py_INCREF(<object>dtype)
|
||||
* return PyArray_Empty(arr.ndim, arr.shape, dtype, 0) # <<<<<<<<<<<<<<
|
||||
*
|
||||
*
|
||||
* cdef CvPoint2D32f* as_2Dpoint_array(np.ndarray arr):
|
||||
*/
|
||||
__Pyx_XDECREF(((PyObject *)__pyx_r));
|
||||
__pyx_t_1 = PyArray_Empty(__pyx_v_arr->nd, __pyx_v_arr->dimensions, __pyx_v_dtype, 0); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
@@ -1999,6 +2026,44 @@ static PyArrayObject *__pyx_f_7scikits_5image_6opencv_14opencv_backend_new_arra
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/home/brucewayne/scikits_image/scikits.image/scikits/image/opencv/opencv_backend.pyx":157
|
||||
* return PyArray_Empty(arr.ndim, arr.shape, dtype, 0)
|
||||
*
|
||||
* cdef CvPoint2D32f* as_2Dpoint_array(np.ndarray arr): # <<<<<<<<<<<<<<
|
||||
* cdef CvPoint2D32f* point2Darr
|
||||
* point2Darr = <CvPoint2D32f*>arr.data
|
||||
*/
|
||||
|
||||
static __pyx_t_7scikits_5image_6opencv_11opencv_type_CvPoint2D32f *__pyx_f_7scikits_5image_6opencv_14opencv_backend_as_2Dpoint_array(PyArrayObject *__pyx_v_arr) {
|
||||
__pyx_t_7scikits_5image_6opencv_11opencv_type_CvPoint2D32f *__pyx_v_point2Darr;
|
||||
__pyx_t_7scikits_5image_6opencv_11opencv_type_CvPoint2D32f *__pyx_r;
|
||||
__Pyx_SetupRefcountContext("as_2Dpoint_array");
|
||||
|
||||
/* "/home/brucewayne/scikits_image/scikits.image/scikits/image/opencv/opencv_backend.pyx":159
|
||||
* cdef CvPoint2D32f* as_2Dpoint_array(np.ndarray arr):
|
||||
* cdef CvPoint2D32f* point2Darr
|
||||
* point2Darr = <CvPoint2D32f*>arr.data # <<<<<<<<<<<<<<
|
||||
* return point2Darr
|
||||
*
|
||||
*/
|
||||
__pyx_v_point2Darr = ((__pyx_t_7scikits_5image_6opencv_11opencv_type_CvPoint2D32f *)__pyx_v_arr->data);
|
||||
|
||||
/* "/home/brucewayne/scikits_image/scikits.image/scikits/image/opencv/opencv_backend.pyx":160
|
||||
* cdef CvPoint2D32f* point2Darr
|
||||
* point2Darr = <CvPoint2D32f*>arr.data
|
||||
* return point2Darr # <<<<<<<<<<<<<<
|
||||
*
|
||||
*
|
||||
*/
|
||||
__pyx_r = __pyx_v_point2Darr;
|
||||
goto __pyx_L0;
|
||||
|
||||
__pyx_r = 0;
|
||||
__pyx_L0:;
|
||||
__Pyx_FinishRefcountContext();
|
||||
return __pyx_r;
|
||||
}
|
||||
|
||||
/* "/usr/local/lib/python2.6/dist-packages/Cython-0.11.3-py2.6-linux-x86_64.egg/Cython/Includes/numpy.pxd":152
|
||||
* # experimental exception made for __getbuffer__ and __releasebuffer__
|
||||
* # -- the details of this may change.
|
||||
@@ -3736,6 +3801,7 @@ PyMODINIT_FUNC PyInit_opencv_backend(void)
|
||||
if (__Pyx_ExportFunction("new_array", (void (*)(void))__pyx_f_7scikits_5image_6opencv_14opencv_backend_new_array, "PyArrayObject *(int, npy_intp *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ExportFunction("new_array_like", (void (*)(void))__pyx_f_7scikits_5image_6opencv_14opencv_backend_new_array_like, "PyArrayObject *(PyArrayObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ExportFunction("new_array_like_diff_dtype", (void (*)(void))__pyx_f_7scikits_5image_6opencv_14opencv_backend_new_array_like_diff_dtype, "PyArrayObject *(PyArrayObject *, PyObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
if (__Pyx_ExportFunction("as_2Dpoint_array", (void (*)(void))__pyx_f_7scikits_5image_6opencv_14opencv_backend_as_2Dpoint_array, "__pyx_t_7scikits_5image_6opencv_11opencv_type_CvPoint2D32f *(PyArrayObject *)") < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
/*--- Type init code ---*/
|
||||
/*--- Type import code ---*/
|
||||
__pyx_ptype_5numpy_dtype = __Pyx_ImportType("numpy", "dtype", sizeof(PyArray_Descr)); if (unlikely(!__pyx_ptype_5numpy_dtype)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
|
||||
|
||||
@@ -31,4 +31,5 @@ cdef int assert_like(np.ndarray arr1, np.ndarray arr2) except -1
|
||||
cdef int assert_not_sharing_data(np.ndarray arr1, np.ndarray arr2) except -1
|
||||
cdef np.ndarray new_array(int ndim, np.npy_intp* shape, dtype)
|
||||
cdef np.ndarray new_array_like(np.ndarray arr)
|
||||
cdef np.ndarray new_array_like_diff_dtype(np.ndarray arr, dtype)
|
||||
cdef np.ndarray new_array_like_diff_dtype(np.ndarray arr, dtype)
|
||||
cdef CvPoint2D32f* as_2Dpoint_array(np.ndarray arr)
|
||||
|
||||
@@ -154,5 +154,10 @@ cdef np.ndarray new_array_like_diff_dtype(np.ndarray arr, dtype):
|
||||
Py_INCREF(<object>dtype)
|
||||
return PyArray_Empty(arr.ndim, arr.shape, dtype, 0)
|
||||
|
||||
cdef CvPoint2D32f* as_2Dpoint_array(np.ndarray arr):
|
||||
cdef CvPoint2D32f* point2Darr
|
||||
point2Darr = <CvPoint2D32f*>arr.data
|
||||
return point2Darr
|
||||
|
||||
|
||||
|
||||
|
||||
+501
-491
File diff suppressed because it is too large
Load Diff
@@ -55,6 +55,13 @@ ctypedef void (*cvCornerHarrisPtr)(IplImage*, IplImage*, int, int, double)
|
||||
cdef cvCornerHarrisPtr c_cvCornerHarris
|
||||
c_cvCornerHarris = (<cvCornerHarrisPtr*><size_t>ctypes.addressof(cv.cvCornerHarris))[0]
|
||||
|
||||
'''
|
||||
# cvFindCornerSubPix
|
||||
ctypedef void (*cvFindCornerSubPixPtr)(IplImage*, CvPoint32f*, int, CvSize, CvSize, CvTermCriteria):
|
||||
cdef cvFindCornerSubPixPtr c_cvFindCornerSubPix
|
||||
c_cvFindCornerSubPix = (<cvFindCornerSubPixPtr*><size_t><ctypes.addressof(cv.cvFindCornerSubPix))[0]
|
||||
'''
|
||||
|
||||
# cvSmooth
|
||||
ctypedef void (*cvSmoothPtr)(IplImage*, IplImage*, int, int, int, double, double)
|
||||
cdef cvSmoothPtr c_cvSmooth
|
||||
@@ -67,6 +74,12 @@ c_cvSmooth = (<cvSmoothPtr*><size_t>ctypes.addressof(cv.cvSmooth))[0]
|
||||
def cvSobel(np.ndarray src, np.ndarray out=None, int xorder=1, int yorder=0,
|
||||
int aperture_size=3):
|
||||
|
||||
"""
|
||||
better doc string needed.
|
||||
for now:
|
||||
http://opencv.willowgarage.com/documentation/cvreference.html
|
||||
"""
|
||||
|
||||
validate_array(src)
|
||||
assert_dtype(src, [UINT8, INT8, FLOAT32])
|
||||
assert_nchannels(src, [1])
|
||||
@@ -100,6 +113,13 @@ def cvSobel(np.ndarray src, np.ndarray out=None, int xorder=1, int yorder=0,
|
||||
return out
|
||||
|
||||
def cvLaplace(np.ndarray src, np.ndarray out=None, int aperture_size=3):
|
||||
|
||||
"""
|
||||
better doc string needed.
|
||||
for now:
|
||||
http://opencv.willowgarage.com/documentation/cvreference.html
|
||||
"""
|
||||
|
||||
validate_array(src)
|
||||
assert_dtype(src, [UINT8, INT8, FLOAT32])
|
||||
assert_nchannels(src, [1])
|
||||
@@ -135,6 +155,13 @@ def cvLaplace(np.ndarray src, np.ndarray out=None, int aperture_size=3):
|
||||
|
||||
def cvCanny(np.ndarray src, np.ndarray out=None, double threshold1=10,
|
||||
double threshold2=50, int aperture_size=3):
|
||||
|
||||
"""
|
||||
better doc string needed.
|
||||
for now:
|
||||
http://opencv.willowgarage.com/documentation/cvreference.html
|
||||
"""
|
||||
|
||||
validate_array(src)
|
||||
assert_nchannels(src, [1])
|
||||
|
||||
@@ -160,6 +187,13 @@ def cvCanny(np.ndarray src, np.ndarray out=None, double threshold1=10,
|
||||
return out
|
||||
|
||||
def cvPreCornerDetect(np.ndarray src, np.ndarray out=None, int aperture_size=3):
|
||||
|
||||
"""
|
||||
better doc string needed.
|
||||
for now:
|
||||
http://opencv.willowgarage.com/documentation/cvreference.html
|
||||
"""
|
||||
|
||||
validate_array(src)
|
||||
assert_dtype(src, [UINT8, FLOAT32])
|
||||
assert_nchannels(src, [1])
|
||||
@@ -186,7 +220,13 @@ def cvPreCornerDetect(np.ndarray src, np.ndarray out=None, int aperture_size=3):
|
||||
|
||||
def cvCornerEigenValsAndVecs(np.ndarray src, int block_size=3,
|
||||
int aperture_size=3):
|
||||
|
||||
|
||||
"""
|
||||
better doc string needed.
|
||||
for now:
|
||||
http://opencv.willowgarage.com/documentation/cvreference.html
|
||||
"""
|
||||
|
||||
# no option for the out argument on this one. Its easier just
|
||||
# to make it for them as there is only 1 valid out array for any
|
||||
# given source array
|
||||
@@ -215,7 +255,11 @@ def cvCornerEigenValsAndVecs(np.ndarray src, int block_size=3,
|
||||
|
||||
def cvCornerMinEigenVal(np.ndarray src, int block_size=3,
|
||||
int aperture_size=3):
|
||||
|
||||
"""
|
||||
better doc string needed.
|
||||
for now:
|
||||
http://opencv.willowgarage.com/documentation/cvreference.html
|
||||
"""
|
||||
# no option for the out argument on this one. Its easier just
|
||||
# to make it for them as there is only 1 valid out array for any
|
||||
# given source array
|
||||
@@ -240,7 +284,11 @@ def cvCornerMinEigenVal(np.ndarray src, int block_size=3,
|
||||
|
||||
def cvCornerHarris(np.ndarray src, int block_size=3, int aperture_size=3,
|
||||
double k=0.04):
|
||||
|
||||
"""
|
||||
better doc string needed.
|
||||
for now:
|
||||
http://opencv.willowgarage.com/documentation/cvreference.html
|
||||
"""
|
||||
# no option for the out argument on this one. Its easier just
|
||||
# to make it for them as there is only 1 valid out array for any
|
||||
# given source array
|
||||
@@ -263,9 +311,38 @@ def cvCornerHarris(np.ndarray src, int block_size=3, int aperture_size=3,
|
||||
|
||||
return out
|
||||
|
||||
|
||||
""" not quite finished with this one
|
||||
def cvFindCornerSubPix(np.ndarray src, np.ndarray corners, int count, win,
|
||||
zero_zone, criteria):
|
||||
validate_array(src)
|
||||
validate_array(corners)
|
||||
|
||||
assert_nchannels(src, [1])
|
||||
assert_dtype(src, UINT8)
|
||||
|
||||
assert_nchannels(corners, [1])
|
||||
assert_dtype(corners, FLOAT32)
|
||||
|
||||
# make sure the number of points
|
||||
# jives with the elements in the array
|
||||
# the shape of the array is irrelevant
|
||||
# because opencv will index it as if it were
|
||||
# flat anyway
|
||||
if a.nbytes != (count * 2 * 4):
|
||||
raise ValueError('the number of declared points is different than exists in the array')
|
||||
|
||||
cdef CvPoint32f* cvCorners = as_2Dpoint_array(corners)
|
||||
|
||||
|
||||
"""
|
||||
|
||||
def cvSmooth(np.ndarray src, np.ndarray out=None, int smoothtype=CV_GAUSSIAN, int param1=3,
|
||||
int param2=0, double param3=0, double param4=0, bool in_place=False):
|
||||
"""
|
||||
better doc string needed.
|
||||
for now:
|
||||
http://opencv.willowgarage.com/documentation/cvreference.html
|
||||
"""
|
||||
|
||||
validate_array(src)
|
||||
if out is not None:
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
# a reimplementation of the opencv IplImage type.
|
||||
# a reimplementation of the opencv types.
|
||||
# so we dont have to worry about having the opencv headers
|
||||
# available at build time.
|
||||
|
||||
cdef struct _IplImage:
|
||||
int nSize # sizeof(_IplImage)
|
||||
@@ -33,7 +35,7 @@ cdef struct _IplImage:
|
||||
|
||||
ctypedef _IplImage IplImage
|
||||
|
||||
ctypedef struct CvPoint2D32F:
|
||||
ctypedef struct CvPoint2D32f:
|
||||
float x
|
||||
float y
|
||||
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -0,0 +1,152 @@
|
||||
# test for the opencv_cv extension module
|
||||
|
||||
import numpy as np
|
||||
from numpy.testing import *
|
||||
|
||||
try:
|
||||
from scikits.image.opencv import *
|
||||
OPENCV_LIBS_NOTFOUND = False
|
||||
except:
|
||||
OPENCV_LIBS_NOTFOUND = True
|
||||
|
||||
@dec.skipif(OPENCV_LIBS_NOTFOUND, 'Skipping OpenCV test because OpenCV libs were not found')
|
||||
def test_cvSobel():
|
||||
lena_RGB_U8 = np.load('data/lena_RGB_U8.npy')
|
||||
lena_GRAY_U8 = np.load('data/lena_GRAY_U8.npy')
|
||||
lena_SOBEL_INT16 = np.load('data/lena_SOBEL_INT16.npy')
|
||||
sobel = cvSobel(lena_GRAY_U8)
|
||||
assert_array_equal(sobel, lena_SOBEL_INT16)
|
||||
assert_raises(Exception, cvSobel, lena_RGB_U8)
|
||||
assert_raises(Exception, cvSobel, (lena_GRAY_U8, lena_GRAY_U8))
|
||||
assert_raises(Exception, cvSobel, lena_GRAY_U8, {'aperture_size':1})
|
||||
assert_raises(Exception, cvSobel, lena_GRAY_U8, {'aperture_size':2})
|
||||
assert_raises(Exception, cvSobel, lena_GRAY_U8, {'aperture_size':4})
|
||||
assert_raises(Exception, cvSobel, lena_GRAY_U8, {'aperture_size':6})
|
||||
assert_raises(Exception, cvSobel, lena_GRAY_U8, {'aperture_size':8})
|
||||
# any need to keep going? only valid apertures are 3, 5, and 7
|
||||
# and testing the validity would require saving new images for each one
|
||||
|
||||
@dec.skipif(OPENCV_LIBS_NOTFOUND, 'Skipping OpenCV test because OpenCV libs were not found')
|
||||
def test_cvLaplace():
|
||||
lena_RGB_U8 = np.load('data/lena_RGB_U8.npy')
|
||||
lena_GRAY_U8 = np.load('data/lena_GRAY_U8.npy')
|
||||
lena_LAPLACE_INT16 = np.load('data/lena_LAPLACE_INT16.npy')
|
||||
laplace = cvLaplace(lena_GRAY_U8)
|
||||
assert_array_equal(laplace, lena_LAPLACE_INT16)
|
||||
assert_raises(Exception, cvLaplace, lena_RGB_U8)
|
||||
assert_raises(Exception, cvLaplace, (lena_GRAY_U8, lena_GRAY_U8))
|
||||
assert_raises(Exception, cvLaplace, lena_GRAY_U8, {'aperture_size':1})
|
||||
assert_raises(Exception, cvLaplace, lena_GRAY_U8, {'aperture_size':2})
|
||||
assert_raises(Exception, cvLaplace, lena_GRAY_U8, {'aperture_size':4})
|
||||
assert_raises(Exception, cvLaplace, lena_GRAY_U8, {'aperture_size':6})
|
||||
assert_raises(Exception, cvLaplace, lena_GRAY_U8, {'aperture_size':8})
|
||||
# any need to keep going? only valid apertures are 3, 5, and 7
|
||||
# and testing the validity would require saving new images for each one
|
||||
|
||||
@dec.skipif(OPENCV_LIBS_NOTFOUND, 'Skipping OpenCV test because OpenCV libs were not found')
|
||||
def test_cvCanny():
|
||||
lena_RGB_U8 = np.load('data/lena_RGB_U8.npy')
|
||||
lena_GRAY_U8 = np.load('data/lena_GRAY_U8.npy')
|
||||
lena_CANNY_U8 = np.load('data/lena_CANNY_U8.npy')
|
||||
canny = cvCanny(lena_GRAY_U8)
|
||||
assert_array_equal(canny, lena_CANNY_U8)
|
||||
assert_raises(Exception, cvCanny, lena_RGB_U8)
|
||||
assert_raises(Exception, cvCanny, (lena_GRAY_U8, lena_GRAY_U8))
|
||||
assert_raises(Exception, cvCanny, lena_GRAY_U8, {'aperture_size':1})
|
||||
assert_raises(Exception, cvCanny, lena_GRAY_U8, {'aperture_size':2})
|
||||
assert_raises(Exception, cvCanny, lena_GRAY_U8, {'aperture_size':4})
|
||||
assert_raises(Exception, cvCanny, lena_GRAY_U8, {'aperture_size':6})
|
||||
assert_raises(Exception, cvCanny, lena_GRAY_U8, {'aperture_size':8})
|
||||
# any need to keep going? only valid apertures are 3, 5, and 7
|
||||
# and testing the validity would require saving new images for each one
|
||||
|
||||
@dec.skipif(OPENCV_LIBS_NOTFOUND, 'Skipping OpenCV test because OpenCV libs were not found')
|
||||
def test_cvPreCornerDetect():
|
||||
lena_RGB_U8 = np.load('data/lena_RGB_U8.npy')
|
||||
lena_GRAY_U8 = np.load('data/lena_GRAY_U8.npy')
|
||||
lena_GRAY_FLOAT32 = np.load('data/lena_GRAY_FLOAT32.npy')
|
||||
lena_PRECORNERDETECT_U8 = np.load('data/lena_PRECORNERDETECT_U8.npy')
|
||||
lena_PRECORNERDETECT_FLOAT32 = np.load('data/lena_PRECORNERDETECT_FLOAT32.npy')
|
||||
pcd8 = cvPreCornerDetect(lena_GRAY_U8)
|
||||
pcd32 = cvPreCornerDetect(lena_GRAY_FLOAT32)
|
||||
assert_array_almost_equal(pcd8, lena_PRECORNERDETECT_U8)
|
||||
assert_array_almost_equal(pcd32, lena_PRECORNERDETECT_FLOAT32)
|
||||
assert_raises(Exception, cvPreCornerDetect, lena_RGB_U8)
|
||||
assert_raises(Exception, cvPreCornerDetect, (lena_GRAY_U8, lena_GRAY_U8))
|
||||
assert_raises(Exception, cvPreCornerDetect, (lena_GRAY_U8, lena_PRECORNERDETECT_U8))
|
||||
assert_raises(Exception, cvPreCornerDetect, lena_GRAY_U8, {'aperture_size':1})
|
||||
assert_raises(Exception, cvPreCornerDetect, lena_GRAY_U8, {'aperture_size':2})
|
||||
assert_raises(Exception, cvPreCornerDetect, lena_GRAY_U8, {'aperture_size':4})
|
||||
assert_raises(Exception, cvPreCornerDetect, lena_GRAY_U8, {'aperture_size':6})
|
||||
assert_raises(Exception, cvPreCornerDetect, lena_GRAY_U8, {'aperture_size':8})
|
||||
|
||||
@dec.skipif(OPENCV_LIBS_NOTFOUND, 'Skipping OpenCV test because OpenCV libs were not found')
|
||||
def test_cvCornerEigenValsAndVecs():
|
||||
lena_RGB_U8 = np.load('data/lena_RGB_U8.npy')
|
||||
lena_GRAY_U8 = np.load('data/lena_GRAY_U8.npy')
|
||||
lena_GRAY_FLOAT32 = np.load('data/lena_GRAY_FLOAT32.npy')
|
||||
lena_CEVAV_U8 = np.load('data/lena_CEVAV_U8.npy')
|
||||
lena_CEVAV_FLOAT32 = np.load('data/lena_CEVAV_FLOAT32.npy')
|
||||
cevav8 = cvCornerEigenValsAndVecs(lena_GRAY_U8)
|
||||
cevav32 = cvCornerEigenValsAndVecs(lena_GRAY_FLOAT32)
|
||||
assert_array_almost_equal(cevav8, lena_CEVAV_U8)
|
||||
assert_array_almost_equal(cevav32, lena_CEVAV_FLOAT32)
|
||||
assert_raises(Exception, cvCornerEigenValsAndVecs, lena_RGB_U8)
|
||||
assert_raises(Exception, cvCornerEigenValsAndVecs, lena_GRAY_U8, {'aperture_size':1})
|
||||
assert_raises(Exception, cvCornerEigenValsAndVecs, lena_GRAY_U8, {'aperture_size':2})
|
||||
assert_raises(Exception, cvCornerEigenValsAndVecs, lena_GRAY_U8, {'aperture_size':4})
|
||||
assert_raises(Exception, cvCornerEigenValsAndVecs, lena_GRAY_U8, {'aperture_size':6})
|
||||
assert_raises(Exception, cvCornerEigenValsAndVecs, lena_GRAY_U8, {'aperture_size':8})
|
||||
|
||||
@dec.skipif(OPENCV_LIBS_NOTFOUND, 'Skipping OpenCV test because OpenCV libs were not found')
|
||||
def test_cvCornerMinEigenVal():
|
||||
lena_RGB_U8 = np.load('data/lena_RGB_U8.npy')
|
||||
lena_GRAY_U8 = np.load('data/lena_GRAY_U8.npy')
|
||||
lena_GRAY_FLOAT32 = np.load('data/lena_GRAY_FLOAT32.npy')
|
||||
lena_CMEV_U8 = np.load('data/lena_CMEV_U8.npy')
|
||||
lena_CMEV_FLOAT32 = np.load('data/lena_CMEV_FLOAT32.npy')
|
||||
cmev8 = cvCornerMinEigenVal(lena_GRAY_U8)
|
||||
cmev32 = cvCornerMinEigenVal(lena_GRAY_FLOAT32)
|
||||
assert_array_almost_equal(cmev8, lena_CMEV_U8)
|
||||
assert_array_almost_equal(cmev32, lena_CMEV_FLOAT32)
|
||||
assert_raises(Exception, cvCornerMinEigenVal, lena_RGB_U8)
|
||||
assert_raises(Exception, cvCornerMinEigenVal, lena_GRAY_U8, {'aperture_size':1})
|
||||
assert_raises(Exception, cvCornerMinEigenVal, lena_GRAY_U8, {'aperture_size':2})
|
||||
assert_raises(Exception, cvCornerMinEigenVal, lena_GRAY_U8, {'aperture_size':4})
|
||||
assert_raises(Exception, cvCornerMinEigenVal, lena_GRAY_U8, {'aperture_size':6})
|
||||
assert_raises(Exception, cvCornerMinEigenVal, lena_GRAY_U8, {'aperture_size':8})
|
||||
|
||||
@dec.skipif(OPENCV_LIBS_NOTFOUND, 'Skipping OpenCV test because OpenCV libs were not found')
|
||||
def test_cvCornerHarris():
|
||||
lena_RGB_U8 = np.load('data/lena_RGB_U8.npy')
|
||||
lena_GRAY_U8 = np.load('data/lena_GRAY_U8.npy')
|
||||
lena_GRAY_FLOAT32 = np.load('data/lena_GRAY_FLOAT32.npy')
|
||||
lena_HARRIS_U8 = np.load('data/lena_HARRIS_U8.npy')
|
||||
lena_HARRIS_FLOAT32 = np.load('data/lena_HARRIS_FLOAT32.npy')
|
||||
hc8 = cvCornerHarris(lena_GRAY_U8)
|
||||
hc32 = cvCornerHarris(lena_GRAY_FLOAT32)
|
||||
assert_array_almost_equal(hc8, lena_HARRIS_U8)
|
||||
assert_array_almost_equal(hc32, lena_HARRIS_FLOAT32)
|
||||
assert_raises(Exception, cvCornerHarris, lena_RGB_U8)
|
||||
assert_raises(Exception, cvCornerHarris, lena_GRAY_U8, {'aperture_size':1})
|
||||
assert_raises(Exception, cvCornerHarris, lena_GRAY_U8, {'aperture_size':2})
|
||||
assert_raises(Exception, cvCornerHarris, lena_GRAY_U8, {'aperture_size':4})
|
||||
assert_raises(Exception, cvCornerHarris, lena_GRAY_U8, {'aperture_size':6})
|
||||
assert_raises(Exception, cvCornerHarris, lena_GRAY_U8, {'aperture_size':8})
|
||||
|
||||
@dec.skipif(OPENCV_LIBS_NOTFOUND, 'Skipping OpenCV test because OpenCV libs were not found')
|
||||
def test_cvSmooth():
|
||||
lena_RGB_U8 = np.load('data/lena_RGB_U8.npy')
|
||||
lena_GRAY_U8 = np.load('data/lena_GRAY_U8.npy')
|
||||
lena_GAUSSRGB_U8 = np.load('data/lena_GAUSSRGB_U8.npy')
|
||||
lena_GAUSSGRAY_U8 = np.load('data/lena_GAUSSGRAY_U8.npy')
|
||||
gaussrgb = cvSmooth(lena_RGB_U8)
|
||||
gaussgray = cvSmooth(lena_GRAY_U8)
|
||||
assert_array_equal(gaussrgb, lena_GAUSSRGB_U8)
|
||||
assert_array_equal(gaussgray, lena_GAUSSGRAY_U8)
|
||||
assert_raises(Exception, cvSmooth, (lena_RGB_U8), {'smoothtype': CV_BLUR_NO_SCALE})
|
||||
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
run_module_suite()
|
||||
Reference in New Issue
Block a user