diff options
32 files changed, 483 insertions, 141 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6d931ee..06e9c78 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,7 +22,7 @@ set (RGL_VERSION_MAJOR 1) set (RGL_VERSION_MINOR 0) set (CIL_VERSION_MAJOR 0) -set (CIL_VERSION_MINOR 9) +set (CIL_VERSION_MINOR 10) set (CIL_VERSION_PATCH 1) set (CIL_VERSION '${CIL_VERSION_MAJOR}.${CIL_VERSION_MINOR}.${CIL_VERSION_PATCH}' CACHE INTERNAL "Core Imaging Library version" FORCE) @@ -30,5 +30,27 @@ set (CIL_VERSION '${CIL_VERSION_MAJOR}.${CIL_VERSION_MINOR}.${CIL_VERSION_PATCH} # set the Python variables for the Conda environment #include(${CMAKE_SOURCE_DIR}/CMake/FindAnacondaEnvironment.cmake) +option (BUILD_MATLAB_WRAPPER "Build Matlab Wrappers" OFF) +option (BUILD_PYTHON_WRAPPER "Build Python Wrappers" ON) +option (CONDA_BUILD "Conda Build" OFF) +option (BUILD_CUDA "Build the CUDA modules" ON) + +set(MATLAB_DEST_DIR "" CACHE PATH "Directory of the Matlab wrappers") +if (MATLAB_DEST_DIR) +set(MATLAB_DEST "${MATLAB_DEST_DIR}") +else() +set(MATLAB_DEST "${CMAKE_INSTALL_PREFIX}/matlab") +endif() +message(STATUS "Matlab wrappers will be installed in " ${MATLAB_DEST}) + +set(PYTHON_DEST_DIR "" CACHE PATH "Directory of the Matlab wrappers") +if (PYTHON_DEST_DIR) + set(PYTHON_DEST "${PYTHON_DEST_DIR}") +else() + set(PYTHON_DEST "${CMAKE_INSTALL_PREFIX}/python") +endif() +message(STATUS "Python wrappers will be installed in " ${PYTHON_DEST}) + + add_subdirectory(Core) add_subdirectory(Wrappers) diff --git a/Core/CMakeLists.txt b/Core/CMakeLists.txt index e596da9..ca6879a 100644 --- a/Core/CMakeLists.txt +++ b/Core/CMakeLists.txt @@ -1,12 +1,12 @@ # Copyright 2018 Edoardo Pasca -cmake_minimum_required (VERSION 3.0) +#cmake_minimum_required (VERSION 3.0) -project(RGL) +project(RGL_core) #https://stackoverflow.com/questions/13298504/using-cmake-with-setup-py # The version number. -set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE) +#set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE) # conda orchestrated build message("CIL_VERSION ${CIL_VERSION}") @@ -18,12 +18,19 @@ if (OPENMP_FOUND) set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}") set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}") set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}") + set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_SHARED_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}") + set (CMAKE_STATIC_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_STATIC_LINKER_FLAGS} ${OpenMP_CXX_FLAGS}") + endif() ## Build the regularisers package as a library message("Creating Regularisers as a shared library") message("CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}") +message("CMAKE_C_FLAGS ${CMAKE_C_FLAGS}") +message("CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS}") +message("CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}") +message("CMAKE_STATIC_LINKER_FLAGS ${CMAKE_STATIC_LINKER_FLAGS}") set(CMAKE_BUILD_TYPE "Release") @@ -94,36 +101,48 @@ message ("I'd install into ${CMAKE_INSTALL_PREFIX} lib bin") ) endif() + + # GPU Regularisers +if (BUILD_CUDA) + find_package(CUDA) + if (CUDA_FOUND) + set(CUDA_NVCC_FLAGS "-Xcompiler -fPIC -shared -D_FORCE_INLINES") + message("CUDA FLAGS ${CUDA_NVCC_FLAGS}") + CUDA_ADD_LIBRARY(cilregcuda SHARED + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_ROF_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_FGP_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_SB_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/LLT_ROF_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TGV_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/dTV_FGP_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/NonlDiff_GPU_core.cu + ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/Diffus_4thO_GPU_core.cu + ) + if (UNIX) + message ("I'd install into ${CMAKE_INSTALL_PREFIX}/lib") + install(TARGETS cilregcuda + LIBRARY DESTINATION lib + CONFIGURATIONS ${CMAKE_BUILD_TYPE} + ) + elseif(WIN32) + message ("I'd install into ${CMAKE_INSTALL_PREFIX} lib bin") + install(TARGETS cilregcuda + RUNTIME DESTINATION bin + ARCHIVE DESTINATION lib + CONFIGURATIONS ${CMAKE_BUILD_TYPE} + ) + endif() + else() + message("CUDA NOT FOUND") + endif() +endif() -find_package(CUDA) -if (CUDA_FOUND) - set(CUDA_NVCC_FLAGS "-Xcompiler -fPIC -shared -D_FORCE_INLINES") - message("CUDA FLAGS ${CUDA_NVCC_FLAGS}") - CUDA_ADD_LIBRARY(cilregcuda SHARED - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_ROF_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_FGP_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TV_SB_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/LLT_ROF_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/TGV_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/dTV_FGP_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/NonlDiff_GPU_core.cu - ${CMAKE_CURRENT_SOURCE_DIR}/regularisers_GPU/Diffus_4thO_GPU_core.cu - ) - if (UNIX) - message ("I'd install into ${CMAKE_INSTALL_PREFIX}/lib") - install(TARGETS cilregcuda - LIBRARY DESTINATION lib - CONFIGURATIONS ${CMAKE_BUILD_TYPE} - ) - elseif(WIN32) - message ("I'd install into ${CMAKE_INSTALL_PREFIX} lib bin") - install(TARGETS cilregcuda - RUNTIME DESTINATION bin - ARCHIVE DESTINATION lib - CONFIGURATIONS ${CMAKE_BUILD_TYPE} - ) +if (${BUILD_MATLAB_WRAPPER}) + if (WIN32) + install(TARGETS cilreg DESTINATION ${MATLAB_DEST}) + if (CUDA_FOUND) + install(TARGETS cilregcuda DESTINATION ${MATLAB_DEST}) + endif() endif() -else() - message("CUDA NOT FOUND") -endif() +endif()
\ No newline at end of file @@ -35,27 +35,62 @@ ## Installation: -### Python binaries +The package comes as a CMake project so you will need CMake to install it. After checking out the repository to a directory, i.e. `CCPi-Regularisation-Toolkit`, create a build directory. Additional flags to CMake will allow you to create the Matlab wrapper and/or the Python wrapper and the CUDA regularisers. In the following example I will write a line to build both wrappers and CUDA. + +```bash +git clone https://github.com/vais-ral/CCPi-Regularisation-Toolkit.git +mkdir build +cd build +cmake ../CCPi-Regularisation-Toolkit -DCONDA_BUILD=OFF -DBUILD_MATLAB_WRAPPER=ON -DBUILD_PYTHON_WRAPPER=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=<your favourite install directory> +make install +``` + +The library may be used directly from C/C++ as it is compiled as a shared library. Check-out the include files in `Core`. We provide wrappers in Python and Matlab. + +### Python +#### Python binaries Python binaries are distributed via the [ccpi](https://anaconda.org/ccpi/ccpi-regulariser) conda channel. Currently we produce packages for Linux64, Python 2.7, 3.5 and 3.6, NumPy 1.12 and 1.13. ``` conda install ccpi-regulariser -c ccpi -c conda-forge ``` -### Python (conda-build) +#### Python (conda-build) ``` - export CIL_VERSION=0.10.0 - conda build recipes/regularisers --numpy 1.12 --python 3.5 - conda install cil_regulariser=${CIL_VERSION} --use-local --force - cd Wrappers/Python - conda build conda-recipe --numpy 1.12 --python 3.5 --no-test + export CIL_VERSION=0.10.1 + conda build Wrappers/Python/conda-recipe --numpy 1.12 --python 3.5 conda install ccpi-regulariser=${CIL_VERSION} --use-local --force cd demos/ python demo_cpu_regularisers.py # to run CPU demo python demo_gpu_regularisers.py # to run GPU demo ``` + +#### Python build + +If Python is not picked by CMake you can provide the additional flag to CMake `-DPYTHON_EXECUTABLE=/path/to/python/executable`. + ### Matlab + +If Matlab is not picked by CMake, you could add `-DMatlab_ROOT_DIR=<Matlab directory>`. + +#### Linux +Because you've installed the modules in `<your favourite install directory>` you need to instruct Matlab to look in those directories: + +```bash + +PATH="/path/to/mex/:$PATH" LD_LIBRARY_PATH="/path/to/library:$LD_LIBRARY_PATH" matlab +``` +By default `/path/to/mex` is `${CMAKE_INSTALL_PREFIX}/bin` and `/path/to/library/` is `${CMAKE_INSTALL_PREFIX}/lib` + +#### Windows +On Windows the `dll` and the mex modules must reside in the same directory. It is sufficient to add the directory at the beginning of the m-file. +```matlab +addpath(/path/to/library); +``` + +#### Legacy Matlab installation ``` + cd /Wrappers/Matlab/mex_compile compileCPU_mex.m % to compile CPU modules compileGPU_mex.m % to compile GPU modules (see instructions in the file) diff --git a/Wrappers/CMakeLists.txt b/Wrappers/CMakeLists.txt index cbe2fec..bdcb8f4 100644 --- a/Wrappers/CMakeLists.txt +++ b/Wrappers/CMakeLists.txt @@ -11,4 +11,9 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. -add_subdirectory(Python)
\ No newline at end of file +if (BUILD_MATLAB_WRAPPER) + add_subdirectory(Matlab) +endif() +if (BUILD_PYTHON_WRAPPER) + add_subdirectory(Python) +endif()
\ No newline at end of file diff --git a/Wrappers/Matlab/CMakeLists.txt b/Wrappers/Matlab/CMakeLists.txt new file mode 100755 index 0000000..0c26148 --- /dev/null +++ b/Wrappers/Matlab/CMakeLists.txt @@ -0,0 +1,147 @@ +project(regulariserMatlab)
+
+
+find_package(Matlab REQUIRED COMPONENTS MAIN_PROGRAM MX_LIBRARY ENG_LIBRARY )
+
+
+
+#C:\Users\ofn77899\Documents\Projects\CCPi\GitHub\CCPi-FISTA_Reconstruction\Core\regularisers_CPU
+# matlab_add_mex(
+ # NAME CPU_ROF
+ # SRC
+ # ${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c
+ # LINK_TO cilreg ${Matlab_LIBRARIES}
+ # )
+
+# target_include_directories(CPU_ROF
+ # PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU
+ # ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU
+ # ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU
+ # ${CMAKE_SOURCE_DIR}/Core/
+ # ${MATLAB_INCLUDE_DIR})
+
+ # matlab_add_mex(
+ # NAME CPU_TNV
+ # SRC
+ # ${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c
+ # LINK_TO cilreg ${Matlab_LIBRARIES}
+ # )
+
+# target_include_directories(CPU_TNV
+ # PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU
+ # ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU
+ # ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU
+ # ${CMAKE_SOURCE_DIR}/Core/
+ # ${MATLAB_INCLUDE_DIR})
+
+#set (CPU_MEX_FILES "regularisers_CPU/TNV.c;regularisers_CPU/ROF_TV.c")
+#set (MEX_TARGETS "CPU_TNV;CPU_ROF")
+#list(APPEND MEX_TARGETS "CPU_TNV")
+#list(APPEND MEX_TARGETS "CPU_ROF")
+
+file(GLOB CPU_MEX_FILES
+ "${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_CPU/*.c"
+ #"${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_GPU/*.c"
+)
+
+#message("CPU_MEX_FILES " ${CPU_MEX_FILES})
+
+list(LENGTH CPU_MEX_FILES num)
+
+
+MATH(EXPR num "${num}-1")
+#set(num "-1")
+message("found ${num} files")
+
+foreach(tgt RANGE 0 ${num})
+ message("number " ${tgt})
+ list(LENGTH CPU_MEX_FILES num2)
+ message("the list is ${num2}")
+ #list(GET CPU_TARGETS ${tgt} current_target)
+ list(GET CPU_MEX_FILES ${tgt} current_file_name)
+ get_filename_component(current_file ${current_file_name} NAME)
+ string(REGEX MATCH "(.+).c" match ${current_file})
+ if (NOT ${match} EQUAL "" )
+ set (current_target ${CMAKE_MATCH_1})
+ endif()
+ message("matlab_add_mex target " ${current_file} " and " ${current_target})
+ matlab_add_mex(
+ NAME ${current_target}
+ SRC
+ ${current_file_name}
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/FGP_TV_core.c
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/SB_TV_core.c
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/TGV_core.c
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/Diffusion_core.c
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/Diffus4th_order_core.c
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/LLT_ROF_core.c
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/ROF_TV_core.c
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/FGP_dTV_core.c
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/TNV_core.c
+ #${CMAKE_SOURCE_DIR}/Core/regularisers_CPU/utils.c
+ #${CMAKE_SOURCE_DIR}/Core/inpainters_CPU/Diffusion_Inpaint_core.c
+ #${CMAKE_SOURCE_DIR}/Core/inpainters_CPU/NonlocalMarching_Inpaint_core.c
+ LINK_TO cilreg ${Matlab_LIBRARIES}
+ )
+
+target_include_directories(${current_target}
+ PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU
+ ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU
+ ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU
+ ${CMAKE_SOURCE_DIR}/Core/
+ ${MATLAB_INCLUDE_DIR})
+ set_property(TARGET ${current_target} PROPERTY C_STANDARD 99)
+ list(APPEND CPU_MEX_TARGETS ${current_target})
+ INSTALL(TARGETS ${current_target} DESTINATION "${MATLAB_DEST}")
+endforeach()
+
+add_custom_target(MatlabWrapper DEPENDS ${CPU_MEX_TARGETS})
+
+if (BUILD_CUDA)
+ find_package(CUDA)
+ if (CUDA_FOUND)
+ file(GLOB GPU_MEX_FILES
+ "${CMAKE_SOURCE_DIR}/Wrappers/Matlab/mex_compile/regularisers_GPU/*.cpp"
+ )
+
+ list(LENGTH GPU_MEX_FILES num)
+message("number of GPU files " ${num})
+
+ MATH(EXPR num "${num}-1")
+ #set(num "-1")
+
+ foreach(tgt RANGE ${num})
+ message("number " ${tgt})
+ list(LENGTH GPU_MEX_FILES num2)
+ message("the list is ${num2}")
+ #list(GET CPU_TARGETS ${tgt} current_target)
+ list(GET GPU_MEX_FILES ${tgt} current_file_name)
+ get_filename_component(current_file ${current_file_name} NAME)
+ string(REGEX MATCH "(.+).c" match ${current_file})
+ if (NOT ${match} EQUAL "" )
+ set (current_target ${CMAKE_MATCH_1})
+ endif()
+ message("matlab_add_mex target " ${current_file} " and " ${current_target})
+ message("matlab_add_mex " ${current_target})
+ matlab_add_mex(
+ NAME ${current_target}
+ SRC
+ ${current_file_name}
+ LINK_TO cilregcuda ${Matlab_LIBRARIES}
+ )
+
+ target_include_directories(${current_target}
+ PUBLIC ${CMAKE_SOURCE_DIR}/Core/regularisers_CPU
+ ${CMAKE_SOURCE_DIR}/Core/regularisers_GPU
+ ${CMAKE_SOURCE_DIR}/Core/inpainters_CPU
+ ${CMAKE_SOURCE_DIR}/Core/
+ ${MATLAB_INCLUDE_DIR})
+
+ list(APPEND GPU_MEX_TARGETS ${current_target})
+ INSTALL(TARGETS ${current_target} DESTINATION "${MATLAB_DEST}")
+ endforeach()
+
+ add_custom_target(MatlabWrapperGPU DEPENDS ${GPU_MEX_TARGETS})
+
+ endif()
+endif()
diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/Diffusion_4thO.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/Diffusion_4thO.c index 81c0600..66ea9be 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/Diffusion_4thO.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/Diffusion_4thO.c @@ -42,8 +42,9 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter_numb, dimX, dimY, dimZ; - const int *dim_array; + int number_of_dims, iter_numb; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; float *Input, *Output=NULL, lambda, tau, sigma; dim_array = mxGetDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_TV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_TV.c index aae1cb7..642362f 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_TV.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_TV.c @@ -44,8 +44,9 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter, dimX, dimY, dimZ, methTV, printswitch, nonneg; - const int *dim_array; + int number_of_dims, iter, methTV, printswitch, nonneg; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; float *Input, *Output=NULL, lambda, epsil; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_dTV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_dTV.c index bb868c7..1a0c070 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_dTV.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/FGP_dTV.c @@ -49,9 +49,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter, dimX, dimY, dimZ, methTV, printswitch, nonneg; - const int *dim_array; - const int *dim_array2; + int number_of_dims, iter, methTV, printswitch, nonneg; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + const mwSize *dim_array2; float *Input, *InputRef, *Output=NULL, lambda, epsil, eta; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/LLT_ROF.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/LLT_ROF.c index 81b717d..ab45446 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/LLT_ROF.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/LLT_ROF.c @@ -46,8 +46,9 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iterationsNumb, dimX, dimY, dimZ; - const int *dim_array; + int number_of_dims, iterationsNumb; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; float *Input, *Output=NULL, lambdaROF, lambdaLLT, tau; dim_array = mxGetDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff.c index e05f5d4..ec35b8b 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff.c @@ -43,8 +43,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter_numb, dimX, dimY, dimZ, penaltytype; - const int *dim_array; + int number_of_dims, iter_numb, penaltytype; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + float *Input, *Output=NULL, lambda, tau, sigma; dim_array = mxGetDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff_Inp.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff_Inp.c index eaab4a7..9833392 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff_Inp.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlDiff_Inp.c @@ -45,9 +45,11 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter_numb, dimX, dimY, dimZ, penaltytype, i, inpaint_elements; - const int *dim_array; - const int *dim_array2; + int number_of_dims, iter_numb, penaltytype, i, inpaint_elements; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + const mwSize *dim_array2; + float *Input, *Output=NULL, lambda, tau, sigma; unsigned char *Mask; @@ -95,7 +97,7 @@ void mexFunction( } inpaint_elements = 0; - for (i=0; i<dimY*dimX*dimZ; i++) if (Mask[i] == 1) inpaint_elements++; + for (i=0; i<(int)(dimY*dimX*dimZ); i++) if (Mask[i] == 1) inpaint_elements++; if (inpaint_elements == 0) mexErrMsgTxt("The mask is full of zeros, nothing to inpaint"); Diffusion_Inpaint_CPU_main(Input, Mask, Output, lambda, sigma, iter_numb, tau, penaltytype, dimX, dimY, dimZ); }
\ No newline at end of file diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlocalMarching_Inpaint.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlocalMarching_Inpaint.c index 36cf05c..b3f2c98 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlocalMarching_Inpaint.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/NonlocalMarching_Inpaint.c @@ -42,9 +42,11 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, dimX, dimY, dimZ, iterations, SW_increment; - const int *dim_array; - const int *dim_array2; + int number_of_dims, iterations, SW_increment; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + const mwSize *dim_array2; + float *Input, *Output=NULL; unsigned char *Mask, *Mask_upd=NULL; diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c index 6b9e1ea..55ef2b1 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/ROF_TV.c @@ -1,3 +1,4 @@ + /* * This work is part of the Core Imaging Library developed by * Visual Analytics and Imaging System Group of the Science Technology @@ -43,11 +44,12 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter_numb, dimX, dimY, dimZ; - const int *dim_array; - float *Input, *Output=NULL, lambda, tau; + int number_of_dims, iter_numb; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array_i; + float *Input, *Output=NULL, lambda, tau; - dim_array = mxGetDimensions(prhs[0]); + dim_array_i = mxGetDimensions(prhs[0]); number_of_dims = mxGetNumberOfDimensions(prhs[0]); /*Handling Matlab input data*/ @@ -59,15 +61,17 @@ void mexFunction( if (mxGetClassID(prhs[0]) != mxSINGLE_CLASS) {mexErrMsgTxt("The input image must be in a single precision"); } if(nrhs != 4) mexErrMsgTxt("Four inputs reqired: Image(2D,3D), regularization parameter, iterations number, marching step constant"); /*Handling Matlab output data*/ - dimX = dim_array[0]; dimY = dim_array[1]; dimZ = dim_array[2]; + dimX = dim_array_i[0]; dimY = dim_array_i[1]; dimZ = dim_array_i[2]; /* output arrays*/ if (number_of_dims == 2) { dimZ = 1; /*2D case*/ /* output image/volume */ - Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array, mxSINGLE_CLASS, mxREAL)); + Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(2, dim_array_i, mxSINGLE_CLASS, mxREAL)); } - if (number_of_dims == 3) Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array, mxSINGLE_CLASS, mxREAL)); - + if (number_of_dims == 3) { + Output = (float*)mxGetPr(plhs[0] = mxCreateNumericArray(3, dim_array_i, mxSINGLE_CLASS, mxREAL)); + } + TV_ROF_CPU_main(Input, Output, lambda, iter_numb, tau, dimX, dimY, dimZ); }
\ No newline at end of file diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/SB_TV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/SB_TV.c index d284cac..8636322 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/SB_TV.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/SB_TV.c @@ -42,8 +42,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter, dimX, dimY, dimZ, methTV, printswitch; - const int *dim_array; + int number_of_dims, iter, methTV, printswitch; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + float *Input, *Output=NULL, lambda, epsil; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/TGV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/TGV.c index 9516869..5459bf5 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/TGV.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/TGV.c @@ -43,8 +43,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter, dimX, dimY; - const int *dim_array; + int number_of_dims, iter; + mwSize dimX, dimY; + const mwSize *dim_array; + float *Input, *Output=NULL, lambda, alpha0, alpha1, L2; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c index e0584c4..acea75d 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/TNV.c @@ -41,8 +41,9 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter, dimX, dimY, dimZ; - const int *dim_array; + int number_of_dims, iter; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; float *Input, *Output=NULL, lambda, epsil; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_CPU/TV_energy.c b/Wrappers/Matlab/mex_compile/regularisers_CPU/TV_energy.c index f9eb2ce..d457f46 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_CPU/TV_energy.c +++ b/Wrappers/Matlab/mex_compile/regularisers_CPU/TV_energy.c @@ -36,8 +36,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, dimX, dimY, dimZ, type; - const int *dim_array; + int number_of_dims, type; + + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; float *Input, *Input0, lambda; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/Diffusion_4thO_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/Diffusion_4thO_GPU.cpp index 0edc067..0cc042b 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_GPU/Diffusion_4thO_GPU.cpp +++ b/Wrappers/Matlab/mex_compile/regularisers_GPU/Diffusion_4thO_GPU.cpp @@ -42,8 +42,9 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter_numb, dimX, dimY, dimZ; - const int *dim_array; + int number_of_dims, iter_numb; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; float *Input, *Output=NULL, lambda, tau, sigma; dim_array = mxGetDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_TV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_TV_GPU.cpp index 9ed9ae0..c174e75 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_TV_GPU.cpp +++ b/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_TV_GPU.cpp @@ -43,8 +43,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter, dimX, dimY, dimZ, methTV, printswitch, nonneg; - const int *dim_array; + int number_of_dims, iter, methTV, printswitch, nonneg; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + float *Input, *Output=NULL, lambda, epsil; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_dTV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_dTV_GPU.cpp index 5b80616..3f5a4b3 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_dTV_GPU.cpp +++ b/Wrappers/Matlab/mex_compile/regularisers_GPU/FGP_dTV_GPU.cpp @@ -47,9 +47,11 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter, dimX, dimY, dimZ, methTV, printswitch, nonneg; - const int *dim_array; - const int *dim_array2; + int number_of_dims, iter, methTV, printswitch, nonneg; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + const mwSize *dim_array2; + float *Input, *InputRef, *Output=NULL, lambda, epsil, eta; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/LLT_ROF_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/LLT_ROF_GPU.cpp index 37563b0..e8da4ce 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_GPU/LLT_ROF_GPU.cpp +++ b/Wrappers/Matlab/mex_compile/regularisers_GPU/LLT_ROF_GPU.cpp @@ -46,8 +46,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iterationsNumb, dimX, dimY, dimZ; - const int *dim_array; + int number_of_dims, iterationsNumb; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + float *Input, *Output=NULL, lambdaROF, lambdaLLT, tau; dim_array = mxGetDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/NonlDiff_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/NonlDiff_GPU.cpp index bfba9ea..1cd0cdc 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_GPU/NonlDiff_GPU.cpp +++ b/Wrappers/Matlab/mex_compile/regularisers_GPU/NonlDiff_GPU.cpp @@ -46,8 +46,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter_numb, dimX, dimY, dimZ, penaltytype; - const int *dim_array; + int number_of_dims, iter_numb, penaltytype; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + float *Input, *Output=NULL, lambda, tau, sigma; dim_array = mxGetDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/ROF_TV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/ROF_TV_GPU.cpp index f60ba7b..bd01d55 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_GPU/ROF_TV_GPU.cpp +++ b/Wrappers/Matlab/mex_compile/regularisers_GPU/ROF_TV_GPU.cpp @@ -42,8 +42,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter_numb, dimX, dimY, dimZ; - const int *dim_array; + int number_of_dims, iter_numb; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + float *Input, *Output=NULL, lambda, tau; dim_array = mxGetDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/SB_TV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/SB_TV_GPU.cpp index 60847d9..9d1328f 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_GPU/SB_TV_GPU.cpp +++ b/Wrappers/Matlab/mex_compile/regularisers_GPU/SB_TV_GPU.cpp @@ -42,8 +42,10 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter, dimX, dimY, dimZ, methTV, printswitch; - const int *dim_array; + int number_of_dims, iter, methTV, printswitch; + mwSize dimX, dimY, dimZ; + const mwSize *dim_array; + float *Input, *Output=NULL, lambda, epsil; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Matlab/mex_compile/regularisers_GPU/TGV_GPU.cpp b/Wrappers/Matlab/mex_compile/regularisers_GPU/TGV_GPU.cpp index 5a0df5b..edb551d 100644 --- a/Wrappers/Matlab/mex_compile/regularisers_GPU/TGV_GPU.cpp +++ b/Wrappers/Matlab/mex_compile/regularisers_GPU/TGV_GPU.cpp @@ -43,8 +43,9 @@ void mexFunction( int nrhs, const mxArray *prhs[]) { - int number_of_dims, iter, dimX, dimY; - const int *dim_array; + int number_of_dims, iter; + mwSize dimX, dimY; + const mwSize *dim_array; float *Input, *Output=NULL, lambda, alpha0, alpha1, L2; number_of_dims = mxGetNumberOfDimensions(prhs[0]); diff --git a/Wrappers/Python/CMakeLists.txt b/Wrappers/Python/CMakeLists.txt index fa1a30b..d86d0ea 100644 --- a/Wrappers/Python/CMakeLists.txt +++ b/Wrappers/Python/CMakeLists.txt @@ -6,7 +6,7 @@ project(regulariserPython) # The version number. -set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE) +#set (CIL_VERSION $ENV{CIL_VERSION} CACHE INTERNAL "Core Imaging Library version" FORCE) # conda orchestrated build message("CIL_VERSION ${CIL_VERSION}") @@ -41,31 +41,101 @@ elseif(UNIX) endif() # GPU regularisers - -find_package(CUDA) -if (CUDA_FOUND) - message("CUDA FOUND") - set (SETUP_GPU_WRAPPERS "extra_libraries += ['cilregcuda']\n\ +if (BUILD_CUDA) + find_package(CUDA) + if (CUDA_FOUND) + message("CUDA FOUND") + set (SETUP_GPU_WRAPPERS "extra_libraries += ['cilregcuda']\n\ setup( \n\ - name='ccpi', \n\ - description='CCPi Core Imaging Library - Image regularisers GPU',\n\ - version=cil_version,\n\ - cmdclass = {'build_ext': build_ext},\n\ - ext_modules = [Extension('ccpi.filters.gpu_regularisers',\n\ - sources=[ \n\ - os.path.join('.' , 'src', 'gpu_regularisers.pyx' ),\n\ - ],\n\ - include_dirs=extra_include_dirs, \n\ - library_dirs=extra_library_dirs, \n\ - extra_compile_args=extra_compile_args, \n\ - libraries=extra_libraries ), \n\ - ],\n\ - zip_safe = False, \n\ - packages = {'ccpi','ccpi.filters'},\n\ -)") -else() - message("CUDA NOT FOUND") - set(SETUP_GPU_WRAPPERS "#CUDA NOT FOUND") + name='ccpi', \n\ + description='CCPi Core Imaging Library - Image regularisers GPU',\n\ + version=cil_version,\n\ + cmdclass = {'build_ext': build_ext},\n\ + ext_modules = [Extension('ccpi.filters.gpu_regularisers',\n\ + sources=[ \n\ + os.path.join('.' , 'src', 'gpu_regularisers.pyx' ),\n\ + ],\n\ + include_dirs=extra_include_dirs, \n\ + library_dirs=extra_library_dirs, \n\ + extra_compile_args=extra_compile_args, \n\ + libraries=extra_libraries ), \n\ + ],\n\ + zip_safe = False, \n\ + packages = {'ccpi','ccpi.filters'},\n\ + )") + else() + message("CUDA NOT FOUND") + set(SETUP_GPU_WRAPPERS "#CUDA NOT FOUND") + endif() +endif() +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/setup-regularisers.py.in" "${CMAKE_CURRENT_BINARY_DIR}/setup-regularisers.py") + + +find_package(PythonInterp) +find_package(PythonLibs) +if (PYTHONINTERP_FOUND) + message(STATUS "Found PYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}") + message(STATUS "Python version ${PYTHON_VERSION_STRING}") +endif() +if (PYTHONLIBS_FOUND) + message(STATUS "Found PYTHON_INCLUDE_DIRS=${PYTHON_INCLUDE_DIRS}") + message(STATUS "Found PYTHON_LIBRARIES=${PYTHON_LIBRARIES}") endif() -configure_file("setup-regularisers.py.in" "setup-regularisers.py") +if (PYTHONINTERP_FOUND) + message("Python found " ${PYTHON_EXECUTABLE}) + set(SETUP_PY_IN "${CMAKE_CURRENT_SOURCE_DIR}/setup-regularisers.py.in") + set(SETUP_PY "${CMAKE_CURRENT_BINARY_DIR}/setup-regularisers.py") + #set(DEPS "${CMAKE_CURRENT_SOURCE_DIR}/module/__init__.py") + set (DEPS "${CMAKE_BINARY_DIR}/Core/") + set(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/build/timestamp") + + configure_file(${SETUP_PY_IN} ${SETUP_PY}) + + message("Core binary dir " ${CMAKE_BINARY_DIR}/Core/${CMAKE_BUILD_TYPE}) + + if (CONDA_BUILD) + add_custom_command(OUTPUT ${OUTPUT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi + COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION} + PREFIX=${CMAKE_SOURCE_DIR}/Core + LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core + LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core + ${PYTHON_EXECUTABLE} ${SETUP_PY} install + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS cilreg) + + else() + if (WIN32) + add_custom_command(OUTPUT ${OUTPUT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi + COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION} + PREFIX=${CMAKE_SOURCE_DIR}/Core + LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core + LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core/${CMAKE_BUILD_TYPE} + ${PYTHON_EXECUTABLE} ${SETUP_PY} build_ext --inplace + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS cilreg) + else() + add_custom_command(OUTPUT ${OUTPUT} + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/src ${CMAKE_CURRENT_BINARY_DIR}/src + COMMAND ${CMAKE_COMMAND} -E copy_directory ${CMAKE_CURRENT_SOURCE_DIR}/ccpi ${CMAKE_CURRENT_BINARY_DIR}/ccpi + COMMAND ${CMAKE_COMMAND} -E env CIL_VERSION=${CIL_VERSION} + PREFIX=${CMAKE_SOURCE_DIR}/Core + LIBRARY_INC=${CMAKE_SOURCE_DIR}/Core + LIBRARY_LIB=${CMAKE_BINARY_DIR}/Core + ${PYTHON_EXECUTABLE} ${SETUP_PY} build_ext --inplace + COMMAND ${CMAKE_COMMAND} -E touch ${OUTPUT} + DEPENDS cilreg) + endif() + install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/ccpi + DESTINATION ${PYTHON_DEST}) + endif() + + + add_custom_target(PythonWrapper ALL DEPENDS ${OUTPUT}) + + #install(CODE "execute_process(COMMAND ${PYTHON} ${SETUP_PY} install)") +endif() diff --git a/Wrappers/Python/conda-recipe/bld.bat b/Wrappers/Python/conda-recipe/bld.bat index e47f8d9..6c84355 100644 --- a/Wrappers/Python/conda-recipe/bld.bat +++ b/Wrappers/Python/conda-recipe/bld.bat @@ -6,12 +6,15 @@ exit 1 mkdir "%SRC_DIR%\ccpi" ROBOCOPY /E "%RECIPE_DIR%\..\.." "%SRC_DIR%\ccpi" ROBOCOPY /E "%RECIPE_DIR%\..\..\..\Core" "%SRC_DIR%\Core" -cd %SRC_DIR%\ccpi\Python +::cd %SRC_DIR%\ccpi\Python +cd %SRC_DIR% :: issue cmake to create setup.py -cmake . +cmake -G "NMake Makefiles" %RECIPE_DIR%\..\..\..\ -DBUILD_PYTHON_WRAPPERS=ON -DCONDA_BUILD=ON -DBUILD_CUDA=OFF -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library" -%PYTHON% setup-regularisers.py build_ext -if errorlevel 1 exit 1 -%PYTHON% setup-regularisers.py install -if errorlevel 1 exit 1 +::%PYTHON% setup-regularisers.py build_ext +::if errorlevel 1 exit 1 +::%PYTHON% setup-regularisers.py install +::if errorlevel 1 exit 1 +nmake install +if errorlevel 1 exit 1
\ No newline at end of file diff --git a/Wrappers/Python/conda-recipe/build.sh b/Wrappers/Python/conda-recipe/build.sh index 8b05663..54bc8e2 100644 --- a/Wrappers/Python/conda-recipe/build.sh +++ b/Wrappers/Python/conda-recipe/build.sh @@ -1,19 +1,16 @@ -if [ -z "$CIL_VERSION" ]; then - echo "Need to set CIL_VERSION" - exit 1 -fi mkdir "$SRC_DIR/ccpi" cp -rv "$RECIPE_DIR/../.." "$SRC_DIR/ccpi" cp -rv "$RECIPE_DIR/../../../Core" "$SRC_DIR/Core" -cd $SRC_DIR/ccpi/Python +cd $SRC_DIR -echo "$SRC_DIR/ccpi/Python" +cmake -G "Unix Makefiles" $RECIPE_DIR/../../../ -DBUILD_PYTHON_WRAPPER=ON -DCONDA_BUILD=ON -DBUILD_CUDA=ON -DCMAKE_BUILD_TYPE="Release" -DLIBRARY_LIB=$CONDA_PREFIX/lib -DLIBRARY_INC=$CONDA_PREFIX -DCMAKE_INSTALL_PREFIX=$PREFIX -cmake . -$PYTHON setup-regularisers.py build_ext -$PYTHON setup-regularisers.py install +make install + +#$PYTHON setup-regularisers.py build_ext +#$PYTHON setup-regularisers.py install diff --git a/Wrappers/Python/conda-recipe/meta.yaml b/Wrappers/Python/conda-recipe/meta.yaml index ca28bae..9286cc4 100644 --- a/Wrappers/Python/conda-recipe/meta.yaml +++ b/Wrappers/Python/conda-recipe/meta.yaml @@ -1,12 +1,10 @@ package: name: ccpi-regulariser - version: {{ environ['CIL_VERSION'] }} + version: 0.10.1 build: preserve_egg_dir: False - script_env: - - CIL_VERSION # number: 0 test: @@ -21,7 +19,6 @@ requirements: - numpy x.x - setuptools - cython - - cil_regulariser =={{ environ['CIL_VERSION'] }} - vc 14 # [win and py36] - vc 14 # [win and py35] - vc 9 # [win and py27] @@ -30,7 +27,6 @@ requirements: run: - python - numpy x.x - - cil_regulariser =={{ environ['CIL_VERSION'] }} - vc 14 # [win and py36] - vc 14 # [win and py35] - vc 9 # [win and py27] diff --git a/Wrappers/Python/setup-regularisers.py.in b/Wrappers/Python/setup-regularisers.py.in index 7108683..542dcb4 100644 --- a/Wrappers/Python/setup-regularisers.py.in +++ b/Wrappers/Python/setup-regularisers.py.in @@ -27,11 +27,13 @@ except: extra_include_dirs = [numpy.get_include(), library_include_path] #extra_library_dirs = [os.path.join(library_include_path, "..", "lib")] extra_compile_args = [] -extra_library_dirs = [] +extra_library_dirs = [library_lib_path] extra_compile_args = [] extra_link_args = [] extra_libraries = ['cilreg'] +print ("extra_library_dirs " , extra_library_dirs) + extra_include_dirs += [os.path.join(".." , ".." , "Core"), os.path.join(".." , ".." , "Core", "regularisers_CPU"), os.path.join(".." , ".." , "Core", "inpainters_CPU"), diff --git a/docs/installation.txt b/docs/installation.txt new file mode 100644 index 0000000..f6db38c --- /dev/null +++ b/docs/installation.txt @@ -0,0 +1,11 @@ +One can install CCPi-RGL toolkit using cmake: + + +cmake ../CCPi-Regularisation-Toolkit/ -DBUILD_MATLAB_WRAPPERS=ON -DBUILD_PYTHON_WRAPPERS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=install -DMatlab_ROOT_DIR=<Matlab directory> -DBUILD_CUDA=OFF + +make + +make install + +Running Matlab from Linux do: +PATH="/path/to/mex/:$PATH" LD_LIBRARY_PATH="/path/to/library:$LD_LIBRARY_PATH" ./matlab -nosplash & diff --git a/recipes/regularisers/bld.bat b/recipes/regularisers/bld.bat index 6f2f7e7..43a5286 100644 --- a/recipes/regularisers/bld.bat +++ b/recipes/regularisers/bld.bat @@ -10,7 +10,7 @@ cd "%SRC_DIR%\build" echo "we should be in %SRC_DIR%\build" -cmake -G "NMake Makefiles" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library" "%SRC_DIR%\build" +cmake -G "NMake Makefiles" "%RECIPE_DIR%\..\..\" -DLIBRARY_LIB="%CONDA_PREFIX%\lib" -DLIBRARY_INC="%CONDA_PREFIX%" -DCMAKE_INSTALL_PREFIX="%PREFIX%\Library" -DCONDA_BUILD=ON -DBUILD_WRAPPERS=OFF ::-DBOOST_LIBRARYDIR="%CONDA_PREFIX%\Library\lib" -DBOOST_INCLUDEDIR="%CONDA_PREFIX%\Library\include" -DBOOST_ROOT="%CONDA_PREFIX%\Library\lib" |