2012-05-16 37 views
1

您好我基本上試圖使一個應用程序顯示和Opencv Iplimage在標籤中轉換爲QImage,我做了一個簡單的例子,它工作得很好,但現在當我嘗試整合圖像轉換到另一個項目,我得到undec Opencv函數引用是這樣的:undefined引用`cvQueryFrame'all來自Highgui使用Qt + Opencv時未定義的Opencv參考

我實際上使用相同的庫路徑,當我第一次嘗試圖像轉換時使用,只是這次它不工作。即時通訊使用Qt很新的,我不知道是哪裏的問題可能是:

#include <qt4/QtGui/QApplication> 
#include "myqtapp.h" 
#include <iostream> 
#include <stdlib.h> 
#include <stdio.h> 
#include <opencv/highgui.h> 
#include <opencv/cv.h> 

using namespace std; 
int main(int argc, char *argv[]) 
{ 

QApplication app(argc, argv); 
myQtApp *dialog = new myQtApp; 
//******************************************************************************************************** 
QImage myImage; 
QLabel label_5; 
IplImage* frame; 
//label_5 = new QLabel(myQtAppDLG); //Not using this Yet 
CvCapture* capture = cvCreateFileCapture("garden.bmp"); 
frame = cvQueryFrame(capture); 
cvCvtColor(frame,frame,CV_BGR2RGB); 
myImage = QImage((unsigned char *)frame->imageDataOrigin,frame->width,frame->height,QImage::Format_RGB888); 
//label_5.setPixmap(QPixmap::fromImage(myImage)); //Not using this Yet 
//******************************************************************************************************** 
dialog->show(); 
return app.exec(); 

}

main.cpp:(.text+0x44): undefined reference to `cvCreateFileCapture' 
main.cpp:(.text+0x4c): undefined reference to `cvQueryFrame' 
main.cpp:(.text+0x62): undefined reference to `cvCvtColor' 

正如你看到的我嘗試做的第一件事就是使用像CvQueryFrame一些OpenCV函數,有趣的是,即時通訊使用第一次使用的完全相同的路徑,也鏈接了完全相同的動態庫。我試過不同的路徑和編譯器,但似乎沒有任何工作,我不知道錯誤可能在哪裏。我使用Linux Ubuntu和Netbeans C++,任何提示?

回答

0

您錯過了將highgui庫包含在庫路徑中。 cvCreateFileCapture和cvCvtColor是該庫的一部分。

+1

是的,謝謝,我解決了它,事情是,我已經包括了圖書館的路徑,因爲我一直這樣做,但編譯器出了問題,我不得不直接添加庫在我的項目的生成文件 – user977480

+0

奇怪,但它現在看來它不在highgui中。我在'cvCvtColor'中得到了「未在此範圍內聲明」,並且我通過highgui搜索,沒有提及其中的'cvCvtColor'!許多其他功能都可以正常工作。 – vsz

+0

@vsz:是的,新版本中有很多變化。但是,根據問題中提供的代碼,我相信這個問題是在opencv 1.x的基礎上解決的。 – alinoz