-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Tutorial for Windows
Jiglxr edited this page Sep 22, 2022
·
6 revisions
日本語が読める方は、以下をどうぞ。
- http://schima.hatenablog.com/entries/2009/06/16
- http://schima.hatenablog.com/entry/2013/12/15/110513
- Download pre-built OpenCV binaries from here: https://opencv.org/releases/
- See: http://docs.opencv.org/doc/tutorials/introduction/windows_install/windows_install.html#windows-installation
Start Visual Studio (2005 or later). Create a new Windows Forms Application project (File -> New Project, Windows Form Application).
Add a reference to OpenCvSharp.dll (Project -> Add Reference, Browse, find DLL).
Type in the following code to Program.cs and execute.
using System;
using System.Runtime.InteropServices;
using OpenCvSharp;
namespace WindowsFormsApplication1
{
static class Program
{
static void Main()
{
using (IplImage image = new IplImage(128, 128, BitDepth.U8, 1))
{
image.Zero();
for (int x = 0; x < image.Width; x++)
{
for (int y = 0; y < image.Height; y++)
{
int offset = y * image.WidthStep + x;
byte value = (byte)(x + y);
Marshal.WriteByte(image.ImageData, offset, value);
}
}
using (CvWindow window = new CvWindow(image))
{
CvWindow.WaitKey();
}
}
}
}
}
ML and cvblob(http://code.google.com/p/cvblob) are implemented with C++, therefore OpenCvSharp.Blob and OpenCvSharp.MachineLearning depend on the C++ wrapper OpenCvSharpExtern.dll. You need to put a OpenCvSharpExtern.dll in the same directory as the executable file (ex. bin/Debug).
Add the OpenCvSharpExtern.dll to your solution explorer, and set the copy property to "Copy if newer" or "Copy always".