C包装器中的OpenCv错误,导致读入:QNativeImage:无法附加到共享内存段 [英] OpenCv Error in C Wrapper for imread: QNativeImage: Unable to attach to shared memory segment

查看:121
本文介绍了C包装器中的OpenCv错误,导致读入:QNativeImage:无法附加到共享内存段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我正在运行的代码.我在Emacs中将Ubuntu Trusty与g ++一起使用.我在页面底部看到了错误,但是我可以使用帮助来找出它们.该程序可以正常工作,它使用C包装程序在代码主体中进行imread和imshow.图片出现了,但是在窗口打开后,我立即得到一串长长的代码,如下所示...它一定是我的包装器,因为C ++的imread和imshow可以完美地工作.这些包装器是由软件分析师编写的,尽管它们准备包含在其中. OpenCv,所以我不确定是什么问题. Googling带来了VLC,Ubuntu和qt错误,但OpenCV没有.包装器是为其他语言而包装的,并且cv_imread无法正常工作.这就是我决定通过运行它们进行调试的原因.然后我发现了这一点.我重建并重新安装了opencv作为我的步骤之一,但得到了相同的消息.任何帮助表示赞赏.

Here is my code I am running. I'm using Ubuntu trusty with g++ in Emacs. I'm getting the errors at the bottom of page but I could use help to figure them out. The program works, it uses the C wrappers for imread and imshow above the main in the code. The picture comes up but right after window opens i get long string of code as below...It must be my wrappers because the C++ imread and imshow work perfect..The wrappers were written by a software analyst though they are up for inclusion in OpenCv so I'm not sure what the issue is. Googling brings up VLC, Ubuntu, and qt bugs but none for OpenCV. The wrappers are made for other languages to wrap around and cv_imread isn't working. That is the reason I decided to debug by running them. Then I discovered this. I rebuilt and reinstalled opencv as one of my steps but got the same message. Any help is appreciated.

   #include "opencv2/highgui/highgui.hpp"
#include "opencv2/highgui/highgui_c.h"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/imgproc/imgproc_c.h"
#include <iostream>

using namespace cv;
using namespace std;

Mat* cv_imread(String* filename, int flags) {

    return new Mat(imread(*filename, flags));
}

void cv_imshow(String* winname, Mat* mat) {
    cv::imshow(*winname, *mat);
}

int main(  )
{
    const char* a = "/home/w/100_0229.JPG";
    const char* c = "String";
    Mat*  b =  cv_imread(new String (a), 1);

 cv_imshow(new String (c), b);

waitKey(0); //wait infinite time for a keypress

     destroyWindow("MyWindow"); //destroy the window with the name, "MyWindow"

return 0;
}

错误:

  (b:19717): Gtk-WARNING **: Unable to locate theme engine in module_path: "clearlooks",
init done
opengl support available
QNativeImage: Unable to attach to shared memory segment.
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x0
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x0
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x0
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x0
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x0
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x0
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x0
X Error: BadDrawable (invalid Pixmap or Window parameter) 9
  Major opcode: 62 (X_CopyArea)
  Resource id:  0x0
1uuuuuuu
Compilation finished at Mon Mar 24 02:46:13

推荐答案

C ++对大小写敏感,opencv使用string作为其参数,但是使用String.我认为string和String是不同的东西.请参考下面的函数原型:

C++ is capital sensitive, opencv use string as its parameter, but you use String. I think string and String are different thing. Refer function prototype below:

static void*
imread_( const string& filename, int flags, int hdrtype, Mat* mat=0 )

Mat imread( const string& filename, int flags )

这篇关于C包装器中的OpenCv错误,导致读入:QNativeImage:无法附加到共享内存段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆