Starting with Emgu CV

What is Emgu CV ?

Before learning what is Emgu CV, one should know what is Open CV.

Open CV

It stands for Open Source Computer Vision, it was designed especially for computational efficiency with strong focus on real time applications.  It is written in optimized C/C++, and can take advantage of multi-core processing. In Image processing it has been a great boon for the developers.

Emgu CV

Its is essentially a huge library of “wrapper” functions that allows calling OpenCV funtions from Visual Studio Windows Form Application. It is necessary because Visual Studio/.NET is an “interpreted” environment that cannot directly call functions written in native C/C++.

In this tutorial we will start configuring our Visual Studio and environment for developing applications using EmguCV.

Firstly we need to download some the essential tools, we will be using the most stable versions though the new versions are also available.

  1. Visual Studio 2010 Express Edition
  2. Emgu CV (version 2.4.2 is available but had various issues so I’m doing it with the most stable version found 2.3.0)

Once you have installed all this it should work fine, but one common exception found is

The type initializer for ‘Emgu.CV.CvInvoke’ threw an exception.

If you see this exception, do following :

  • For Version 2.4+, the bundled OpenCV binary is build with Visual Studio 2010, you will needs to installed MSVCRT 10.0 SP1 x86 or MSVCRT 10.0 SP1 x64 to resolve the dependency issue.
  • For Version 2.0+, the bundled OpenCV binary is build with Visual Studio 2008, you will needs to installed MSVCRT 9.0 SP1 to resolve the dependency issue.
  • For Version 1.5, the bundled OpenCV pre1.1 binary is build with Visual Studio 2005, you will needs to installed MSVCRT 8.0 SP1 to resolve the dependency issue.

This is the most effective solution to the problem for the above exception, for others and detailed troubleshooting click here.

Now start the configuration part :

  1. We need to add a environment variable to the system variables.
    Right Click My Computer>Advanced System Settings>Environment Variables
    Under “System Variables” edit variable “path”
    add a semicolon(;) and the path to the emgu installation directory bin folder(by default it is C:Emguemgucv-windows-x86 2.3.0.1416bin
    system variables
  2. Now the environment is ready and we need to add the emgu custom controls to Visual Studio ToolBox
    In the toolbox, right click on General tab and select “choose items”
    Visual Studio ToolBox
  3. Select browse on bottom right corner and browse for “Emgu.CV.UI.dll” (it is located in bin folder of installation directory i.e C:Emguemgucv-windows-x86 2.3.0.1416bin)
  4. Now the Visual Studio will have the tools for emgu control
    Emgu Controls

 This is all required for setting up the environment for working with Emgu CV, in the next article we will learn how to create our first project with Emgu CV. Cheers :)

D Programming Language

What is D?

D is a general purpose systems and applications programming language. It is a high level language, but retains the ability to write high performance code and interface directly with the operating system API‘s and with hardware. D is well suited to writing medium to large scale million line programs with teams of developers. D is easy to learn, provides many capabilities to aid the programmer, and is well suited to aggressive compiler optimization technology. D Man

D is not a scripting language, nor an interpreted language. It doesn’t come with a VM, a religion, or an overriding philosophy. It’s a practical language for practical programmers who need to get the job done quickly, reliably, and leave behind maintainable, easy to understand code.

D is the culmination of decades of experience implementing compilers for many diverse languages, and attempting to construct large projects using those languages. D draws inspiration from those other languages (most especially C++) and tempers it with experience and real world practicality.

Why D?

Why, indeed. Who needs another programming language?

The software industry has come a long way since the C language was invented. Many new concepts were added to the language with C++, but backwards compatibility with C was maintained, including compatibility with nearly all the weaknesses of the original design. There have been many attempts to fix those weaknesses, but the compatibility issue frustrates it. Meanwhile, both C and C++ undergo a constant accretion of new features. These new features must be carefully fitted into the existing structure without requiring rewriting old code. The end result is very complicated – the C standard is nearly 500 pages, and the C++ standard is about 750 pages! C++ is a difficult and costly language to implement, resulting in implementation variations that make it frustrating to write fully portable C++ code.

C++ implements things like resizable arrays and string concatenation as part of the standard library, not as part of the core language. Not being part of the core language has several suboptimal consequences.

Can the power and capability of C++ be extracted, redesigned, and recast into a language that is simple, orthogonal, and practical? Can it all be put into a package that is easy for compiler writers to correctly implement, and which enables compilers to efficiently generate aggressively optimized code?

Modern compiler technology has progressed to the point where language features for the purpose of compensating for primitive compiler technology can be omitted. (An example of this would be the ‘register’ keyword in C, a more subtle example is the macro preprocessor in C.) We can rely on modern compiler optimization technology to not need language features necessary to get acceptable code quality out of primitive compilers.

Who D is For

  • Programmers who routinely use lint or similar code analysis tools to eliminate bugs before the code is even compiled.
  • People who compile with maximum warning levels turned on and who instruct the compiler to treat warnings as errors.
  • Programming managers who are forced to rely on programming style guidelines to avoid common C bugs.
  • Those who decide the promise of C++ object oriented programming is not fulfilled due to the complexity of it.
  • Programmers who enjoy the expressive power of C++ but are frustrated by the need to expend much effort explicitly managing memory and finding pointer bugs.
  • Projects that need built-in testing and verification.
  • Teams who write apps with a million lines of code in it.
  • Programmers who think the language should provide enough features to obviate the continual necessity to manipulate pointers directly.
  • Numerical programmers. D has many features to directly support features needed by numerics programmers, like extended floating point precision, core support for complex and imaginary floating types and defined behavior for NaN‘s and infinities. (These are added in the new C99 standard, but not in C++.)
  • Programmers who write half their application in scripting langauges like Ruby and Python, and the other half in C++ to speed up the bottlenecks. D has many of the productivity features of Ruby and Python, making it possible to write the entire app in one language.
  • D’s lexical analyzer and parser are totally independent of each other and of the semantic analyzer. This means it is easy to write simple tools to manipulate D source perfectly without having to build a full compiler. It also means that source code can be transmitted in tokenized form for specialized applications.

Who D is Not For

  • Realistically, nobody is going to convert million line C or C++ programs into D. Since D does not compile unmodified C/C++ source code, D is not for legacy apps. (However, D supports legacy C API’s very well. D can connect directly to any code that exposes a C interface.)
  • As a first programming language – Basic or Java is more suitable for beginners. D makes an excellent second language for intermediate to advanced programmers.
  • Language purists. D is a practical language, and each feature of it is evaluated in that light, rather than by an ideal. For example, D has constructs and semantics that virtually eliminate the need for pointers for ordinary tasks. But pointers are still there, because sometimes the rules need to be broken. Similarly, casts are still there for those times when the typing system needs to be overridden.

~source D-Programming-Language