Setting up Emgu CV and IronPython

From Emgu CV: OpenCV in .NET (C#, VB, C++ and more)
Jump to navigation Jump to search

To use Emgu CV 2.2 with IronPython (2.7) on Windows, please follow the steps below:

  • Run IronPython-{version}.msi and follow the instruction to install IronPython
  • Go to the folder that contains both
    • OpenCV binaries (all the "opencv_{module name}{version}.dll" files)
    • Emgu CV binaries (Emgu.CV.dll, Emgu.CV.UI.dll Emgu.Util.dll, ZedGraph.dll)
  • Copy EmguInit.py to the same Folder. The EmguInit.py contains the following code
import clr
clr.AddReferenceToFile("Emgu.Util.dll")
clr.AddReferenceToFile("Emgu.CV.dll")
clr.AddReferenceToFile("Emgu.CV.ML.dll")
clr.AddReferenceToFile("Emgu.CV.UI.dll")
from Emgu.CV import *
from Emgu.CV.UI import *
from Emgu.CV.Structure import *
from System import *
  • Run the ipy.exe program. (On Mono, call "mono ipy.exe")
  • From the IronPython command line, run the following command:
import EmguInit
from EmguInit import *
  • You are ready to go. Now try to run the following simple program
image = Image[Gray, Byte](320, 240)
image.SetRandNormal(MCvScalar(100), MCvScalar(100))
ImageViewer.Show(image)