对不起,如果我的英语不完美,我的第一语言是法语。
在我的程序中,我试图发送带有信号的Mat变量。当我这样做时,我收到了这个错误:
QObject::connect: Cannot queue arguments of type 'Mat'
(Make sure 'Mat' is registered using qRegisterMetaType().)
我已经在旧项目中遇到过这个问题,我在本主题中找到了解决方案。
How to send a Qt signal containing a cv::Mat?
解决方案是在我的主要部分添加这一行:
qRegisterMetaType<Mat>("Mat");
但是当我用我的树莓派Pi执行我的程序时,我收到了这个错误:
./(myprojet): relocation error: ./(myprojet): symbol _ZN9QMetaType22registerNormalizedTypeERK10QByteArrayPFvPvEPFS3_S3_PKvEi6QFlagsINS_8TypeFlagEEPK11QMetaObject, version Qt_5 not defined in file libQt5Core.so.5 with link time reference
程序崩溃了。如果我删除该行,我有第一个错误。
我的代码在哪里使用有问题的行。
#include "partage.h"
#include "mainwindow.h"
#include <QApplication>
#include <cvimagewidget.h>
#include <ctime>
#include <iostream>
#include <QThread>
#include "cameraprocess.h"
//#include <unistd.h>
#include "raspicam/raspicam_cv.h"
#include "opencv/highgui.h"
#include "opencv/cv.h"
using namespace cv;
using namespace std;
Partage infoCommun;
Q_DECLARE_METATYPE(Mat)
//Q_DECLARE_METATYPE(Mat); also try this but not work
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow w;
qRegisterMetaType<Mat>("Mat");
CVImageWidget* imageWidget = new CVImageWidget();
QThread* camThread= new QThread;
CameraProcess* process_1= new CameraProcess;
infoCommun.data.camPross=process_1;
infoCommun.data.camThread=camThread;
infoCommun.data.imgWidget=imageWidget;
w.connectThread(camThread,&a,process_1);
camThread->start();
w.setFocusPolicy(Qt::ClickFocus);
Mat img=imread("lena2.jpeg",CV_LOAD_IMAGE_COLOR);
imageWidget->showImage(img);
/*CVImageWidget* imageWidget = new CVImageWidget();
Mat img=imread("lena2.jpeg",CV_LOAD_IMAGE_COLOR);
imageWidget->showImage(img);*/
w.setCentralWidget(imageWidget);
w.show();
return a.exec();
}
修改
我已经找到了为什么代码可以无错误地编译而且在执行时它们有它。这是因为当我设置我的交叉编译时,我在我的覆盆子pi上有一个巨大的problem和qt解决了它,我需要重新安装覆盆子Pi的新图像。但我有一些困难重新生成我的qmake.exe whit这个新图像,所以我使用旧的qmake,它完美地工作,因为他们有一些共同的库。所以错误是兼容性错误。为了修复它,我试图复制.so,我用来在我的rasberry pi里用qt编译。当我尝试执行我的程序时,我得到了这个。
此应用程序无法启动,因为它无法找到或加载 Qt平台插件“eglfs”在“”。
重新安装应用程序可能会解决此问题。中止
找到插件的位置我在终端中输入以下命令。
export QT_DEBUG_PLUGINS=1
新结果是有一个新行
QFactoryLoader::QFactoryLoader() checking directory path "/home/Projet/ProjetPololu/platforms" ...
平台路径是/ usr / lib / arm-linux-gnueabihf / qt5 / plugins /所以我不知道它为什么在这里搜索...但是我将好吃的覆盆子pi的平台放在我的项目文件夹里,那就是我得到了什么:
QFactoryLoader::QFactoryLoader() checking directory path "/home/Projet/ProjetPololu/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "/home/Projet/ProjetPololu/platforms/libqeglfs.so"
Found metadata in lib /home/Projet/ProjetPololu/platforms/libqeglfs.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2",
"MetaData": {
"Keys": [
"eglfs"
]
},
"className": "QEglFSIntegrationPlugin",
"debug": false,
"version": 328450
}
Got keys from plugin meta data ()
QFactoryLoader::QFactoryLoader() looking at "/home/Projet/ProjetPololu/platforms/libqkms.so"
Found metadata in lib /home/Projet/ProjetPololu/platforms/libqkms.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2",
"MetaData": {
"Keys": [
"kms"
]
},
"className": "QKmsIntegrationPlugin",
"debug": false,
"version": 328450
}
Got keys from plugin meta data ()
QFactoryLoader::QFactoryLoader() looking at "/home/Projet/ProjetPololu/platforms/libqlinuxfb.so"
Found metadata in lib /home/Projet/ProjetPololu/platforms/libqlinuxfb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2",
"MetaData": {
"Keys": [
"linuxfb"
]
},
"className": "QLinuxFbIntegrationPlugin",
"debug": false,
"version": 328450
}
Got keys from plugin meta data ()
QFactoryLoader::QFactoryLoader() looking at "/home/Projet/ProjetPololu/platforms/libqminimal.so"
Found metadata in lib /home/Projet/ProjetPololu/platforms/libqminimal.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2",
"MetaData": {
"Keys": [
"minimal"
]
},
"className": "QMinimalIntegrationPlugin",
"debug": false,
"version": 328450
}
Got keys from plugin meta data ()
QFactoryLoader::QFactoryLoader() looking at "/home/Projet/ProjetPololu/platforms/libqminimalegl.so"
Found metadata in lib /home/Projet/ProjetPololu/platforms/libqminimalegl.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2",
"MetaData": {
"Keys": [
"minimalegl"
]
},
"className": "QMinimalEglIntegrationPlugin",
"debug": false,
"version": 328450
}
Got keys from plugin meta data ()
QFactoryLoader::QFactoryLoader() looking at "/home/Projet/ProjetPololu/platforms/libqoffscreen.so"
Found metadata in lib /home/Projet/ProjetPololu/platforms/libqoffscreen.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2",
"MetaData": {
"Keys": [
"offscreen"
]
},
"className": "QOffscreenIntegrationPlugin",
"debug": false,
"version": 328450
}
Got keys from plugin meta data ()
QFactoryLoader::QFactoryLoader() looking at "/home/Projet/ProjetPololu/platforms/libqxcb.so"
Found metadata in lib /home/Projet/ProjetPololu/platforms/libqxcb.so, metadata=
{
"IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.2",
"MetaData": {
"Keys": [
"xcb"
]
},
"className": "QXcbIntegrationPlugin",
"debug": false,
"version": 328450
}
Got keys from plugin meta data ()
This application failed to start because it could not find or load the Qt platform plugin "eglfs"
in "".
Reinstalling the application may fix this problem.
Aborted
如果我尝试用我的工具链中的平台替换我得到了相同的结果
如果你能告诉我它为什么会发生,或者有另一种方法可以解决第一个问题。我们将不胜感激。 感谢阅读。