Friday, August 08, 2008

OpenCV (Open Source Computer Vision) for C# – Wrapper, plus info on it

CodeProject - Easy to use Wrapper (DLL) for Intel's OpenCV Library with Examples

“If the first thing you want to do is try out some examples please start with reading the Install section.

This is my first contribution for this great forum and I hope the wrapper I'm introducing will be useful for those who are friends of the C# language and are occupied in the area of image processing.

Some years ago I decided to change from C++ (MSVS 6.0) and Java (Eclipse) to C#. I was surprised at how easy it was to pick up, even for understanding complex tasks. At the same time I was seized by the desire to port some of my older C++ image processing projects where I used parts of Intel's OpenCV Library.

Some Features

  • The wrapper is provided in the form of a dynamic link library. (DLL)
  • All exported methods (e.g. cvCanny,...), the most important macros, constructors, constant definitions and callbacks are visible through on class. (e.g.: cvlib.Functionname(...), cvlib.CV_LOAD_IMAGE_COLOR).
  • All structure definitions are usable in a familiar way (e.g. IplImage img;, CvMat mat;).
  • Special function parameters like pointers are passed by IntPtr, and for casting additional support is available (a second tools library, see cvtools) when necessary.
  • The conversion to and from drawing types like Bitmap is integrated in the Library and casting operators to and from Bitmap are available.
  • For error handling, the provided mechanisms of the OpenCV Library can be used. There is no support for exceptions (still not).
  • Callbacks are handled by predefind delegates. Use trackbars in a child window, mouse callbacks and error handlers in a familiar way.
  • The user has to take care freeing the unmanaged memory. This is simply done by call of the appropriated OpenCV functions, e.g. CvReleaseImage(...).

The OpenCV Library has a very extensive amount of highly developed algorithms (more than 400 functions, hundreds of macros, myriads of constants etc.) so it seemed nearly impossible for a single person to encapsulate all of this. Additionally, there is a high probability of overloading and default values.


Intel - Open Source Computer Vision Library


This library is intended for use, incorporation and modification by researchers, commercial software developers, government and camera vendors as reflected in the license.

See the Library Overview for a quick idea of what's in the library.

FAQ (Frequently Asked Questions).

Philosophy – Aid commercial uses of computer vision in human-computer interface, robotics, monitoring, biometrics and security by providing a free and open infrastructure where the distributed efforts of the vision community can be consolidated and performance optimized.


Open Source Computer Vision Library - Overview

“This library is mainly aimed at real time computer vision.  Some example areas would be  Human-Computer Interaction (HCI); Object Identification, Segmentation and Recognition; Face Recognition; Gesture Recognition; Motion Tracking, Ego Motion, Motion Understanding; Structure From Motion (SFM);  and Mobile Robotics.

Library Areas

  • Image functions
    Creation, allocation, destruction of images. Fast pixel access macros.

  • Contour Processing
    Finding, displaying, manipulation, and simplification of image contours.
  • Geometry
    Line and ellipse fitting.  Convex hull.  Contour analysis.

  • Morphology
    Erode, dilate, open, close. Gradient, top-hat, black-hat.
  • Background Differencing
    Accumulate images and squared images.  Running averages.

  • Camera Calibration
    Intrinsic and extrinsic, Rodrigues, un-distortion, Finding checkerboard calibration pattern
  • View Morphing
    8 point algorithm, Epipolar alignment of images
  • Gesture Recognition
    Stereo based: Finding hand, hand mask.  Image homography, bounding box.

Intel® Image Processing Library (included in OpenCV WinOS download):

  • Image creation and access (same image header used for both libraries).
  • Image arithmetic and logic operations.
  • Image filtering.
  • Linear image transformation.
  • Image morphology.
  • Color space conversion.
  • Image histogram and thresholding.
  • Geometric transformation (zoom-decimate, rotate, mirror, shear, warp, perspective transform, affine transform).
  • Image moments.


OpenVC Library Wiki

“Welcome to the OpenCV Wiki

This Wiki is intended to support the OpenCV community. The main objective is to share experiences and improve the documentation.


  1. Introduction
    1. What is OpenCV?
    2. How do I Download OpenCV?
    3. Installing OpenCV
    4. Getting Started with OpenCV
    5. Frequently Asked Questions
    6. Tutorials
  2. Support, Documentation & Resources
    1. Technical Support
    2. Documentation of Functions
    3. OpenCV Online Resources
    4. Ideas for the Future of OpenCV


This is the first time I’ve looked at OpenCV. Wow, there’s some pretty nifty stuff there! And the license is very friendly too.

Hum… Looks like one more project to keep an eye on. :)

1 comment:

rahuldeo2047 said...

How to use 'cvCaptureFromAVI' here.