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

匿名 (未验证) 提交于 2019-12-03 01:23:02

问题:

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; } 

Errors:

  (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 

回答1:

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 ) 


易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!