OpenCv错误在C包装为imread: QNativeImage:无法连接到共享内存段

OpenCv Error in C Wrapper for imread: QNativeImage: Unable to attach to shared memory segment

本文关键字:连接 共享 内存 QNativeImage 包装 OpenCv imread 错误      更新时间:2023-10-16

这是我正在运行的代码。我正在使用Ubuntu,在Emacs中使用g++。我在这一页的底部看到了错误,但我可以借助帮助找出它们。该程序工作,它使用C包装为imread和imshow上面的主代码。图片出现,但窗口打开后,我得到长串代码如下…这一定是我的包装器,因为c++ imread和imshow工作得很完美…包装器是由软件分析师编写的,尽管它们被包含在OpenCv中,所以我不确定问题是什么。谷歌搜出了VLC、Ubuntu和qt的bug,但没有OpenCV的。包装器是为其他语言设计的,cv_imread不起作用。这就是我决定通过运行它们来进行调试的原因。然后我发现了这个。我重建并重新安装了opencv作为我的步骤之一,但得到了相同的信息。任何帮助都是感激的。

   #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是不同的东西。参考下面的函数原型:

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