Difference between revisions of "OpenCV Module in Slicer3"

From NAMIC Wiki
Jump to: navigation, search
(Created page with '=Steps to Use OpenCV Module in Slicer3= 1. My operating system: ----------------------- Ubuntu 8.04 - the Hardy Heron - released in April 2008. Linux brainlab-desktop 2.6.24-2...')
 
 
(20 intermediate revisions by 2 users not shown)
Line 1: Line 1:
=Steps to Use OpenCV Module in Slicer3=
+
=Steps to Build and Use OpenCV Module=
  
1. My operating system:
+
==My operating system==
-----------------------
+
The following Linux system is my desktop where this tutorial is based on:<br>
 
+
Ubuntu 8.04 - the Hardy Heron - released in April 2008. <br>
Ubuntu 8.04 - the Hardy Heron - released in April 2008.
 
 
Linux brainlab-desktop 2.6.24-23-generic #1 SMP Mon Jan 26 00:13:11 UTC 2009 i686 GNU/Linux
 
Linux brainlab-desktop 2.6.24-23-generic #1 SMP Mon Jan 26 00:13:11 UTC 2009 i686 GNU/Linux
  
2. Install OpenCV 1.0
+
==Test camera==
---------------------
 
  
1) Download OpeCV 1.0 at http://sourceforge.net/projects/opencvlibrary/files/
+
#My camera is '''Logitech QuickCam Pro for Noteboks'''
You get file opencv-1.0.0.tar.gz
+
#If you don't have a tool called "luvcview," you can get it using this command "sudo apt-get install luvcview"
 +
#Plug in the camera to any usb port on your computer
 +
#Run luvcview
  
2) Move the file to any temporary folder and then unzip it:
+
<br>In a few seconds you should see video displayed in luvcview
tar xvfz opencv-1.0.0.tar.gz
 
You will get a directory called "opencv-1.0.0"
 
  
3) cd to opencv-1.0.0 and run these commands:
+
==Compile Slicer3==
./configure
+
* To include OpenCV module into your Slicer3 build, open this file:
make
+
Slicer3/slicer_variables.tcl
sudo make install
+
<br>
 +
and set ::USE_OPENCV to "ON"
  
The above commands will configure, compile and install opencv 1.0 on your system.
+
* The compiling process will automatically download and build OpenCV 1.0 from http://sourceforge.net/projects/opencvlibrary/files/.
  
3. Test camera
+
==Test the system==
--------------
+
[[Image:opencv_video_from_camera.png|300px|thumb|Video from a camera is displayed in the second window of OpenCV module in Slicer3.]]
 +
#Plug in your camera into any usb port
 +
#Bring Slicer up
 +
#Go to the modules list in Slicer3 interface
 +
#Pick OpenCV module
 +
#Press the button "second window on"
  
1) My camera
+
You should see video from the camera in a few seconds.
Logitech QuickCam Pro for Noteboks
 
  
2) If you don't have a tool called "luvcview," you can get it using this command:
+
=Future Work=
sudo apt-get install luvcview
+
# OpenCV 1.0 library is now built automatically as one of the external libraries in Slicer3 if we turn it on. OpenCV module in Slicer3 is then built on top of the OpenCV l.0 library. If we want to use OpenCV 1.1 in the future, we need figure out why our module fails to compile with OpenCV 1.1.
 +
# More testing of the functionality in OpenCV module.
  
3) Plug in the camera to any usb port on your computer
+
=Bug Fixes=
  
4) Run
+
* There is a bug in OpenCV related to V4L2 devices:
luvcview
+
** Here is the bugtrac with information: [[https://bugs.launchpad.net/ubuntu/+source/linux/+bug/260251]]
 
+
*** Somehow this is related to bttv 878 cards. OpenCV seem not to be able to handle all output of the card correctly
In a few seconds you should see video displayed in luvcview
+
** Here is the fix [[http://opencvlibrary.svn.sourceforge.net/viewvc/opencvlibrary/trunk/opencv/src/highgui/cvcap_v4l.cpp?r1=1604&r2=1609]]
 
+
*** Apply the changes of revision 1609 to the file # opencv/src/highgui/cvcap_v4l.cpp
4. Compile Slicer3
 
------------------
 
 
 
I have created a Slicer3 (in trunk) module named "OpenCV," whose name was suggested by Dr. Noby Hata.
 
It's basically the videoOpenIGTLink module plus a few bug fixes.
 
To include this module into your Slicer3 build, open this file:
 
Slicer3/Modules/CMakeLists.txt
 
 
 
and uncomment "OpenCV" (by default, it's commented for now because it depends OpenCV library)
 
 
 
5. Test the system
 
------------------
 
 
 
1) Plug in your camera into any usb port
 
2) Bring Slicer up
 
3) Go to the modules list in Slicer3 interface
 
4) Pick OpenCV module
 
5) Press the button "second window on"
 
 
 
You should see video from the camera in a few seconds.
 
 
 
=Future Work=
 

Latest revision as of 02:55, 19 August 2009

Home < OpenCV Module in Slicer3

Steps to Build and Use OpenCV Module

My operating system

The following Linux system is my desktop where this tutorial is based on:
Ubuntu 8.04 - the Hardy Heron - released in April 2008.
Linux brainlab-desktop 2.6.24-23-generic #1 SMP Mon Jan 26 00:13:11 UTC 2009 i686 GNU/Linux

Test camera

  1. My camera is Logitech QuickCam Pro for Noteboks
  2. If you don't have a tool called "luvcview," you can get it using this command "sudo apt-get install luvcview"
  3. Plug in the camera to any usb port on your computer
  4. Run luvcview


In a few seconds you should see video displayed in luvcview

Compile Slicer3

  • To include OpenCV module into your Slicer3 build, open this file:

Slicer3/slicer_variables.tcl
and set ::USE_OPENCV to "ON"

Test the system

Video from a camera is displayed in the second window of OpenCV module in Slicer3.
  1. Plug in your camera into any usb port
  2. Bring Slicer up
  3. Go to the modules list in Slicer3 interface
  4. Pick OpenCV module
  5. Press the button "second window on"

You should see video from the camera in a few seconds.

Future Work

  1. OpenCV 1.0 library is now built automatically as one of the external libraries in Slicer3 if we turn it on. OpenCV module in Slicer3 is then built on top of the OpenCV l.0 library. If we want to use OpenCV 1.1 in the future, we need figure out why our module fails to compile with OpenCV 1.1.
  2. More testing of the functionality in OpenCV module.

Bug Fixes

  • There is a bug in OpenCV related to V4L2 devices:
    • Here is the bugtrac with information: [[1]]
      • Somehow this is related to bttv 878 cards. OpenCV seem not to be able to handle all output of the card correctly
    • Here is the fix [[2]]
      • Apply the changes of revision 1609 to the file # opencv/src/highgui/cvcap_v4l.cpp