2013-07-07 18 views
0

我希望熟悉openCV和圖像處理的人能夠儘快幫助我。
我絕對是新來的openCV和VC++,這是本週第三次,我遇到了錯誤LNK2019。
我知道這個錯誤意味着包含指定函數的.lib文件沒有鏈接到項目,並且它的合適的頭文件沒有被包含在代碼的頂部。
但基於this web page這個時候,我搜集這cvSmooth是包括在opencv_imgproc243d.lib的功能,所以我加入這個.LIB爲Additional Dependencies,並已寫入的行錯誤LNK2019:在函數「void __cdecl example2_4(struct _IplImage *)」中引用了無法解析的外部符號cvSmooth

#include "opencv2\imgproc\imgproc.hpp" 

在我的代碼頂部,但錯誤

error LNK2019: unresolved external symbol cvSmooth referenced in function "void __cdecl example2_4(struct _IplImage *)" 

不會改變,並保持不變。
我一直很困惑?
任何幫助,將不勝感激,如果需要,請告訴我添加代碼作爲編輯部分我的問題,請。
是不是和cvSmooth屬於另一個.lib文件?


基於h3now的建議,我的問題的編輯部分

我的代碼如下:

#include "stdafx.h" 
#include "opencv\cv.h" 
#include "opencv\highgui.h" 
#include "opencv2\core\core.hpp" 
#include "opencv2\imgproc\imgproc.hpp" 

void example2_4(IplImage* image) 
{ 
    // Create some windows to show the input 
    // and output images in. 
    // 
    cvNamedWindow("Example4-in",CV_WINDOW_AUTOSIZE); 
    cvNamedWindow("Example4-out",CV_WINDOW_AUTOSIZE); 
    // Create a window to show our input image 
    // 
    cvShowImage("Example4-in", image); 
    // Create an image to hold the smoothed output 
    // 
    IplImage* out = cvCreateImage(cvGetSize(image),IPL_DEPTH_8U,3); 
    // Do the smoothing 
    // 
    // Do the smoothing 
    // 
    cvSmooth(image, out, CV_GAUSSIAN, 3, 3); 
    // Show the smoothed image in the output window 
    // 
    cvShowImage("Example4-out", out); 
    // Be tidy 
    // 
    cvReleaseImage(&out); 
    // Wait for the user to hit a key, then clean up the windows 
    // 
    cvWaitKey(0); 
    cvDestroyWindow("Example4-in"); 
    cvDestroyWindow("Example4-out"); 
} 




int main(int argc, char* argv[]) 
{ 
    IplImage* img = cvLoadImage(argv[1]); 
    example2_4(img); 
    cvReleaseImage(&img); 
    system("pause"); 
    return 0; 
} 

例如,當我在功能上右鍵單擊cvCreateImage和並選擇Go To Definition打開一個名爲core_c.h的文件。所以理解這個函數的原型包含在core_c.h中。
因此,對於這個原因,我們明白,我們應該寫#include "opencv2\core\core.hpp"#include "opencv2\core\core_c.h"(我認爲使用任何兩個碼的沒有區別)在我們的代碼並鏈接opency_core243d.lib頂部的項目使用的功能cvCreateImage
但是當我右鍵點擊cvSmooth並選擇Go To Definition時,什麼也沒有發生
@ h3now建議的解決方案是否適用於所有功能?
因爲當我也右鍵單擊cvShowImage時,沒有任何反應。

+0

有時候這個庫包含一些其他的庫。只要確保你沒有錯過核心庫或其他。 –

回答

0

我有同樣的錯誤。我使用的是opencv 2.2而不是2.4.3,但解決方案應該是等效的。

找到需要包含的文件的好方法是(在Visual Studio中)右鍵單擊代碼中的函數名並選擇「轉到定義」。通過這樣做,我意識到我應該包含imgproc_c.h頭文件,而不是imgproc.hpp

+0

感謝您的關注,但請根據h3now的建議查看我的問題的編輯部分,以查看我真正擁有的問題。 – sepideh

相關問題