<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.8%2FExtensions%2FSlicerOpenCV</id>
	<title>Documentation/4.8/Extensions/SlicerOpenCV - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://www.slicer.org/w/index.php?action=history&amp;feed=atom&amp;title=Documentation%2F4.8%2FExtensions%2FSlicerOpenCV"/>
	<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.8/Extensions/SlicerOpenCV&amp;action=history"/>
	<updated>2026-05-03T01:47:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.33.0</generator>
	<entry>
		<id>https://www.slicer.org/w/index.php?title=Documentation/4.8/Extensions/SlicerOpenCV&amp;diff=55511&amp;oldid=prev</id>
		<title>UpdateBot: Nightly -&gt; 4.8</title>
		<link rel="alternate" type="text/html" href="https://www.slicer.org/w/index.php?title=Documentation/4.8/Extensions/SlicerOpenCV&amp;diff=55511&amp;oldid=prev"/>
		<updated>2017-10-18T07:05:11Z</updated>

		<summary type="html">&lt;p&gt;Nightly -&amp;gt; 4.8&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;noinclude&amp;gt;{{documentation/versioncheck}}&amp;lt;/noinclude&amp;gt;&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-header}}&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Introduction and Acknowledgements}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-start|{{documentation/modulename}}}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
Extension: [[Documentation/{{documentation/version}}/Extensions/SlicerOpenCV|SlicerOpenCV]]&amp;lt;br&amp;gt;&lt;br /&gt;
Acknowledgments:&lt;br /&gt;
This work was supported by a supplement to the Quantitative Image Informatics for Cancer Research (QIICR) project via the NIH-National Cancer Institute Grant U24 CA180918-03 as well as U24 CA180924 Tools to Analyze Morphology and Spatially Mapped Molecular Data with Stony Brook University.&amp;lt;br&amp;gt;&lt;br /&gt;
Author: Nicole Aucoin ({{collaborator|name|spl}})&amp;lt;br&amp;gt;&lt;br /&gt;
Contributor1: Andrey Fedorov ({{collaborator|name|spl}})&amp;lt;br&amp;gt;&lt;br /&gt;
Contributor2: Jean-Christophe Fillion-Robin ({{collaborator|name|kitware}})&amp;lt;br&amp;gt;&lt;br /&gt;
Contact: Nicole Aucoin, &amp;lt;email&amp;gt;nicole@bwh.harvard.edu&amp;lt;/email&amp;gt;&amp;lt;br&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-row}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-logo-gallery&lt;br /&gt;
|{{collaborator|logo|qiicr}}|{{collaborator|longname|qiicr}}&lt;br /&gt;
|{{collaborator|logo|spl}}|{{collaborator|longname|spl}}&lt;br /&gt;
|{{collaborator|logo|kitware}}|{{collaborator|longname|kitware}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{documentation/{{documentation/version}}/module-introduction-end}}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Extension Description}}&lt;br /&gt;
[[File:SlicerOpenCV-logo.png|x200px]]&lt;br /&gt;
&lt;br /&gt;
This extension provides a way for a Slicer extension developer to build against the OpenCV package, by depending on the SlicerOpenCV extension. &lt;br /&gt;
[http://opencv.org OpenCV] (Open Source Computer Vision Library) is an open source computer vision and machine learning software library.&lt;br /&gt;
 &lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Use Cases}}&lt;br /&gt;
&lt;br /&gt;
* 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.&lt;br /&gt;
** SlicerOpenCV also provides a python wrapped OpenCV library that can be used in scripted modules.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Tutorials}}&lt;br /&gt;
&lt;br /&gt;
* A Python scripted module is provided in the SlicerOpenCV extension to provide an example on how to use OpenCV from within scripted modules in Slicer:&lt;br /&gt;
** [https://github.com/SBU-BMI/SlicerOpenCV/blob/master/SlicerOpenCV/Testing/Python/SlicerOpenCVSelfTest.py SlicerOpenCVSelfTest.py] (note: this self test will run from inside the Slicer GUI when Developer Mode has been enabled, but it currently won't run as a ctest command line test)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Panels and their use}}&lt;br /&gt;
&lt;br /&gt;
The OpenCV module doesn't provide a GUI, it's intended to be used at the library level by other modules.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Similar Extensions}}&lt;br /&gt;
&lt;br /&gt;
* The [[Documentation/{{documentation/version}}/Extensions/OpenCVExample | OpenCVExample]] extension depends on this module and provides a template for linking and using OpenCV.&lt;br /&gt;
* The [https://github.com/SBU-BMI/SlicerPathology Slicer Pathology] extension uses the SlicerOpenCV extension &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|References}}&lt;br /&gt;
* [http://qiicr.org Quantitative Image Informatics for Cancer Research (QIICR)]&lt;br /&gt;
* [http://opencv.org Open Source Computer Vision] &lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-section|Information for Developers}}&lt;br /&gt;
{{documentation/{{documentation/version}}/module-developerinfo}}&lt;br /&gt;
&lt;br /&gt;
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&lt;br /&gt;
&lt;br /&gt;
Include the SlicerOpenCV extension by calling find_package(SlicerOpenCV REQUIRED). This will set OpenCV_DIR in the scope of your extension.&lt;br /&gt;
&lt;br /&gt;
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]&lt;br /&gt;
&lt;br /&gt;
===C++===&lt;br /&gt;
&lt;br /&gt;
Once the library is available, in C++ you can include header files and use the video IO factory through ITK to read from file:&lt;br /&gt;
&lt;br /&gt;
    itk::VideoIOBase::Pointer ioReadFile = itk::VideoIOFactory::CreateVideoIO(&lt;br /&gt;
      itk::VideoIOFactory::ReadFileMode, input);&lt;br /&gt;
    if (!ioReadFile)&lt;br /&gt;
      {&lt;br /&gt;
      std::cerr &amp;lt;&amp;lt; &amp;quot;Did not create valid VideoIO for reading from file &amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
      return;&lt;br /&gt;
      }&lt;br /&gt;
&lt;br /&gt;
You can also use the OpenCV library directly to access an attached camera:&lt;br /&gt;
&lt;br /&gt;
    itk::SizeValueType cameraNumber = 0;&lt;br /&gt;
    CvCapture* cameraCapture = cvCaptureFromCAM( cameraNumber );&lt;br /&gt;
    if (cameraCapture == ITK_NULLPTR)&lt;br /&gt;
      {&lt;br /&gt;
      std::cerr &amp;lt;&amp;lt; &amp;quot;Unable to create a camera to capture from&amp;quot; &amp;lt;&amp;lt; std::endl;&lt;br /&gt;
      return;&lt;br /&gt;
      }&lt;br /&gt;
    }&lt;br /&gt;
  &lt;br /&gt;
===Python===&lt;br /&gt;
&lt;br /&gt;
SlicerOpenCV also provides the python wrapped OpenCV library. It's bundled in the extension in the lib/Slicer-X.Y directory. A Python scripted self test was added  to the SlicerOpenCV module, [https://github.com/SBU-BMI/SlicerOpenCV/tree/master/SlicerOpenCV/Testing/Python Python tests], to provide an example of how to use the python module:&lt;br /&gt;
&lt;br /&gt;
  import cv2&lt;br /&gt;
&lt;br /&gt;
Note: there's some work to be done on Slicer's Python infrastructure to ensure that this always works in installed extensions with third party libraries (PYTHONPATH needs to be set correctly). A work around as illustrated as a case in the SlicerOpenCVSelfTest script is to use an explicit path to the wrapped library, cv2File, adn load it directly:&lt;br /&gt;
&lt;br /&gt;
  cv2 = imp.load_dynamic('cv2', cv2File)&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;br /&gt;
{{documentation/{{documentation/version}}/module-footer}}&lt;br /&gt;
[[Category:Documentation/{{documentation/version}}/Modules/Libraries]]&lt;br /&gt;
&amp;lt;!-- ---------------------------- --&amp;gt;&lt;/div&gt;</summary>
		<author><name>UpdateBot</name></author>
		
	</entry>
</feed>