Git Product home page Git Product logo

sliceropencv's Introduction

SlicerOpenCV

This is an extension that adds OpenCV (https://opencv.org/) to 3D Slicer (https://slicer.org).

See this Slicer labs page for details on what features will be provided by the extension, design decisions and such:

Planning and development page: https://wiki.slicer.org/slicerWiki/index.php/Documentation/Labs/OpenCV

Extension documentation page: https://wiki.slicer.org/slicerWiki/index.php/Documentation/Nightly/Extensions/SlicerOpenCV

Contact

Questions regarding this extension should be posted on 3D Slicer forum: https://discourse.slicer.org

Acknowledgments

This work was supported in part by an administrative supplement to the NIH NCI projects:

  • U24 CA180918 Quantitative Image Informatics for Cancer Research (QIICR), http://qiicr.org, PIs Ron Kikinis and Andrey Fedorov, Brigham and Women's Hospital
  • U24 CA180924 Tools to Analyze Morphology and Spatially Mapped Molecular Data, PI Joel Saltz, SUNY Stony Brook

sliceropencv's People

Contributors

adamrankin avatar fedorov avatar jamesobutler avatar jcfr avatar lassoan avatar sjh26 avatar tdiprima avatar thewtex avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sliceropencv's Issues

Example of vtkImageData to cv2.Mat in Python

Hello all,

Thank you very much for the python example. I was wondering if it's possible to copy (deep or shallow, either is fine) an image from vtkImageData (aka scalar volume node) to a cv2.Mat for input to opencv functions?

Cheers,
Adam

Build error on linux and macOS

This extension fails to build with the latest Slicer Preview Release on linux and macOS:

https://slicer.cdash.org/viewBuildError.php?buildid=2636277

CMake Error at [OpenCV-install/lib/cmake/opencv4/OpenCVModules.cmake:424](https://github.com/Slicer/Slicer/blob/master/OpenCV-install/lib/cmake/opencv4/OpenCVModules.cmake#L424) (message):
  The imported target "quirc" references the file

     "/.../SlicerOpenCV-build/OpenCV-install/lib/opencv4/3rdparty/libquirc.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.
 
but not all the files it references.

Call Stack (most recent call first):
  [OpenCV-install/lib/cmake/opencv4/OpenCVConfig.cmake:126](https://github.com/Slicer/Slicer/blob/master/OpenCV-install/lib/cmake/opencv4/OpenCVConfig.cmake#L126) (include)
  itk-module-init.cmake:4 (find_package)
  CMakeLists.txt:14 (include)


-- Configuring incomplete, errors occurred!

https://slicer.cdash.org/build/2636040

CMake Error at /.../SlicerOpenCV-build/OpenCV-install/lib/cmake/opencv4/OpenCVModules.cmake:424 (message):

The imported target "quirc" references the file

     "/.../SlicerOpenCV-build/OpenCV-install/lib/opencv4/3rdparty/libquirc.a"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  but not all the files it references.

Call Stack (most recent call first):
  /.../SlicerOpenCV-build/OpenCV-install/lib/cmake/opencv4/OpenCVConfig.cmake:126 (include)
  itk-module-init.cmake:4 (find_package)
  CMakeLists.txt:14 (include)


-- Configuring incomplete, errors occurred!

make[5]: *** [ITKVideoBridgeOpenCV-prefix/src/ITKVideoBridgeOpenCV-stamp/ITKVideoBridgeOpenCV-configure] Error 1
make[4]: *** [CMakeFiles/ITKVideoBridgeOpenCV.dir/all] Error 2
make[3]: *** [all] Error 2

https://slicer.cdash.org/viewBuildError.php?buildid=2636032

CMake Error at itk-module-init.cmake:4 (find_package):
  By not providing "FindOpenCV.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "OpenCV", but
  CMake did not find one.

  Could not find a package configuration file provided by "OpenCV" with any
  of the following names:

    OpenCVConfig.cmake
    opencv-config.cmake

Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
  "OpenCV_DIR" to a directory containing one of the above files.  If "OpenCV"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:14 (include)

gmake[5]: *** [ITKVideoBridgeOpenCV-prefix/src/ITKVideoBridgeOpenCV-stamp/ITKVideoBridgeOpenCV-configure] Error 1

gmake[4]: *** [CMakeFiles/ITKVideoBridgeOpenCV.dir/all] Error 2

gmake[3]: *** [all] Error 2

import cv2 fails in nightly

Hello all,

With no modifications, the python command import cv2 fails.

After some investigation, the cv2.pyd is properly installed, but the [PYTHONPATH] in Slicer-26861.ini (or current) does not contain an entry for its location.

After adding it manually

[PYTHONPATH]
1\path=C:/Users/arankin/AppData/Roaming/NA-MIC/Extensions-26861/SlicerOpenCV/lib/Slicer-4.9
size=1

the import command succeeds.

OpenCV_contrib module `wechat_qrcode` leads to build error in client project

For example, here is the error reported when ITKVideoBridgeOpenCV external project associated SlicerOpenCV extension is configured:

-- Found OpenCV: /tmp/SlicerOpenCV-Release/OpenCV-install (found version "4.5.5") 
-- Found Python3: /home/jcfr/Projects/Slicer-2-Release/python-install/bin/PythonSlicer (found suitable version "3.9.10", minimum required is "3.9") found components: Interpreter Development.Module Development.Embed 
-- Found Python3: /home/jcfr/Projects/Slicer-2-Release/python-install/bin/PythonSlicer (found version "3.9.10") found components: Interpreter 
-- Configuring done
CMake Error at src/CMakeLists.txt:6 (add_library):
  Target "ITKVideoBridgeOpenCV" links to target "Iconv::Iconv" but the target
  was not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?


-- Generating done

Adding zlib as dependency to OpenCV project lead to build errors

When attempting to build OpenCV project associated with the SlicerOpenCV extension against the zlib project built by Slicer, it fails with error like the following

/tmp/SlicerOpenCV-Release/OpenCV/3rdparty/openexr/IlmImf/ImfDwaCompressor.cpp:1873:25: error: no ‘int Imf_opencv::DwaCompressor::slicer_zlib_compress(const char*, int, int, const char*&)’ member function declared in class ‘Imf_opencv::DwaCompressor’
      const char *&outPtr)
                         ^
[...]

This happen because classes like DwaCompressor defines compress symbol in the same file where zlib.h (itself including zlib_mangle.h.in) is included.

Steps to reproduce

Add the following option to External_OpenCV.cmake

# Dependencies: ZLIB
-DBUILD_ZLIB:BOOL=OFF
-DZLIB_ROOT:PATH=${ZLIB_ROOT}
-DZLIB_INCLUDE_DIR:PATH=${ZLIB_INCLUDE_DIR}
-DZLIB_LIBRARY:FILEPATH=${ZLIB_LIBRARY}
-DCMAKE_POLICY_DEFAULT_CMP0074:STRING=NEW # Explicitly set to NEW to ensure ZLIB_ROOT is not ignored.

Expected behavior

Successful build without build errors.

Environment

Parallel build with make does not work on mac

$ make -j6
Scanning dependencies of target CopyvtkSlicerOpenCVModuleLogicPythonScriptFiles
Scanning dependencies of target opencv
Scanning dependencies of target ConfigureAdditionalLauncherSettings
Scanning dependencies of target vtkSlicerOpenCVModuleLogic
[  5%] Copying python Script: vtkSlicerOpenCVModuleLogic.py
[  5%] Creating directories for 'opencv'
[  8%] Configuring: AdditionalLauncherSettings.ini
[  8%] Built target CopyvtkSlicerOpenCVModuleLogicPythonScriptFiles
[  8%] Built target ConfigureAdditionalLauncherSettings
Scanning dependencies of target CompilevtkSlicerOpenCVModuleLogicPythonFiles
[ 11%] Compiling python scripts: vtkSlicerOpenCVModuleLogic
[ 14%] Performing download step (git clone) for 'opencv'
Cloning into 'opencv-source'...
Compiling /Users/fedorov/local/builds/SlicerOpenCV/lib/Slicer-4.5/qt-loadable-modules/Python/vtkSlicerOpenCVModuleLogic.py ...
[ 14%] Built target CompilevtkSlicerOpenCVModuleLogicPythonFiles
[ 17%] Building CXX object OpenCV/Logic/CMakeFiles/vtkSlicerOpenCVModuleLogic.dir/vtkSlicerOpenCVLogic.cxx.o
/Users/fedorov/github/SlicerOpenCV/OpenCV/Logic/vtkSlicerOpenCVLogic.cxx:34:10: fatal error: 'cv.h' file not found
#include <cv.h>
         ^
1 error generated.

`is not a valid Qt plugin` error on startup

  Error(s):
    The file '/Applications/Slicer-4.5.0-1/Slicer.app/Contents/Extensions-25042/SlicerOpenCV/lib/Slicer-4.5/qt-loadable-modules/libqSlicerOpenCVModule.dylib' is not a valid Qt plugin.

Manual build on MacOSX 10.6 (Slicer factory) fails

Configuring the extension using:

git clone [email protected]:SBU-BMI/SlicerOpenCV.git
mkdir SlicerOpenCV-Release
cd SlicerOpenCV-Release
/Users/kitware/Dashboards/Support/CMake\ 3.0.1.app/Contents/bin/cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_ARCHITECTURES:STRING=x86_64 -DCMAKE_OSX_DEPLOYMENT_TARGET:STRING=10.6 -DCMAKE_OSX_SYSROOT:PATH=/Developer/SDKs/MacOSX10.6.sdk -DSlicer_DIR=/Users/kitware/Dashboards/Nightly/Slicer-0-build/Slicer-build ../SlicerOpenCV

gives the following error:

OclDbgAssert'
#define CV_OclDbgAssert(expr) do { if (isRaiseError()) { CV_Assert(expr); } else { (void)(expr); } } while ((void)0, 0)
                                                                                          ^
/Users/kitware/Dashboards/Experimental/SlicerOpenCV-Release/OpenCV-source/modules/core/src/ocl.cpp:3520:53: error: use of undeclared
      identifier 'CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE'
    return clGetKernelWorkGroupInfo(p->handle, dev, CL_KERNEL_PREFERRED_WORK_GROUP_SIZE_MULTIPLE,
                                                    ^
/Users/kitware/Dashboards/Experimental/SlicerOpenCV-Release/OpenCV-source/modules/core/src/ocl.cpp:5004:28: error: use of undeclared
      identifier 'clEnqueueReadBufferRect'
                CV_Assert( clEnqueueReadBufferRect(q, (cl_mem)u->handle, CL_TRUE,
                           ^
/Users/kitware/Dashboards/Experimental/SlicerOpenCV-Release/OpenCV-source/modules/core/include/opencv2/core/base.hpp:410:33: note: expanded
      from macro 'CV_Assert'
#define CV_Assert( expr ) if(!!(expr)) ; else cv::error( cv::Error::StsAssert, #expr, CV_Func, __FILE__, __LINE__ )
                                ^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
2 warnings and 20 errors generated.
make[5]: *** [modules/core/CMakeFiles/opencv_core.dir/src/ocl.cpp.o] Error 1
make[4]: *** [modules/core/CMakeFiles/opencv_core.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [OpenCV-prefix/src/OpenCV-stamp/OpenCV-build] Error 2
make[1]: *** [CMakeFiles/OpenCV.dir/all] Error 2
make: *** [all] Error 2

Extension fails to build

I'm reviewing extension builds for latest Slicer-4.13 version. This extension fails to build for current Slicer version:

CMake Error at CMakeLists.txt:23 (find_package):
  By not providing "FindSlicerOpenCV.cmake" in CMAKE_MODULE_PATH this project
  has asked CMake to find a package configuration file provided by
  "SlicerOpenCV", but CMake did not find one.

  Could not find a package configuration file provided by "SlicerOpenCV" with
  any of the following names:

    SlicerOpenCVConfig.cmake
    sliceropencv-config.cmake

  Add the installation prefix of "SlicerOpenCV" to CMAKE_PREFIX_PATH or set
  "SlicerOpenCV_DIR" to a directory containing one of the above files.  If
  "SlicerOpenCV" provides a separate development package or SDK, be sure it
  has been installed.

(https://slicer.cdash.org/build/2499757/configure)

Is there still an intention to maintain it?
Alternatively, Python-wrapped distributions can be installed using pip (but that is not conveniently available from C++ and may not be built with options that Slicer extensions need)

SlicerPathology, SlicerPinholeCameras, SlicerVASST extensions depend on this.

Fix Windows build/test errors

According to @lassoan testing:

After some more testing I’ve found that SlicerPathology build step is skipped because SlicerOpenCV extension tests fail.

SlicerOpenCV tests all fail because ITKVideoBridgeOpenCV-4.10.dll is not found (it is built, but it’s not found when running the tests).

The solution would be to fix SlicerOpenCV tests and maybe also extensions should be built even if tests in dependent extensions fail.

Tests on the dashboard for windows indeed all fail, but of course there are no hints why, by looking at the dashboard: http://slicer.cdash.org/viewTest.php?onlyfailed&buildid=865107

Probably related to this issue: SBU-BMI/SlicerPathology#47

Linking error on Mac

Building on Mac OS X 10.10.5, I have this error. Slicer built from scratch. CMAKE_OSX_DEPLOYMENT_TARGET set to 10.10.

[  4%] Built target ConfigureAdditionalLauncherSettings
[ 36%] Built target OpenCV
[ 68%] Built target ITKVideoBridgeOpenCV
[ 72%] Performing build step for 'inner'
[  5%] Built target ConfigureAdditionalLauncherSettings
[ 10%] Linking CXX shared library ../../lib/Slicer-4.5/qt-loadable-modules/libvtkSlicerOpenCVModuleLogic.dylib
ld: file not found: /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/SharedFileList.framework/Versions/A/SharedFileList for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[5]: *** [lib/Slicer-4.5/qt-loadable-modules/libvtkSlicerOpenCVModuleLogic.dylib] Error 1
make[4]: *** [SlicerOpenCV/Logic/CMakeFiles/vtkSlicerOpenCVModuleLogic.dir/all] Error 2
make[3]: *** [all] Error 2

Build fails on mac

The issue seems to be related to the presence of a system python and/or VTK libraries it installed.

-- Checking for module 'libgphoto2'
--   Package 'libgphoto2' not found
-- Could NOT find Doxygen (missing:  DOXYGEN_EXECUTABLE)
-- To enable PlantUML support, set PLANTUML_JAR environment variable or pass -DPLANTUML_JAR=<filepath> option to cmake
-- Found PythonInterp: /Users/fedorov/local/builds/Slicer4-Debug/python-install/bin/SlicerPython (found suitable version "2.7.10", minimum required is "2.7")
-- Found PythonLibs: /usr/lib/libpython2.7.dylib (found suitable exact version "2.7.10")
-- Could NOT find PythonInterp: Found unsuitable version "2.7.10", but required is at least "3.4" (found /usr/bin/python)
-- Could NOT find PythonInterp: Found unsuitable version "2.7.10", but required is at least "3.2" (found /usr/bin/python)
-- Found JNI: /System/Library/Frameworks/JavaVM.framework
-- Found Matlab: /Applications/MATLAB_R2013b.app/bin/mex
CMake Error at /Users/fedorov/Library/Enthought/Canopy_64bit/User/lib/cmake/vtk-6.2/VTKTargets.cmake:1445 (message):
  The imported target "vtkWrapPython" references the file

     "/Users/fedorov/Library/Enthought/Canopy_64bit/User/bin/vtkWrapPython-6.2"

  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

     "/Users/fedorov/Library/Enthought/Canopy_64bit/User/lib/cmake/vtk-6.2/VTKTargets.cmake"

  but not all the files it references.

Call Stack (most recent call first):
  /Users/fedorov/Library/Enthought/Canopy_64bit/User/lib/cmake/vtk-6.2/VTKConfig.cmake:60 (include)
  cmake/OpenCVDetectVTK.cmake:6 (find_package)
  CMakeLists.txt:584 (include)


-- Configuring incomplete, errors occurred!

Hide the module widget

Since the module UI is empty, I suggest to either hide it or add the openCV icon with some descriptive text

fatal error: Eigen/Eigenvalues: No such file or directory when trying to build latest SlicerOpenCV on Ubuntu

[ 89%] Building CXX object modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/dls.cpp.o
In file included from :0:0:
/usr/include/stdc-predef.h:59:1: warning: /home/erich/MyProjects/SlicerOpenCV-build/OpenCV-build/modules/calib3d/precomp.hpp.gch/opencv_calib3d_Debug.gch: not used because `NO_INLINE' not defined [-Winvalid-pch]
#endif
^
/home/erich/MyProjects/SlicerOpenCV-build/OpenCV-source/modules/calib3d/src/dls.cpp:11:31: fatal error: Eigen/Eigenvalues: No such file or directory

include <Eigen/Eigenvalues>

                           ^

compilation terminated.
make[5]: *** [modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/dls.cpp.o] Error 1
make[4]: *** [modules/calib3d/CMakeFiles/opencv_calib3d.dir/all] Error 2
make[3]: *** [all] Error 2
make[2]: *** [OpenCV-prefix/src/OpenCV-stamp/OpenCV-build] Error 2
make[1]: *** [CMakeFiles/OpenCV.dir/all] Error 2
make: *** [all] Error 2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.