Configure the OpenCV (EmguCV) Environment in Unity3d

Source: Internet
Author: User

Recently, I have been studying how to use EmguCV in Unity for my graduation project, and I have achieved little success today.

My environment: Unity3d 4.3.1f
Libemgucv-windows-universal-gpu-2.4.9.1847

Http://forum.unity3d.com/threads/182600-OpenCV-(EMGUCV-wrapper)-integration-in-Unity

Start now: 1. download and install the libemgucv-windows-universal-gpu-2.4.9.1847, note that this is the version I used, and other Emgu versions may have different files to introduce the project.

Download: http://sourceforge.net/projects/emgucv/files/emgucv/2.4.9-alpha/

2. Open the bin folder in the Emgu installation folder. If my location is C: \ Emgu \ emgucv-windows-universal-gpu 2.4.9.1847 \ bin, copy the 12 dll files in the bin directory to

Under the Plugins directory, and then copy the 22 dll files under the X86 folder to the Plugins folder.

3. Create an Editor folder in the Unity project and put the cudart32_50_35 and npp32_50_35 files under Plugins into the Editor folder.

4. (This step is not required for confirmation. If the preceding three steps are acceptable, this step is omitted) copy the cudart32_50_35 and npp32_50_35 files to the Editor under the Unity root directory,

For example, C: \ Program Files (x86) \ Unity \ Editor.

5. Set Player Setting to. NET 2.0.

Now, if it is normal, you can test the code and use System. drowing, now provides the available System of Unity. drowing. dll file, drag one of them into Plugins.

CSDN address: http://download.csdn.net/detail/pmrssn/7377343

Test code:

Using UnityEngine;
Using System. Collections;
Using Emgu. CV;
Using Emgu. CV. Util;
Using Emgu. CV. UI;
Using Emgu. CV. CvEnum;
Using Emgu. CV. Structure;
Using System. Runtime. InteropServices;
Using System;
Using System. Drawing;
Public class Test: MonoBehaviour {


Void Start ()
{
Image <Bgr, byte> picture = new Image <Bgr, byte> ("C: \ picture1.jpg ");
Bgr myWhiteColor = new Bgr (255, 0,255 );
For (int I = 0; I <200; I ++)
{
Picture [I, I] = myWhiteColor;
}
Picture. Save ("C: \ picture2.jpg ");
}
}

Running result:

Picture1.jpg picture2.jpg


Note 1: only available when the test target is PC, WebPlayer unavailable, not tested on other platforms

2: I'm not sure whether to configure the OpenCV environment, because I used to configure it.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.