gpt4 book ai didi

c++ - imread : QNativeImage: Unable to attach to shared memory segment 的 C 包装器中的 OpenCv 错误

转载 作者:太空狗 更新时间:2023-10-29 23:16:39 26 4
gpt4 key购买 nike

这是我正在运行的代码。我在 Emacs 中使用 Ubuntu trusty with g++。我在页面底部收到错误,但我可以使用帮助来找出它们。该程序有效,它在代码的 main 上方使用 C 包装器进行 imread 和 imshow 。图片出现了,但在窗口打开后我得到了一长串代码,如下所示......它一定是我的包装器,因为 C++ imread 和 imshow 工作完美..包装器是由软件分析师编写的,尽管它们可以包含在OpenCv 所以我不确定问题是什么。谷歌搜索带来了 VLC、Ubuntu 和 qt 的错误,但没有发现 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。我认为字符串和字符串是不同的东西。引用下面的函数原型(prototype):

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

Mat imread( const string& filename, int flags )

关于c++ - imread : QNativeImage: Unable to attach to shared memory segment 的 C 包装器中的 OpenCv 错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22606144/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com