I have a Windows 7 Intel i7 laptop (Toshiba Qosmio). I downloaded OpenCV for
Windows and OpenCVSharp for Windows. I tried to run the simple example - with
no success.
Compiles fine - I get the following error when executed in debug mode:
using (CvCapture cap = CvCapture.FromCamera(0))
TypeInitializationException was unhandled
The type initializer for 'OpenCvSharp.CvInvoke' thres and exception.
I tried lots of things - no luck. I tried copying OpenCV .dll's into
the Debug directory - cannot find the right DLL's - they all lead
with "opencv_core230.dll". I do not think OpenCvSharp wants them named
this way.
I would appreciate help.
Thanks,
Art
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;
using OpenCvSharp;
using System.Threading;
using System.Reflection;
using System.Runtime.CompilerServices;
namespace OpenCvSharp_Proj_1
{
public partial class OpenCvSharp_Proj_1 : Form
{
public OpenCvSharp_Proj_1()
{
InitializeComponent();
using (CvCapture cap = CvCapture.FromCamera(0))
using (CvWindow w = new CvWindow("OpenCV Example"))
{
while (CvWindow.WaitKey(10) < 0)
{
using (IplImage src = cap.QueryFrame())
using (IplImage gray = new IplImage(src.Size, BitDepth.U8, 1))
using (IplImage dstCanny = new IplImage(src.Size, BitDepth.U8, 1))
{
src.CvtColor(gray, ColorConversion.BgrToGray);
Cv.Canny(gray, dstCanny, 50, 50, ApertureSize.Size3);
w.Image = dstCanny;
}
}
}
}
}
}