OpenCV: Difference between revisions
(problem - camera.) |
|||
(14 intermediate revisions by 5 users not shown) | |||
Line 1: | Line 1: | ||
== About == |
|||
Wikipedia: [http://en.wikipedia.org/wiki/Opencv OpenCV] |
Wikipedia: [http://en.wikipedia.org/wiki/Opencv OpenCV] |
||
: ''OpenCV is an open source computer vision library originally developed by Intel. It is free for commercial and research use under a BSD license. The library is cross-platform, and runs on Mac OS X, Windows and Linux. It focuses mainly on real-time image processing, as such, if it finds Intel's Integrated Performance Primitives (IPP) on the system, it will use these commercial optimized routines to accelerate itself.'' |
: ''OpenCV is an open source computer vision library originally developed by Intel. It is free for commercial and research use under a BSD license. The library is cross-platform, and runs on Mac OS X, Windows and Linux. It focuses mainly on real-time image processing, as such, if it finds Intel's Integrated Performance Primitives (IPP) on the system, it will use these commercial optimized routines to accelerate itself.'' |
||
Line 12: | Line 12: | ||
:* ... |
:* ... |
||
== Python integration == |
|||
OpenCV has reasonably robust Python interface created with SWIG. This makes it easy to integrate with existing libraries like Pygame and olpcgames. As an example, OpenCV can be combined with Pygame to make a simple [http://eclecti.cc/olpc/pyeyes-xeyes-in-python-with-face-tracking face tracking xeyes clone]. |
|||
The interface is available as a package in the default repository, called opencv-python. |
|||
⚫ | |||
⚫ | |||
[http://eclecti.cc/code/face-detection-on-the-olpc-xo Nirav Patel reports] success in basic image recognition on the XO Laptop (with xo-cam) with good timings using OpenCV and [[xawtv]]. |
[http://eclecti.cc/code/face-detection-on-the-olpc-xo Nirav Patel reports] success in basic image recognition on the XO Laptop (with xo-cam) with good timings using OpenCV and [[xawtv]]. |
||
Sources: [http://eclecti.cc/files/2008/03/face.py face.py] [http://eclecti.cc/files/2008/03/haarcascade_frontalface_alt.xml haarcascade_frontalface_alt.xml] |
Sources: [http://eclecti.cc/files/2008/03/face.py face.py] [http://eclecti.cc/files/2008/03/haarcascade_frontalface_alt.xml haarcascade_frontalface_alt.xml] |
||
== Head tracking == |
|||
http://code.google.com/p/ehci/ ehci - GSoC OpenCV-based head and hand tracking. Has python api. |
|||
This would be useful for [[augmented reality]]. |
|||
== Hand tracking == |
|||
To do something similar to the pygame http://www.youtube.com/watch?v=HIDdxY3L5V8 . |
|||
Perhaps combine it with [http://www.inference.phy.cam.ac.uk/dasher/ Dasher][http://www.youtube.com/watch?v=0d6yIquOKQ0] to get something like http://www.youtube.com/watch?v=IK5_QYv3kf0 . Dasher would make a nice Activity. It even has a Mongolian corpus. |
|||
When one XO is present, several more are likely to be as well. Interesting possibilities. For instance, two XO's might work together to do ''3D'' hand tracking. Others? |
|||
== Downloads == |
|||
The source can be downloaded from sourceforge, or OpenCV can be installed from the opencv package in the Fedora repository. To use OpenCV with python, also install the opencv-python package. |
The source can be downloaded from sourceforge, or OpenCV can be installed from the opencv package in the Fedora repository. To use OpenCV with python, also install the opencv-python package. |
||
<pre> |
<pre> |
||
Line 24: | Line 41: | ||
</pre> |
</pre> |
||
== Problems == |
|||
Currently, OpenCV fails to interface with the XO's [[Camera]]. It is therefore necessary to use [[xawtv]] or [[Gstreamer]] to capture video or images, and feed the results to OpenCV. |
Currently, OpenCV fails to interface with the XO's [[Camera]]. It is therefore necessary to use [[xawtv]] or [[Gstreamer]] to capture video or images, and feed the results to OpenCV. |
||
The problem is fixed in the latest CVS source, or can be fixed by changing the following at line 415 in otherlibs/highgui/cvcap_v4l.cpp in the opencv 1.0.0 source. |
|||
⚫ | |||
<pre> capture->form.fmt.pix.field = V4L2_FIELD_INTERLACED;</pre> |
|||
⚫ | |||
to |
|||
<pre> capture->form.fmt.pix.field = V4L2_FIELD_ANY;</pre> |
|||
Note that the packages required to compile OpenCV include gtk2-devel, which currently is not installable, a [http://dev.laptop.org/ticket/6650 known bug]. I got around it with the following, though your milage may vary. |
|||
<pre>yum -t --enablerepo=* install libXI-devel |
|||
yum -t --enablerepo=* install gtk2-devel</pre> |
|||
An easier but even dirtier fix is available [http://eclecti.cc/code/a-dirty-hack-for-opencv-on-the-olpc-xo here]. |
|||
====Incomplete Frame Updates Using Highgui's: cvQueryFrame()==== |
|||
The query frame function in highgui (which is used in most of the python examples that ship with opencv),often returns frames that are only half updated |
|||
<pre>frame=cvQueryFrame(capture)</pre> |
|||
This function is roughly equivalent to |
|||
<pre> |
|||
cvGrabFrame(capture) |
|||
frame=cvRetrieveFrame(capture)</pre> |
|||
Often on the XO, the grab frame is incomplete when the camera is asked to return the frame. This results in an image where only the top half has been updated. |
|||
This problem can be solved by giving the camera time to complete the grab before retrieving the frame. Any non-trivial image grabbing loop takes long enough to execute for the camera to finish the grab (including a loop that simply displays the image), so calling the grab for the next iteration immediately after the retrieve for the current iteration usually solves the problem. |
|||
== Demos == |
|||
* PyEyes - http://eclecti.cc/olpc/pyeyes-xeyes-in-python-with-face-tracking |
|||
*: Doesn't seem to currently work. (8.2.0) [[User:MitchellNCharity|MitchellNCharity]] 20:29, 17 November 2008 (UTC) |
|||
* [[Colors!]] with charger tracking - http://eclecti.cc/code/paint-with-color-based-object-tracking-on-the-olpc-xo |
|||
*: Doesn't seem to currently work. (8.2.0) [[User:MitchellNCharity|MitchellNCharity]] 20:29, 17 November 2008 (UTC) |
|||
*: This is unfortunately a known bug relating to the newer gstreamer. It is fairly trivial to fix, but it may be easier in the long term to switch from gstreamer to the Pygame camera module. [[User:Nrp|Nrp]] 05:26, 24 November 2008 (UTC) |
|||
⚫ | |||
⚫ | |||
* [http://sourceforge.net/projects/opencvlibrary/ OpenCV SourceForge] site |
* [http://sourceforge.net/projects/opencvlibrary/ OpenCV SourceForge] site |
||
* [http://www.intel.com/technology/computing/opencv/index.htm OpenCV] homepage at intel |
* [http://www.intel.com/technology/computing/opencv/index.htm OpenCV] homepage at intel |
Latest revision as of 18:13, 27 June 2009
About
Wikipedia: OpenCV
- OpenCV is an open source computer vision library originally developed by Intel. It is free for commercial and research use under a BSD license. The library is cross-platform, and runs on Mac OS X, Windows and Linux. It focuses mainly on real-time image processing, as such, if it finds Intel's Integrated Performance Primitives (IPP) on the system, it will use these commercial optimized routines to accelerate itself.
- OpenCV's application areas include:
- Human-Computer Interface (HCI)
- Object Identification
- Segmentation and Recognition
- Face Recognition
- Gesture Recognition
- Motion Tracking
- ...
Python integration
OpenCV has reasonably robust Python interface created with SWIG. This makes it easy to integrate with existing libraries like Pygame and olpcgames. As an example, OpenCV can be combined with Pygame to make a simple face tracking xeyes clone.
The interface is available as a package in the default repository, called opencv-python.
Face Detection
Nirav Patel reports success in basic image recognition on the XO Laptop (with xo-cam) with good timings using OpenCV and xawtv.
Sources: face.py haarcascade_frontalface_alt.xml
Head tracking
http://code.google.com/p/ehci/ ehci - GSoC OpenCV-based head and hand tracking. Has python api.
This would be useful for augmented reality.
Hand tracking
To do something similar to the pygame http://www.youtube.com/watch?v=HIDdxY3L5V8 .
Perhaps combine it with Dasher[1] to get something like http://www.youtube.com/watch?v=IK5_QYv3kf0 . Dasher would make a nice Activity. It even has a Mongolian corpus.
When one XO is present, several more are likely to be as well. Interesting possibilities. For instance, two XO's might work together to do 3D hand tracking. Others?
Downloads
The source can be downloaded from sourceforge, or OpenCV can be installed from the opencv package in the Fedora repository. To use OpenCV with python, also install the opencv-python package.
$ yum install opencv opencv-python
Problems
Currently, OpenCV fails to interface with the XO's Camera. It is therefore necessary to use xawtv or Gstreamer to capture video or images, and feed the results to OpenCV.
The problem is fixed in the latest CVS source, or can be fixed by changing the following at line 415 in otherlibs/highgui/cvcap_v4l.cpp in the opencv 1.0.0 source.
capture->form.fmt.pix.field = V4L2_FIELD_INTERLACED;
to
capture->form.fmt.pix.field = V4L2_FIELD_ANY;
Note that the packages required to compile OpenCV include gtk2-devel, which currently is not installable, a known bug. I got around it with the following, though your milage may vary.
yum -t --enablerepo=* install libXI-devel yum -t --enablerepo=* install gtk2-devel
An easier but even dirtier fix is available here.
Incomplete Frame Updates Using Highgui's: cvQueryFrame()
The query frame function in highgui (which is used in most of the python examples that ship with opencv),often returns frames that are only half updated
frame=cvQueryFrame(capture)
This function is roughly equivalent to
cvGrabFrame(capture) frame=cvRetrieveFrame(capture)
Often on the XO, the grab frame is incomplete when the camera is asked to return the frame. This results in an image where only the top half has been updated.
This problem can be solved by giving the camera time to complete the grab before retrieving the frame. Any non-trivial image grabbing loop takes long enough to execute for the camera to finish the grab (including a loop that simply displays the image), so calling the grab for the next iteration immediately after the retrieve for the current iteration usually solves the problem.
Demos
- PyEyes - http://eclecti.cc/olpc/pyeyes-xeyes-in-python-with-face-tracking
- Doesn't seem to currently work. (8.2.0) MitchellNCharity 20:29, 17 November 2008 (UTC)
- Colors! with charger tracking - http://eclecti.cc/code/paint-with-color-based-object-tracking-on-the-olpc-xo
- Doesn't seem to currently work. (8.2.0) MitchellNCharity 20:29, 17 November 2008 (UTC)
- This is unfortunately a known bug relating to the newer gstreamer. It is fairly trivial to fix, but it may be easier in the long term to switch from gstreamer to the Pygame camera module. Nrp 05:26, 24 November 2008 (UTC)
Links
- OpenCV Documentation Wiki (the temporary but working site)
- OpenCV SourceForge site
- OpenCV homepage at intel