Difference between revisions of "Documentation/Nightly/Extensions/SlicerOpenCV"
Line 59: | Line 59: | ||
{{documentation/{{documentation/version}}/module-developerinfo}} | {{documentation/{{documentation/version}}/module-developerinfo}} | ||
− | + | While configuring your project that depends on a built version of SlicerOpenCV, you need to set SlicerOpenCV_DIR to point to SlicerOpenCV_BUILD_DIR/inner-build - this is the location of SlicerOpenCVConfig.cmake | |
− | |||
− | |||
+ | Include the SlicerOpenCV extension by calling find_package(SlicerOpenCV REQUIRED). This will set OpenCV_DIR in the scope of your extension. | ||
+ | |||
+ | This extension also provides the ITK module Video Bridge OpenCV [http://insightsoftwareconsortium.github.io/ITKBarCamp-doc/ITK/VideoProcessingUsingOpenCVBridge/index.html Video Processing Using OpenCV Bridge] | ||
+ | |||
+ | Once the library is available, in C++ you can include header files and use the video IO factory through ITK to read from file: | ||
+ | |||
+ | itk::VideoIOBase::Pointer ioReadFile = itk::VideoIOFactory::CreateVideoIO( | ||
+ | itk::VideoIOFactory::ReadFileMode, input); | ||
+ | if (!ioReadFile) | ||
+ | { | ||
+ | std::cerr << "Did not create valid VideoIO for reading from file " << std::endl; | ||
+ | return; | ||
+ | } | ||
+ | |||
+ | You can also use the OpenCV library directly to access an attached camera: | ||
+ | |||
+ | itk::SizeValueType cameraNumber = 0; | ||
+ | CvCapture* cameraCapture = cvCaptureFromCAM( cameraNumber ); | ||
+ | if (cameraCapture == ITK_NULLPTR) | ||
+ | { | ||
+ | std::cerr << "Unable to create a camera to capture from" << std::endl; | ||
+ | return; | ||
+ | } | ||
+ | } | ||
+ | |||
<!-- ---------------------------- --> | <!-- ---------------------------- --> | ||
{{documentation/{{documentation/version}}/module-footer}} | {{documentation/{{documentation/version}}/module-footer}} | ||
[[Category:Documentation/{{documentation/version}}/Modules/Libraries]] | [[Category:Documentation/{{documentation/version}}/Modules/Libraries]] | ||
<!-- ---------------------------- --> | <!-- ---------------------------- --> |
Revision as of 18:30, 26 May 2016
Home < Documentation < Nightly < Extensions < SlicerOpenCV
For the latest Slicer documentation, visit the read-the-docs. |
Introduction and Acknowledgements
Extension: SlicerOpenCV | |||||||
|
Module Description
This extension provides a way for a Slicer extension developer to build against the OpenCV pacakge, by depending on the SlicerOpenCV extension. OpenCV (Open Source Computer Vision Library) is an open source computer vision and machine learning software library.
Use Cases
- If an extension developer needs the algorithms provided by OpenCV, they can add a module dependency on SlicerOpenCV and obtain a Slicer style library to link against and use.
Tutorials
Panels and their use
The OpenCV module doesn't provide a GUI, it's intended to be used at the library level by other modules.
Similar Modules
- The OpenCVExample extension depends on this module and provides a template for linking and using OpenCV.
- The Slicer Pathology extension uses the SlicerOpenCV extension
References
Information for Developers
Section under construction. |
While configuring your project that depends on a built version of SlicerOpenCV, you need to set SlicerOpenCV_DIR to point to SlicerOpenCV_BUILD_DIR/inner-build - this is the location of SlicerOpenCVConfig.cmake
Include the SlicerOpenCV extension by calling find_package(SlicerOpenCV REQUIRED). This will set OpenCV_DIR in the scope of your extension.
This extension also provides the ITK module Video Bridge OpenCV Video Processing Using OpenCV Bridge
Once the library is available, in C++ you can include header files and use the video IO factory through ITK to read from file:
itk::VideoIOBase::Pointer ioReadFile = itk::VideoIOFactory::CreateVideoIO( itk::VideoIOFactory::ReadFileMode, input); if (!ioReadFile) { std::cerr << "Did not create valid VideoIO for reading from file " << std::endl; return; }
You can also use the OpenCV library directly to access an attached camera:
itk::SizeValueType cameraNumber = 0; CvCapture* cameraCapture = cvCaptureFromCAM( cameraNumber ); if (cameraCapture == ITK_NULLPTR) { std::cerr << "Unable to create a camera to capture from" << std::endl; return; } }