简体   繁体   中英

c# GTK 2 & 3 conflict when using Emgucv

I found a strange confict when using Emgu with class 'ImageViewer'

When I have no static class member, everything work just fine. for example, code like below

using Emgu.CV;
using Emgu.CV.Util;
using Emgu.CV.UI;

namespace TmpTest
{
    class TmpTest
    {
        private Mat img = new Mat();  // a non-static class member is OKey
        public static void Main(string[] arg)
        {
            SDKWrapper util = new SDKWrapper();
            ImageViewer viewer = new ImageViewer ();
            VideoCapture capture = new VideoCapture ();

            Application.Idle += new EventHandler (delegate(object sender, EventArgs e) {
                Mat read_frame = capture.QueryFrame();
                util.processFrame(read_frame);
                util.drawSkeleton(read_frame);
                viewer.Image = read_frame;
            });
            viewer.ShowDialog ();  
            return;
        }
    }
}

But as soon as I add a static class member, for example, change private Mat img into private static Mat img , I got an runtime error immediately like this

Gtk-ERROR **: GTK+ 2.x symbols detected. Using GTK+ 2.x and GTK+ 3 in the same process is not supported

I'm using ubuntu 16.04 and monodevelopment, does anyone knows what had happened and how to solve it?

Emgu CV is a .Net wrapper to OpenCV. Depending on the OpenCV version you use, it can be build against GTK 2 or GTK 3, but usually is against GTK 2. However, an application can't use GTK 2 and GTK 3 at the same time. So I think the OpenCv part uses GTK 2 and you have something else pulling GTK 3. You should check on which libraries the binaries of emgu CV you're using depend.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM