我在QT中运行以下简单代码(它需要openBR,但我已经安装了它)。该项目名为“openBRtest”。该文件名为openbrtestplugin.cpp:
//Playing Video
#include <openbr_plugin.h>
using namespace cv;
static void printTemplate(const br::Template &t)
{
const QPoint firstEye = t.file.get<QPoint>("Affine_0");
const QPoint secondEye = t.file.get<QPoint>("Affine_1");
printf("%s eyes: (%d, %d) (%d, %d)\n", qPrintable(t.file.fileName()), firstEye.x(), firstEye.y(), secondEye.x(), secondEye.y());
}
int main(int argc, char *argv[])
{
br::Context::initialize(argc, argv);
// Retrieve classes for enrolling and comparing templates using the FaceRecognition algorithm
QSharedPointer<br::Transform> transform = br::Transform::fromAlgorithm("FaceRecognition");
QSharedPointer<br::Distance> distance = br::Distance::fromAlgorithm("FaceRecognition");
// Initialize templates
br::Template queryA("../data/MEDS/img/S354-01-t10_01.jpg");
br::Template queryB("../data/MEDS/img/S382-08-t10_01.jpg");
br::Template target("../data/MEDS/img/S354-02-t10_01.jpg");
// Enroll templates
queryA >> *transform;
queryB >> *transform;
target >> *transform;
printTemplate(queryA);
printTemplate(queryB);
printTemplate(target);
// Compare templates
float comparisonA = distance->compare(target, queryA);
float comparisonB = distance->compare(target, queryB);
// Scores range from 0 to 1 and represent match probability
printf("Genuine match score: %.3f\n", comparisonA);
printf("Impostor match score: %.3f\n", comparisonB);
br::Context::finalize();
return 0;
}
这是h文件openbrtestplugin.h:
#ifndef OPENBRTESTPLUGIN_H
#define OPENBRTESTPLUGIN_H
#include <QDesignerCustomWidgetInterface>
class openbrTestPlugin : public QObject, public QDesignerCustomWidgetInterface
{
Q_OBJECT
Q_INTERFACES(QDesignerCustomWidgetInterface)
#if QT_VERSION >= 0x050000
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.QDesignerCustomWidgetInterface")
#endif // QT_VERSION >= 0x050000
public:
openbrTestPlugin(QObject *parent = 0);
bool isContainer() const;
bool isInitialized() const;
QIcon icon() const;
QString domXml() const;
QString group() const;
QString includeFile() const;
QString name() const;
QString toolTip() const;
QString whatsThis() const;
QWidget *createWidget(QWidget *parent);
void initialize(QDesignerFormEditorInterface *core);
private:
bool m_initialized;
};
#endif
这是我的专业档案:
CONFIG += plugin debug_and_release
TARGET = $$qtLibraryTarget(openbrtestplugin)
TEMPLATE = lib
HEADERS = openbrtestplugin.h
SOURCES = openbrtestplugin.cpp
RESOURCES = icons.qrc
LIBS += -L.
greaterThan(QT_MAJOR_VERSION, 4) {
QT += designer
} else {
CONFIG += designer
}
target.path = $$[QT_INSTALL_PLUGINS]/designer
INSTALLS += target
include(openbrtest.pri)
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../opencv-2.4.6.1/build-msvc2012/lib/ -lopencv_core246
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../opencv-2.4.6.1/build-msvc2012/lib/ -lopencv_core246d
INCLUDEPATH += $$PWD/../../../../../../opencv-2.4.6.1/build-msvc2012/include
DEPENDPATH += $$PWD/../../../../../../opencv-2.4.6.1/build-msvc2012/include
win32:CONFIG(release, debug|release): LIBS += -L$$PWD/../../../../../../opencv-2.4.6.1/build-msvc2012/lib/ -lopencv_highgui246
else:win32:CONFIG(debug, debug|release): LIBS += -L$$PWD/../../../../../../opencv-2.4.6.1/build-msvc2012/lib/ -lopencv_highgui246d
else:unix: LIBS += -L$$PWD/../../../../../../opencv-2.4.6.1/build-msvc2012/lib/ -lopencv_highgui246
INCLUDEPATH += $$PWD/../../../../../../opencv-2.4.6.1/build-msvc2012/include
INCLUDEPATH+= C:\opencv-2.4.6.1\include
INCLUDEPATH += C:\openbr\build-msvc2012\install\include
INCLUDEPATH += C:\openbr\build-msvc2012\install\include\openbr
INCLUDEPATH += C:\opencv-2.4.6.1\modules\core\include
DEPENDPATH += C:\openbr\build-msvc2012\install\lib
INCLUDEPATH += $$PWD/../../../../../../openbr/build-msvc2012/install/include
DEPENDPATH += $$PWD/../../../../../../openbr/build-msvc2012/install/include
LIBS += -lC:\openbr\build-msvc2012\install\lib\openbr
我收到以下链接器错误:
moc_openbrtestplugin.obj:-1: error: LNK2019: unresolved external symbol "public: __cdecl openbrTestPlugin::openbrTestPlugin(class QObject *)" (??0openbrTestPlugin@@QEAA@PEAVQObject@@@Z) referenced in function qt_plugin_instance
我不知道是什么导致它。我在专业文件中添加了必要的包含和库。
我会很高兴得到一些帮助,因为我很困难,不知道如何解决它。
谢谢, 吉尔。