我希望熟悉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時,沒有任何反應。
有時候這個庫包含一些其他的庫。只要確保你沒有錯過核心庫或其他。 –