mirror of
https://github.com/wassname/scikit-image.git
synced 2026-07-23 13:10:18 +08:00
added a setup.py, moved the data files to the head folder.
This commit is contained in:
@@ -6,3 +6,4 @@ doc/source/api
|
||||
doc/build
|
||||
source/api
|
||||
scikits/image/opencv/*.so
|
||||
scikits/image/opencv/*.bak
|
||||
|
||||
|
Before Width: | Height: | Size: 32 KiB After Width: | Height: | Size: 32 KiB |
|
Before Width: | Height: | Size: 11 KiB After Width: | Height: | Size: 11 KiB |
@@ -1,4 +1,6 @@
|
||||
Until we come to a solution for a setup.py, execute the included shell script build.sh
|
||||
You can try to use the setup.py but it may still be broken
|
||||
|
||||
Until we come to a solution for a setup.py, execute the included shell script build.sh and copy the .so's to wherever you want them
|
||||
|
||||
scikit/image/opencv$./build.sh
|
||||
scikit/image/opencv$cd tests
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
Copyright (C) 2009 Steven C. Colbert <sccolbert@gmail.com>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
1. Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Neither the name of scikits.image nor the names of its
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
||||
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
|
||||
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
||||
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Generated by Cython 0.11.3 on Tue Oct 13 00:28:25 2009 */
|
||||
/* Generated by Cython 0.11.3 on Wed Oct 14 12:47:10 2009 */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Generated by Cython 0.11.3 on Tue Oct 13 00:28:27 2009 */
|
||||
/* Generated by Cython 0.11.3 on Wed Oct 14 12:47:11 2009 */
|
||||
|
||||
#define PY_SSIZE_T_CLEAN
|
||||
#include "Python.h"
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import shutil
|
||||
|
||||
current_dir = os.path.dirname(__file__)
|
||||
|
||||
def configuration(parent_package='', top_path=None):
|
||||
from numpy.distutils.misc_util import Configuration, get_numpy_include_dirs
|
||||
config = Configuration('opencv', parent_package, top_path)
|
||||
|
||||
config.add_data_dir(os.path.join(current_dir, 'tests'))
|
||||
|
||||
# since distutils/cython has problems, we'll check to see if cython is
|
||||
# installed and use that to rebuild the .c files, if not, we'll just build
|
||||
# direct from the included .c files
|
||||
|
||||
# if the cython compilation fails, it will overwrite the good .c files
|
||||
# so we back them up first
|
||||
|
||||
src = os.path.join(current_dir, 'opencv_cv.c')
|
||||
dst = os.path.join(current_dir, 'opencv_cv.c.bak')
|
||||
shutil.copy(src, dst)
|
||||
src = os.path.join(current_dir, 'opencv_backend.c')
|
||||
dst = os.path.join(current_dir, 'opencv_backend.c.bak')
|
||||
shutil.copy(src, dst)
|
||||
|
||||
try:
|
||||
import cython
|
||||
# no way to check the cython version number????
|
||||
os.system('cython opencv_backend.pyx')
|
||||
os.system('cython opencv_cv.pyx')
|
||||
|
||||
# if the cython compilation failed, the resulting file
|
||||
# size will be very small ~ 78 bytes
|
||||
f1 = os.path.join(current_dir, 'opencv_cv.c')
|
||||
f2 = os.path.join(current_dir, 'opencv_backend.c')
|
||||
size1 = os.path.getsize(f1)
|
||||
size2 = os.path.getsize(f2)
|
||||
assert size1 > 100 and size2 > 100
|
||||
except:
|
||||
print 'Cython compilation failed. Building from backups.'
|
||||
src = os.path.join(current_dir, 'opencv_cv.c.bak')
|
||||
dst = os.path.join(current_dir, 'opencv_cv.c')
|
||||
shutil.copy(src, dst)
|
||||
src = os.path.join(current_dir, 'opencv_backend.c.bak')
|
||||
dst = os.path.join(current_dir, 'opencv_backend.c')
|
||||
shutil.copy(src, dst)
|
||||
|
||||
config.add_extension('opencv_backend', sources=['opencv_backend.c'],
|
||||
include_dirs=[get_numpy_include_dirs()])
|
||||
|
||||
config.add_extension('opencv_cv', sources=['opencv_cv.c'],
|
||||
include_dirs=[get_numpy_include_dirs()])
|
||||
|
||||
return config
|
||||
|
||||
if __name__ == '__main__':
|
||||
from numpy.distutils.core import setup
|
||||
setup(maintainer = 'Scikits.Image Developers',
|
||||
author = 'Steven C. Colbert',
|
||||
maintainer_email = 'scikits-image@googlegroups.com',
|
||||
description = 'OpenCV wrapper for NumPy arrays',
|
||||
url = 'http://stefanv.github.com/scikits.image/',
|
||||
license = 'SciPy License (BSD Style)',
|
||||
**(configuration(top_path='').todict())
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# test for the opencv_cv extension module
|
||||
|
||||
import os
|
||||
import numpy as np
|
||||
from numpy.testing import *
|
||||
|
||||
@@ -9,6 +9,8 @@ try:
|
||||
except:
|
||||
OPENCV_LIBS_NOTFOUND = True
|
||||
|
||||
from scikits.image import data_dir
|
||||
|
||||
_opencv_skip = dec.skipif(OPENCV_LIBS_NOTFOUND,
|
||||
'Skipping OpenCV test because OpenCV'
|
||||
'libs were not found')
|
||||
@@ -16,8 +18,8 @@ _opencv_skip = dec.skipif(OPENCV_LIBS_NOTFOUND,
|
||||
class OpenCVTest:
|
||||
# setup only works as a module level function
|
||||
def __init__(self):
|
||||
self.lena_RGB_U8 = np.load('data/lena_RGB_U8.npy')
|
||||
self.lena_GRAY_U8 = np.load('data/lena_GRAY_U8.npy')
|
||||
self.lena_RGB_U8 = np.load(os.path.join(data_dir, 'lena_RGB_U8.npy'))
|
||||
self.lena_GRAY_U8 = np.load(os.path.join(data_dir, 'lena_GRAY_U8.npy'))
|
||||
|
||||
|
||||
class TestSobel(OpenCVTest):
|
||||
|
||||
Reference in New Issue
Block a user