Getting Emgu CV (OpenCV) to work in GHPython Guide

Guide for getting Emgu CV to work in the GHPython component:

You want to do something with Computer Vision and Grasshopper?
Already Realised that OpenCV doesn’t work with IronPython?
Scrapped the forums and found that Emgu CV is an option?
Can’t figure out how to install the damn thing?

I feel for you because I’ve been there too. That’s why I made this guide!

Follow these 7 easy steps and you will be ready to detect faces (and other body parts) from the comfort of the GHPython component in Grasshopper:

Turn on your Computer.

Download the latest version of EmguCV from SourceForge (in my case it was 4.2.0).

Link for EmguCV download:

Install EmguCV to “C:\Emgu”

Create a python file called “” and save it at “C:\Emgu\bin”.

The file should contain the following code:

import clr
from Emgu.CV import *
from Emgu.CV.UI import *
from Emgu.CV.Structure import *
from System import *

In Rhino add a Module Search path for python.
You can do this by typing in EditPythonScript in the command line. When the Rhino Python Editor opens, go to Tools --> Options and add “C:\Emgu\bin” to the search paths.

Under “C:\Emgu\libs” you are going to find two folders “x64” and “x86”. Copy both of them to the “C:\Program Files\Rhino 6\System” folder.

Restart Rhino.

After Rhino starts again you will be able to use Emgu CV from GHPython by importing EmguInit:

import EmguInit
from EmguInit import *

To use OpenCV methods you will need to utilise the Emgu CV “CvInvoke” class:

img = cv2.imread('test_2.png')OpenCV syntax

img = CvInvoke.Imread('test_2.png')Emgu CV syntax

You can find more information on EmguCV CvInvoke methods here:

Good luck in anything you are trying to do!



This is awesome! Thanks for sharing.

But I noticed I don’t get CvInvoke.VideoCapture (cv2.VideoCapture), so no webcam access? Would be a shame if this is the case :frowning:

and with Emgu CV 4.3, there is no bin folder from the zip download from: So I’m using the 4.2 release as well. Or do I need to build the .dll?

For EmguCV 4.4, I had to make

import clr
from Emgu.CV import *
from Emgu.CV.BitmapExtension import *
from Emgu.CV.Structure import *
from Emgu.CV.Util import *
from System import *

Also, you need to build 4.4 with Visual Studio to get the bin folder (building Solution\Windows.Desktop\Emgu.CV.Example.sln will do it).