21,489
社区成员
发帖
与我相关
我的任务
分享
#ifndef MYTEST_H
#define MYTEST_H
#include <QtGui/QWidget>
#include <cv.h>
#include <QImage>
#include <QtCore>
#include <highgui.h>
class MyTest : public QWidget
{
Q_OBJECT
public:
MyTest(QWidget *parent = 0);
~MyTest();
void showImage(char *filename);
QImage& pConvQImage(IplImage *p,QImage &q);
private:
IplImage * pImage;
QImage qImage;
};
#endif // MYTEST_H
#include "mytest.h"
#include <QPainter>
MyTest::MyTest(QWidget *parent)
: QWidget(parent)
{
this->showImage("lena.jpg");
}
MyTest::~MyTest()
{
}
void MyTest::showImage(char *filename)
{
pImage = cvLoadImage(filename,1);
QPainter q;
q.drawImage(this->rect(),pConvQImage(pImage,qImage));
}
QImage& MyTest::pConvQImage(IplImage *p, QImage &q)
{
q = QImage((const uchar*)p->imageData,p->width,p->height,p->widthStep,QImage::Format_RGB888);
return q;
}
#include <QtGui/QApplication>
#include "mytest.h"
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MyTest w;
w.show();
return a.exec();
}
TARGET = test_OpenCV4
TEMPLATE = app
SOURCES += main.cpp\
mytest.cpp
HEADERS += mytest.h
INCLUDEPATH += D:\OpenCV2.0\include\opencv \
LIBS \
+= \
D:\OpenCV2.0\lib
D:/learning/workspace/test_OpenCV4/mytest.cpp:17: undefined reference to `cvLoadImage'
:-1: error: collect2: ld returned 1 exit status
INCLUDEPATH += D:\OpenCV2.0\include\opencv
LIBS += D:\OpenCV2.0\lib\libcv200.dll.a\
D:\OpenCV2.0\lib\libcvaux200.dll.a \
D:\OpenCV2.0\lib\libcxcore200.dll.a \
D:\OpenCV2.0\lib\libcxts200.dll.a \
D:\OpenCV2.0\lib\libhighgui200.dll.a \
D:\OpenCV2.0\lib\libml200.dll.a
INCLUDEPATH += D:\OpenCV2.0\include\opencv
LIBS += D:\OpenCV2.0\lib