编辑:将问题缩小到(失败)
cv::namedWindow(...)
cv::imshow(...)
基本上,我正在尝试在文件中包含opencv代码片段,如下所示。
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include "someFile.h"
//using namespace cv;
using namespace std;
int helloWorld(){
printf("hello from CPP");
cv::Mat image1, image2, dst;
image1 = cv::imread("/home/gabriel/pics/opencv-logo.jpg", CV_LOAD_IMAGE_COLOR);
if ( !image1.data){
printf("Error loading image1 \n");
return -1;}
image2 = cv::imread("/home/gabriel/pics/opencv-test.png", CV_LOAD_IMAGE_COLOR);
if ( !image1.data){
printf("Error loading image2 \n");
return -1;}
//add( image1, image2, dst);
// dst = image1 + image2
cv::namedWindow( "Display window", CV_WINDOW_AUTOSIZE );
cv::imshow( "Display window", image2 );
cv::namedWindow(" Display window ", CV_WINDOW_AUTOSIZE );
cv::imshow( "Display window", image1 );
//namedWindow(" Display window ", CV_WINDOW_AUTOSIZE );
//imshow( "Display window", dst );
cv::waitKey(0);
return 0;
}
使用cmake进行的编译运行良好(在c中包装/实现的c ++ opencv代码),但是在运行文件时从c ++到达我的函数时会抛出错误。
**
Gtk:ERROR:/build/gtk+2.0-XBK2Qt/gtk+2.0-2.24.32/gtk/gtkaccelmap.c:113:_gtk_accel_map_init: assertion failed: (accel_entry_ht == NULL)
**
Gtk:ERROR:/build/gtk+2.0-XBK2Qt/gtk+2.0-2.24.32/gtk/gtkaccelmap.c:113:_gtk_accel_map_init: assertion failed: (accel_entry_ht == NULL)
**
Gtk:ERROR:/build/gtk+2.0-XBK2Qt/gtk+2.0-2.24.32/gtk/gtkaccelmap.c:113:_gtk_accel_map_init: assertion failed: (accel_entry_ht == NULL)
Aborted (core dumped)
找不到太多关于此错误的信息,希望能查看失败的地方。使用helloWorld()函数失败(注释掉该函数后,代码可以平稳运行)
答案 0 :(得分:0)
我不确定是什么原因导致了该错误的发生,但看起来该点已在更高版本的某个位置更新:https://github.com/GNOME/gtk/commit/f119c834c1770f183ef4722f82e9c120b3954474#diff-cad9b5941076c1782f4e9bcbbe13eb0a
gtk-3-4看起来像第一个版本有此更改:https://github.com/GNOME/gtk/blob/gtk-3-4/gtk/gtkaccelmap.c